Skip to content

Commit 8ea2e61

Browse files
committed
Add a capcity member for lists
This is to keep track of the amount that we have allocated for mutable lists.
1 parent a56a7c3 commit 8ea2e61

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

M2/Macaulay2/d/actors5.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ examine(e:Expr):Expr := (
516516
<< "basic list:" << endl
517517
<< " length: " << length(s.v) << endl
518518
<< " hash: " << s.hash << endl
519-
<< " mutable: " << s.Mutable << endl;
519+
<< " mutable: " << s.Mutable << endl
520+
<< " capacity: " << s.capacity << endl;
520521
nullE)
521522
is s:SpecialExpr do (
522523
stdIO

M2/Macaulay2/d/basic.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export seq(e:Expr):Expr := Expr(Sequence(e));
9999
export seq(e:Expr,f:Expr):Expr := Expr(Sequence(e,f));
100100
export seq(e:Expr,f:Expr,g:Expr):Expr := Expr(Sequence(e,f,g));
101101
export list(classs:HashTable,a:Sequence,is_mutable:bool):Expr := (
102-
r := List(classs,a,hash_t(0),is_mutable);
102+
r := List(classs,a,hash_t(0),is_mutable, length(a));
103103
Expr(sethash(r)));
104104
export list(classs:HashTable,a:Sequence):Expr := list(classs, a, false);
105105
export list(a:Sequence):Expr := list(listClass, a);

M2/Macaulay2/d/parse.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ export List := {+
312312
Class:HashTable,
313313
v:Sequence,
314314
hash:hash_t,
315-
Mutable:bool
315+
Mutable:bool,
316+
capacity:int -- amount of allocated memory (for mutable lists)
316317
};
317318

318319
export Error := {+

0 commit comments

Comments
 (0)