summaryrefslogtreecommitdiff
path: root/box/map.tnsl
diff options
context:
space:
mode:
authorKai Gunger <kgunger12@gmail.com>2026-11-15 18:44:38 -0500
committerKai Gunger <kgunger12@gmail.com>2026-11-15 18:44:38 -0500
commitbcc923602fbbcb50a35e7870aec6b26c96175c10 (patch)
tree60594e99af3f29eb2bd7d8f19eacc7bab2c71849 /box/map.tnsl
parent3e09a6ae3aea3b90961e4216339368775ea7c842 (diff)
fixes to map
Diffstat (limited to 'box/map.tnsl')
-rw-r--r--box/map.tnsl24
1 files changed, 9 insertions, 15 deletions
diff --git a/box/map.tnsl b/box/map.tnsl
index 43d52a3..71b3263 100644
--- a/box/map.tnsl
+++ b/box/map.tnsl
@@ -58,16 +58,13 @@ uint MAP_MAX_GROW = 4096
uint old_size = self.size
self.count = 0
- /; if (self.size < MAP_MAX_GROW / 2)
- self.size = old_size * 2
- ;; else
- self.size = old_size + MAP_MAX_GROW
- ;/
+ self.size = old_size * 2
self._alloc()
/; loop (int i = 0; i < old_size) [i++]
MapNode to_copy = old_list{i}
/; if (to_copy.active)
+ self.count++
uint idx = self._index(to_copy.key)
self._under{idx} = to_copy
;; else if (to_copy.key !== null)
@@ -97,8 +94,8 @@ uint MAP_MAX_GROW = 4096
int first_free = -1
/; loop (int i = 0; i < self.size) [i++]
- uint try = h + (i + i * i) / 2
- try = try % self.size
+ uint try = (i + i * i) / 2
+ try = (h + try) % self.size
MapNode node = self._under{try}
@@ -109,10 +106,8 @@ uint MAP_MAX_GROW = 4096
return first_free
;; else if (node.deleted() == true && first_free < 0)
first_free = try
- ;; else if (node.key !== null)
- /; if (text.cstr.eq(node.key, key))
- return try
- ;/
+ ;; else if (text.cstr.eq(node.key, key))
+ return try
;/
;/
@@ -157,14 +152,13 @@ uint MAP_MAX_GROW = 4096
/; del (~uint8 key)
uint idx = self._index(key)
- MapNode n = self._under{idx}
+ ~MapNode n = ~self._under{idx}
- /; if (n.active == true)
+ /; if (n`.active == false)
return
;/
- n.active = false
- self._under{idx} = n
+ n`.active = false
self.count--
;/