[Zodb-checkins] CVS: Zope/lib/python/BTrees - BTreeTemplate.c:1.44

Tim Peters tim.one@comcast.net
Tue, 11 Jun 2002 14:52:16 -0400


Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv6420

Modified Files:
	BTreeTemplate.c 
Log Message:
_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.


=== Zope/lib/python/BTrees/BTreeTemplate.c 1.43 => 1.44 ===
 {
     int min, grew, copied=1, changed=0, bchanged=0;
+    int childlength;
     BTreeItem *d;
     KEY_TYPE key;
 
@@ -375,14 +376,21 @@
 
     /* A bucket changed size. */
     bchanged = 1;
+
+    UNLESS(PER_USE(d->child))
+        goto err;
+    childlength = d->child->len;
+    PER_ALLOW_DEACTIVATION(d->child);
+    PER_ACCESSED(d->child);
+
     if (value) {
-        /* A bucket got bigger. */
+        /* A bucket got bigger -- if it's "too big", split it. */
         int toobig;
 
         if (SameType_Check(self, d->child))
-            toobig = BTREE(d->child)->len > MAX_BTREE_SIZE(d->child);
+            toobig = childlength > MAX_BTREE_SIZE(d->child);
         else
-            toobig = BUCKET(d->child)->len > MAX_BUCKET_SIZE(d->child);
+            toobig = childlength > MAX_BUCKET_SIZE(d->child);
 
         if (toobig) {
             if (BTree_grow(self, min, noval) < 0)
@@ -400,7 +408,7 @@
             goto err;
         grew = 1; /* Reset flag, since we handled it */
     }
-    if (d->child->len > 0)
+    if (childlength > 0)
         goto Done;
 
     /* The child became empty. */