Commit 9901f0b6 authored by Tim Peters's avatar Tim Peters

_BTree_set(): In three places, the length of a child node was accessed

directly without doing the unghostification dance.  Repaired to cache
the child length once in a local vrbl, bracketed by the right
persistence stuff.
parent c9d254d9
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
****************************************************************************/ ****************************************************************************/
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.43 2002/06/11 02:59:05 tim_one Exp $\n" #define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.44 2002/06/11 18:52:16 tim_one Exp $\n"
/* /*
** _BTree_get ** _BTree_get
...@@ -342,6 +342,7 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value, ...@@ -342,6 +342,7 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value,
int unique, int noval) int unique, int noval)
{ {
int min, grew, copied=1, changed=0, bchanged=0; int min, grew, copied=1, changed=0, bchanged=0;
int childlength;
BTreeItem *d; BTreeItem *d;
KEY_TYPE key; KEY_TYPE key;
...@@ -375,14 +376,21 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value, ...@@ -375,14 +376,21 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value,
/* A bucket changed size. */ /* A bucket changed size. */
bchanged = 1; bchanged = 1;
UNLESS(PER_USE(d->child))
goto err;
childlength = d->child->len;
PER_ALLOW_DEACTIVATION(d->child);
PER_ACCESSED(d->child);
if (value) { if (value) {
/* A bucket got bigger. */ /* A bucket got bigger -- if it's "too big", split it. */
int toobig; int toobig;
if (SameType_Check(self, d->child)) if (SameType_Check(self, d->child))
toobig = BTREE(d->child)->len > MAX_BTREE_SIZE(d->child); toobig = childlength > MAX_BTREE_SIZE(d->child);
else else
toobig = BUCKET(d->child)->len > MAX_BUCKET_SIZE(d->child); toobig = childlength > MAX_BUCKET_SIZE(d->child);
if (toobig) { if (toobig) {
if (BTree_grow(self, min, noval) < 0) if (BTree_grow(self, min, noval) < 0)
...@@ -400,7 +408,7 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value, ...@@ -400,7 +408,7 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value,
goto err; goto err;
grew = 1; /* Reset flag, since we handled it */ grew = 1; /* Reset flag, since we handled it */
} }
if (d->child->len > 0) if (childlength > 0)
goto Done; goto Done;
/* The child became empty. */ /* The child became empty. */
......
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