[Zope-Checkins] CVS: Zope/lib/python/BTrees - BucketTemplate.c:1.32 SetOpTemplate.c:1.21
Tim Peters
tim.one@comcast.net
Wed, 5 Jun 2002 15:26:56 -0400
Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv17800
Modified Files:
BucketTemplate.c SetOpTemplate.c
Log Message:
Repaired failure of SetOpTemplate.c to compile (sorry!).
Elsewhere, repaired all other known cases where uses of the
TEST_KEY_OR_SET macro did early exits without finishing persistence
dances (Jeremy confirmed that's a Bad Thing -- creates unghostifiable
cache hogs).
=== Zope/lib/python/BTrees/BucketTemplate.c 1.31 => 1.32 ===
for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2)
{
- TEST_KEY_SET_OR(cmp, self->keys[i], key) return NULL;
+ TEST_KEY_SET_OR(cmp, self->keys[i], key) goto err;
if (PyErr_Occurred()) goto err;
if (cmp < 0) min=i;
@@ -63,8 +63,11 @@
PER_ACCESSED(self);
if (has_key) return PyInt_FromLong(0);
PyErr_SetObject(PyExc_KeyError, keyarg);
+ return NULL;
err:
+ PER_ALLOW_DEACTIVATION(self);
+ PER_ACCESSED(self);
return NULL;
}
@@ -161,7 +164,7 @@
for (min=0, max=l=self->len, i=max/2; i != l; l=i, i=(min+max)/2)
{
- TEST_KEY_SET_OR(cmp, self->keys[i], key) return -1;
+ TEST_KEY_SET_OR(cmp, self->keys[i], key) goto err;
if (cmp < 0) min=i;
else if (cmp==0)
{
@@ -466,7 +469,7 @@
for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2)
{
- TEST_KEY_SET_OR(cmp, self->keys[i], key) return -1;
+ TEST_KEY_SET_OR(cmp, self->keys[i], key) goto err;
if (cmp < 0)
min=i;
else if (cmp == 0)
@@ -504,8 +507,12 @@
PER_ALLOW_DEACTIVATION(self);
PER_ACCESSED(self);
-
return i;
+
+err:
+ PER_ALLOW_DEACTIVATION(self);
+ PER_ACCESSED(self);
+ return -1;
}
static PyObject *
=== Zope/lib/python/BTrees/SetOpTemplate.c 1.20 => 1.21 ===
if (set->ob_type == (PyTypeObject*)&SetType ||
set->ob_type == (PyTypeObject*)&BucketType) {
+ Sized *theset = SIZED(set);
int setsize;
int size_desired;
- UNLESS (PER_USE(set)) goto Error;
- setsize = SIZED(set)->len;
+ UNLESS (PER_USE(theset)) goto Error;
+ setsize = theset->len;
size_desired = result->len + setsize;
/* If there are more to come, overallocate by 25% (arbitrary). */
if (i < n-1)
size_desired += size_desired >> 2;
if (size_desired && size_desired > result->size) {
if (Bucket_grow(result, size_desired, 1) < 0) {
- PER_ALLOW_DEACTIVATION(set);
- PER_ACCESSED(set);
+ PER_ALLOW_DEACTIVATION(theset);
+ PER_ACCESSED(theset);
goto Error;
}
}
memcpy(result->keys + result->len,
- BUCKET(set)->keys,
+ BUCKET(theset)->keys,
setsize * sizeof(KEY_TYPE));
result->len += setsize;
- PER_ALLOW_DEACTIVATION(set);
- PER_ACCESSED(set);
+ PER_ALLOW_DEACTIVATION(theset);
+ PER_ACCESSED(theset);
}
else {
/* No cheap way: iterate over set's elements one at a time. */