Replace context <- c {} with context = c;. context assignments are scope based

This commit is contained in:
gingerBill
2018-08-04 23:14:55 +01:00
parent 0718f14774
commit cdbf831a7a
10 changed files with 133 additions and 136 deletions
+9 -11
View File
@@ -364,26 +364,24 @@ parametric_polymorphism :: proc() {
allocate :: proc(table: ^$T/Table, capacity: int) {
c := context;
if table.allocator.procedure != nil do c.allocator = table.allocator;
context = c;
context <- c {
table.slots = make_slice(type_of(table.slots), max(capacity, TABLE_SIZE_MIN));
}
table.slots = make_slice(type_of(table.slots), max(capacity, TABLE_SIZE_MIN));
}
expand :: proc(table: ^$T/Table) {
c := context;
if table.allocator.procedure != nil do c.allocator = table.allocator;
context = c;
context <- c {
old_slots := table.slots;
defer delete(old_slots);
old_slots := table.slots;
defer delete(old_slots);
cap := max(2*len(table.slots), TABLE_SIZE_MIN);
allocate(table, cap);
cap := max(2*len(table.slots), TABLE_SIZE_MIN);
allocate(table, cap);
for s in old_slots do if s.occupied {
put(table, s.key, s.value);
}
for s in old_slots do if s.occupied {
put(table, s.key, s.value);
}
}