Skip to content

Commit cf71b75

Browse files
made dicts simpler, are considerably faster now
1 parent bece586 commit cf71b75

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

dict.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,14 @@ limo_dict_item *dict_get_place(limo_data *dict, limo_data *key)
159159
unsigned int h = hash(key);
160160
unsigned int perturb = h;
161161
limo_dict *d = dict->d_dict;
162-
#define PERTURB_SHIFT 5;
163-
164-
while (1) {
165-
i = ((i<<2) + i + perturb + 1) % d->size; // 5i + 1 (perturb gets eventually zero)
166162

163+
i=h & (d->size -1);
164+
while (1) {
167165
if (d->store[i].cons == NULL ||
168166
limo_equals(key, CAR(d->store[i].cons)))
169167
return &d->store[i]; // WILL be found!
170168

171-
perturb >>= PERTURB_SHIFT;
169+
i = (i+1) & (d->size -1);
172170
}
173171

174172
limo_error("dict_get_place(): this should not happen!");

examples/mandelbrot.limo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@
5454
([_sdl . sdl-flip] *surface*)))
5555

5656
(main)
57-
(print "press RET to quit\n")
58-
(file-getc stdin)
57+
;; (print "press RET to quit\n")
58+
;; (file-getc stdin)

inlined.mods

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#file
2-
#string_builtins
3-
#ncurses
1+
file
2+
string_builtins
3+
ncurses
44

55
###########
66
# windows

0 commit comments

Comments
 (0)