Skip to content

Commit

Permalink
Add fill-count to count deleted members in hash-tables (fixes euslisp…
Browse files Browse the repository at this point in the history
  • Loading branch information
Affonso-Gui committed Mar 27, 2023
1 parent 3d04045 commit b1f5d40
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lisp/l/hashtab.l
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
((key :type vector)
(value :type vector)
(size :type :integer)
(fill-count :type :integer)
(count :type :integer)
(hash-function)
(test-function)
Expand Down Expand Up @@ -45,11 +46,13 @@
(:enter (sym val)
(let ((entry (send self :find sym)))
(when (>= entry size) ;new entry?
(when (> count (/ size rehash-size))
(when (> fill-count (/ size rehash-size))
(send self :extend)
(setq entry (send self :find sym)) )
(setq entry (- entry size))
(inc count)
(setq entry (- entry size)))
(if (eq (svref key entry) empty)
(inc fill-count)))
(svset key entry sym)
(svset value entry val)
val))
Expand All @@ -74,6 +77,7 @@
x size
size altsize
altsize x
fill-count 0
count 0)
(dotimes (i altsize)
(setq x (svref altkey i))
Expand Down Expand Up @@ -133,6 +137,7 @@
empty (gensym "EMPTY")
deleted (gensym "DEL")
not-found nofound
fill-count 0
count 0
rehash-size rehash)
(dotimes (i s) (svset key i empty))
Expand Down

0 comments on commit b1f5d40

Please sign in to comment.