aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-08-04 23:14:55 +0100
committergingerBill <bill@gingerbill.org>2018-08-04 23:14:55 +0100
commitcdbf831a7a6d9bc36e3cf76d525c44af88dc0a53 (patch)
treeea6d0be0d032a77f6d7c0303be4dffd31c837412 /examples
parent0718f14774c152b84edb747c03ca53b9400407b9 (diff)
Replace `context <- c {}` with `context = c;`. context assignments are scope based
Diffstat (limited to 'examples')
-rw-r--r--examples/demo/demo.odin20
1 files changed, 9 insertions, 11 deletions
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin
index 477408e62..4860d9414 100644
--- a/examples/demo/demo.odin
+++ b/examples/demo/demo.odin
@@ -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);
}
}