[Zope-Checkins] CVS: Zope3/lib/python/Persistence/BTrees - SetOpTemplate.c:1.1.2.7
Tim Peters
tim.one@comcast.net
Wed, 5 Jun 2002 14:38:50 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv1092
Modified Files:
Tag: Zope-3x-branch
SetOpTemplate.c
Log Message:
multiunion(): Do a persistence dance when handling a bucket/set entirely
inline.
=== Zope3/lib/python/Persistence/BTrees/SetOpTemplate.c 1.1.2.6 => 1.1.2.7 ===
if (set->ob_type == (PyTypeObject*)&SetType ||
set->ob_type == (PyTypeObject*)&BucketType) {
+ int setsize;
+ int size_desired;
- const int setsize = SIZED(set)->len;
- int size_desired = result->len + setsize;
+ UNLESS (PER_USE(set)) goto Error;
+ setsize = SIZED(set)->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)
+ if (Bucket_grow(result, size_desired, 1) < 0) {
+ PER_ALLOW_DEACTIVATION(SIZED(set));
+ PER_ACCESSED(set);
goto Error;
+ }
}
memcpy(result->keys + result->len,
BUCKET(set)->keys,
setsize * sizeof(KEY_TYPE));
result->len += setsize;
+ PER_ALLOW_DEACTIVATION(SIZED(set));
+ PER_ACCESSED(set);
}
else {
/* No cheap way: iterate over set's elements one at a time. */
@@ -521,5 +529,4 @@
Py_XDECREF(setiter.set);
return NULL;
}
-
#endif