diff options
author | Guido van Rossum <guido@python.org> | 1996-07-30 16:45:31 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-07-30 16:45:31 (GMT) |
commit | 310968dc06e5f1631b38fc86ca46e61330e60cc5 (patch) | |
tree | f7181723d616b7c644bb974677792cc62885bee7 | |
parent | 14f44516a4ae60dd0e83a3ad27729af337fb725c (diff) | |
download | cpython-310968dc06e5f1631b38fc86ca46e61330e60cc5.zip cpython-310968dc06e5f1631b38fc86ca46e61330e60cc5.tar.gz cpython-310968dc06e5f1631b38fc86ca46e61330e60cc5.tar.bz2 |
Speedup suggested by Sjoerd
-rw-r--r-- | Objects/dictobject.c | 7 | ||||
-rw-r--r-- | Objects/mappingobject.c | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 42e68d8..f655828 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -129,12 +129,13 @@ lookmapping(mp, key, hash) register int i, incr; register unsigned long sum = (unsigned long) hash; register mappingentry *freeslot = NULL; + register int size = mp->ma_size; /* We must come up with (i, incr) such that 0 <= i < ma_size and 0 < incr < ma_size and both are a function of hash */ - i = sum % mp->ma_size; + i = sum % size; do { sum = 3*sum + 1; - incr = sum % mp->ma_size; + incr = sum % size; } while (incr == 0); for (;;) { register mappingentry *ep = &mp->ma_table[i]; @@ -152,7 +153,7 @@ lookmapping(mp, key, hash) cmpobject(ep->me_key, key) == 0) { return ep; } - i = (i + incr) % mp->ma_size; + i = (i + incr) % size; } } diff --git a/Objects/mappingobject.c b/Objects/mappingobject.c index 42e68d8..f655828 100644 --- a/Objects/mappingobject.c +++ b/Objects/mappingobject.c @@ -129,12 +129,13 @@ lookmapping(mp, key, hash) register int i, incr; register unsigned long sum = (unsigned long) hash; register mappingentry *freeslot = NULL; + register int size = mp->ma_size; /* We must come up with (i, incr) such that 0 <= i < ma_size and 0 < incr < ma_size and both are a function of hash */ - i = sum % mp->ma_size; + i = sum % size; do { sum = 3*sum + 1; - incr = sum % mp->ma_size; + incr = sum % size; } while (incr == 0); for (;;) { register mappingentry *ep = &mp->ma_table[i]; @@ -152,7 +153,7 @@ lookmapping(mp, key, hash) cmpobject(ep->me_key, key) == 0) { return ep; } - i = (i + incr) % mp->ma_size; + i = (i + incr) % size; } } |