Skip to content

Commit a9788a8

Browse files
authored
Merge pull request #1989 from andrew-johnson-4/gc-disabled-lib2-deploy-diiiilklsd
Gc disabled lib2 deploy diiiilklsd
2 parents 7084241 + 71aceb9 commit a9788a8

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

lib2/core/hashtable.lsts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ let .length(h: Hashtable<k,v>): USize = (
8383
# Reallocates the hashtable with a new capacity, rehashing all existing entries.
8484
# Used internally when the hashtable needs to grow.
8585
let .realloc(h: Hashtable<k,v>, target-capacity: USize): Hashtable<k,v> = (
86-
let new-data = mk-sparse-owned-data(type((HashtableRowExists,k,v)), target-capacity);
86+
let new-data = Hashtable(mk-sparse-owned-data(type((HashtableRowExists,k,v)), target-capacity));
8787
let old-i = 0_sz;
8888
while old-i < h.data.capacity {
8989
let old-kv = h.data[old-i];
9090
if is(old-kv.first,HashtableRowFilled)
91-
then new-data[old-i] = h.data[old-i];
91+
then new-data.bind-direct(old-kv.second, old-kv.third);
9292
old-i = old-i + 1;
9393
};
94-
Hashtable(new-data)
94+
new-data
9595
);
9696

9797
# new allocations = 1 if realloc is necessary

tests/promises/hashtable/comparison.lsts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ assert( safe-alloc-block-count == 0 );
2525
assert( {"1":"2"}.lookup("1","3") == "2" );
2626
assert( {"1":"2"}.lookup("2","3") == "3" );
2727
assert( safe-alloc-block-count == 0 );
28+
29+
assert( {"1":"2"}["1"] == {"1":"2","2":"3","3":"4","4":"5","5":"6","6":"7","7":"8","8":"9","9":"10","10":"11","11":"12","12":"13","13":"14","14":"15","15":"16","16":"17","17":"18",
30+
"18":"19","19":"20","20":"21","21":"22","22":"23"}["1"] );
31+
assert( {"1":"2","2":"3","3":"4","4":"5","5":"6","6":"7","7":"8","8":"9","9":"10","10":"11","11":"12","12":"13","13":"14","14":"15","15":"16","16":"17","17":"18",
32+
"18":"19","19":"20","20":"21","21":"22","22":"23","23":"24","24":"25","25":"26","26":"27","27":"28","28":"29","29":"30","30":"31","31":"32","32":"33"}["11"] == Some("12") );
33+
assert( safe-alloc-block-count == 0 );
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
import lib/std/minimal.lsts;
3+
4+
let table = mk-hashtable(type(String), type(U64));
5+
6+
let ti = 0_u64;
7+
while ti < 5000 {
8+
table = table.bind("\{ti}", ti);
9+
ti = ti + 1;
10+
};
11+
12+
ti = 0_u64;
13+
while ti < 5000 {
14+
assert(table.lookup("\{ti}", 0_u64) == ti);
15+
ti = ti + 1;
16+
};

0 commit comments

Comments
 (0)