Mercurial > cpython-lru_cache-weakref
diff Objects/mappingobject.c @ 3836:fa1480e60ed6 legacy-trunk
Speedup suggested by Sjoerd
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 30 Jul 1996 16:45:31 +0000 |
| parents | e38c09d00806 |
| children | 9c2cbf306864 |
line wrap: on
line diff
--- a/Objects/mappingobject.c Tue Jul 30 16:43:44 1996 +0000 +++ b/Objects/mappingobject.c Tue Jul 30 16:45:31 1996 +0000 @@ -129,12 +129,13 @@ 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 @@ cmpobject(ep->me_key, key) == 0) { return ep; } - i = (i + incr) % mp->ma_size; + i = (i + incr) % size; } }
