about summary refs log tree commit diff stats
path: root/070table.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-31 21:59:05 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-31 21:59:05 -0700
commit88b8d6124e199a61c302e4f7b826fbc991410076 (patch)
tree81e437126d755e2433f709f4b5be57b44324b697 /070table.mu
parent7c3bbb775b92577a147676c2901c449abfe4e8ca (diff)
downloadmu-88b8d6124e199a61c302e4f7b826fbc991410076.tar.gz
3615
Diffstat (limited to '070table.mu')
-rw-r--r--070table.mu14
1 files changed, 7 insertions, 7 deletions
diff --git a/070table.mu b/070table.mu
index 111e56b5..1b3d5fd3 100644
--- a/070table.mu
+++ b/070table.mu
@@ -51,15 +51,15 @@ def put-index table:&:table:_key:_value, key:_key, value:_value -> table:&:table
   hash:num <- hash key
   hash <- abs hash
   capacity:num <- get *table, capacity:offset
-  _, hash <- divide-with-remainder hash, capacity
-  hash <- abs hash  # in case hash overflows into a negative integer
+  _, hash-key:num <- divide-with-remainder hash, capacity
+  hash-key <- abs hash-key  # in case hash-key overflows into a negative integer
   table-data:&:@:table-row:_key:_value <- get *table, data:offset
-  x:table-row:_key:_value <- index *table-data, hash
+  x:table-row:_key:_value <- index *table-data, hash-key
   occupied?:bool <- get x, occupied?:offset
   not-occupied?:bool <- not occupied?:bool
   assert not-occupied?, [can't handle collisions yet]
   new-row:table-row:_key:_value <- merge 1/true, key, value
-  *table-data <- put-index *table-data, hash, new-row
+  *table-data <- put-index *table-data, hash-key, new-row
 ]
 
 def abs n:num -> result:num [
@@ -76,10 +76,10 @@ def index table:&:table:_key:_value, key:_key -> result:_value [
   hash:num <- hash key
   hash <- abs hash
   capacity:num <- get *table, capacity:offset
-  _, hash <- divide-with-remainder hash, capacity
-  hash <- abs hash  # in case hash overflows into a negative integer
+  _, hash-key:num <- divide-with-remainder hash, capacity
+  hash-key <- abs hash-key  # in case hash-key overflows into a negative integer
   table-data:&:@:table-row:_key:_value <- get *table, data:offset
-  x:table-row:_key:_value <- index *table-data, hash
+  x:table-row:_key:_value <- index *table-data, hash-key
   occupied?:bool <- get x, occupied?:offset
   assert occupied?, [can't handle missing elements yet]
   result <- get x, value:offset