Commit 1bebf267 authored by Tim Peters's avatar Tim Peters

multiunion(): Not entirely sure, but I believe this function has to do

a persistence dance on the buckets/sets it handles directly by itself.
If so, a similar but different change is also needed on the Zope3 branch.
parent 33443390
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
Set operations Set operations
****************************************************************************/ ****************************************************************************/
#define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.19 2002/06/03 17:45:08 tim_one Exp $\n" #define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.20 2002/06/05 16:03:11 tim_one Exp $\n"
#ifdef INTSET_H #ifdef INTSET_H
static int static int
...@@ -459,20 +459,28 @@ multiunion_m(PyObject *ignored, PyObject *args) ...@@ -459,20 +459,28 @@ multiunion_m(PyObject *ignored, PyObject *args)
/* If set is a bucket, do a straight resize + memcpy. */ /* If set is a bucket, do a straight resize + memcpy. */
if (set->ob_type == (PyTypeObject*)&SetType || if (set->ob_type == (PyTypeObject*)&SetType ||
set->ob_type == (PyTypeObject*)&BucketType) { set->ob_type == (PyTypeObject*)&BucketType) {
int setsize;
int size_desired;
const int setsize = SIZED(set)->len; UNLESS (PER_USE(set)) goto Error;
int size_desired = result->len + setsize; setsize = SIZED(set)->len;
size_desired = result->len + setsize;
/* If there are more to come, overallocate by 25% (arbitrary). */ /* If there are more to come, overallocate by 25% (arbitrary). */
if (i < n-1) if (i < n-1)
size_desired += size_desired >> 2; size_desired += size_desired >> 2;
if (size_desired && size_desired > result->size) { 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(set);
PER_ACCESSED(set);
goto Error; goto Error;
}
} }
memcpy(result->keys + result->len, memcpy(result->keys + result->len,
BUCKET(set)->keys, BUCKET(set)->keys,
setsize * sizeof(KEY_TYPE)); setsize * sizeof(KEY_TYPE));
result->len += setsize; result->len += setsize;
PER_ALLOW_DEACTIVATION(set);
PER_ACCESSED(set);
} }
else { else {
/* No cheap way: iterate over set's elements one at a time. */ /* No cheap way: iterate over set's elements one at a time. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment