summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c2
-rw-r--r--Objects/listobject.c6
-rw-r--r--Objects/mappingobject.c2
-rw-r--r--Objects/stringobject.c2
-rw-r--r--Objects/tupleobject.c8
5 files changed, 12 insertions, 8 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index d74e74f..11d344a 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -133,7 +133,7 @@ lookmapping(mp, key, hash)
and 0 < incr < ma_size and both are a function of hash */
i = sum % mp->ma_size;
do {
- sum = sum + sum + sum + 1;
+ sum = 3*sum + 1;
incr = sum % mp->ma_size;
} while (incr == 0);
for (;;) {
diff --git a/Objects/listobject.c b/Objects/listobject.c
index a367ed1..44003bc 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -120,6 +120,7 @@ setlistitem(op, i, newitem)
register object *newitem;
{
register object *olditem;
+ register object **p;
if (!is_listobject(op)) {
XDECREF(newitem);
err_badcall();
@@ -130,8 +131,9 @@ setlistitem(op, i, newitem)
err_setstr(IndexError, "list assignment index out of range");
return -1;
}
- olditem = ((listobject *)op) -> ob_item[i];
- ((listobject *)op) -> ob_item[i] = newitem;
+ p = ((listobject *)op) -> ob_item + i;
+ olditem = *p;
+ *p = newitem;
XDECREF(olditem);
return 0;
}
diff --git a/Objects/mappingobject.c b/Objects/mappingobject.c
index d74e74f..11d344a 100644
--- a/Objects/mappingobject.c
+++ b/Objects/mappingobject.c
@@ -133,7 +133,7 @@ lookmapping(mp, key, hash)
and 0 < incr < ma_size and both are a function of hash */
i = sum % mp->ma_size;
do {
- sum = sum + sum + sum + 1;
+ sum = 3*sum + 1;
incr = sum % mp->ma_size;
} while (incr == 0);
for (;;) {
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index cb76d77..b09fc25 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -419,7 +419,7 @@ string_hash(a)
p = (unsigned char *) a->ob_sval;
x = *p << 7;
while (--len >= 0)
- x = (x + x + x) ^ *p++;
+ x = (3*x) ^ *p++;
x ^= a->ob_size;
if (x == -1)
x = -2;
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 1e5ea13..69c4f95 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -119,9 +119,10 @@ int
settupleitem(op, i, newitem)
register object *op;
register int i;
- register object *newitem;
+ object *newitem;
{
register object *olditem;
+ register object **p;
if (!is_tupleobject(op)) {
XDECREF(newitem);
err_badcall();
@@ -132,8 +133,9 @@ settupleitem(op, i, newitem)
err_setstr(IndexError, "tuple assignment index out of range");
return -1;
}
- olditem = ((tupleobject *)op) -> ob_item[i];
- ((tupleobject *)op) -> ob_item[i] = newitem;
+ p = ((tupleobject *)op) -> ob_item + i;
+ olditem = *p;
+ *p = newitem;
XDECREF(olditem);
return 0;
}