[Zope-Checkins] CVS: ZODB3/Persistence - cPersistence.c:1.72.8.25 cPickleCache.c:1.85.8.13
Tim Peters
tim.one@comcast.net
Wed, 9 Jul 2003 16:39:51 -0400
Update of /cvs-repository/ZODB3/Persistence
In directory cvs.zope.org:/tmp/cvs-serv20794/Persistence
Modified Files:
Tag: zodb33-devel-branch
cPersistence.c cPickleCache.c
Log Message:
More struct member renaming; more whitespace trimming.
=== ZODB3/Persistence/cPersistence.c 1.72.8.24 => 1.72.8.25 ===
--- ZODB3/Persistence/cPersistence.c:1.72.8.24 Wed Jul 9 15:38:13 2003
+++ ZODB3/Persistence/cPersistence.c Wed Jul 9 16:39:46 2003
@@ -107,7 +107,7 @@
accessed(cPersistentObject *self)
{
/* Do nothing unless the object is in a cache and not a ghost. */
- if (self->cache && self->state >= 0 && self->ring.next)
+ if (self->cache && self->state >= 0 && self->ring.r_next)
ring_move_to_head(&self->cache->ring_home, &self->ring);
}
@@ -117,7 +117,7 @@
/* If the cache has been cleared, then a non-ghost object
isn't in the ring any longer.
*/
- if (self->ring.next == NULL)
+ if (self->ring.r_next == NULL)
return;
/* if we're ghostifying an object, we better have some non-ghosts */
@@ -142,7 +142,7 @@
}
/* If the cache is still active, we must unlink the object. */
- if (self->ring.next) {
+ if (self->ring.r_next) {
/* if we're ghostifying an object, we better have some non-ghosts */
assert(self->cache->non_ghost_count > 0);
self->cache->non_ghost_count--;
=== ZODB3/Persistence/cPickleCache.c 1.85.8.12 => 1.85.8.13 ===
--- ZODB3/Persistence/cPickleCache.c:1.85.8.12 Wed Jul 9 16:34:43 2003
+++ ZODB3/Persistence/cPickleCache.c Wed Jul 9 16:39:46 2003
@@ -151,7 +151,7 @@
cPersistentObject *object;
int error;
CPersistentRing placeholder;
- CPersistentRing *here = self->ring_home.next;
+ CPersistentRing *here = self->ring_home.r_next;
/* Scan through the ring until we either find the ring_home (i.e. start
* of the ring, or we've ghosted enough objects to reach the target
@@ -159,7 +159,7 @@
*/
while (1) {
/* back to the home position. stop looking */
- if (here == &self->ring_home)
+ if (here == &self->ring_home)
return 0;
/* At this point we know that the ring only contains nodes
@@ -168,7 +168,7 @@
the current ring node is a persistent object now we know it
is not the home */
object = OBJECT_FROM_RING(self, here, "scan_gc_items");
- if (!object)
+ if (!object)
return -1;
/* we are small enough */
@@ -187,13 +187,13 @@
head of the list.
*/
- placeholder.next = here->r_next;
+ placeholder.r_next = here->r_next;
placeholder.r_prev = here;
here->r_next->r_prev = &placeholder;
here->r_next = &placeholder;
/* In Python, "obj._p_changed = None" spells, ghostify */
- error = PyObject_SetAttr((PyObject *)object, py__p_changed,
+ error = PyObject_SetAttr((PyObject *)object, py__p_changed,
Py_None);
/* unlink the placeholder */
@@ -202,10 +202,10 @@
here = placeholder.r_next;
- if (error)
+ if (error)
return -1; /* problem */
}
- else
+ else
here = here->r_next;
}
}
@@ -244,13 +244,13 @@
/* This cache will gradually drain down to a small size. Check
a (small) number of objects proportional to the current size */
- int target_size_2 = (starting_size - 1
+ int target_size_2 = (starting_size - 1
- starting_size / self->cache_drain_resistance);
if (target_size_2 < target_size)
target_size = target_size_2;
}
- if (!PyArg_ParseTuple(args, "|i:incrgc", &n))
+ if (!PyArg_ParseTuple(args, "|i:incrgc", &n))
return NULL;
return lockgc(self, target_size);
@@ -260,7 +260,7 @@
cc_full_sweep(ccobject *self, PyObject *args)
{
int dt = 0;
- if (!PyArg_ParseTuple(args, "|i:full_sweep", &dt))
+ if (!PyArg_ParseTuple(args, "|i:full_sweep", &dt))
return NULL;
if (dt == 0)
return lockgc(self, 0);
@@ -272,7 +272,7 @@
cc_minimize(ccobject *self, PyObject *args)
{
int ignored;
- if (!PyArg_ParseTuple(args, "|i:minimize", &ignored))
+ if (!PyArg_ParseTuple(args, "|i:minimize", &ignored))
return NULL;
return lockgc(self, 0);
}
@@ -292,9 +292,9 @@
}
else {
v = PyObject_CallFunction(self->setklassstate, "O", v);
- if (v)
+ if (v)
Py_DECREF(v);
- else
+ else
PyErr_Clear();
}
} else {
@@ -319,7 +319,7 @@
_invalidate(self, inv);
else {
int l;
-
+
l = PyObject_Length(inv);
if (l < 0)
return NULL;
@@ -334,17 +334,17 @@
PySequence_DelSlice(inv, 0, l);
}
}
-
+
Py_INCREF(Py_None);
return Py_None;
}
-
+
static PyObject *
cc_get(ccobject *self, PyObject *args)
{
PyObject *r, *key, *d = NULL;
- if (!PyArg_ParseTuple(args, "O|O:get", &key, &d))
+ if (!PyArg_ParseTuple(args, "O|O:get", &key, &d))
return NULL;
r = PyDict_GetItem(self->data, key);
@@ -373,7 +373,7 @@
int p = 0;
l = PyList_New(PyDict_Size(self->data));
- if (l == NULL)
+ if (l == NULL)
return NULL;
while (PyDict_Next(self->data, &p, &k, &v)) {
@@ -411,10 +411,10 @@
}
l = PyList_New(0);
- if (l == NULL)
+ if (l == NULL)
return NULL;
- here = self->ring_home.next;
+ here = self->ring_home.r_next;
while (here != &self->ring_home) {
PyObject *v;
cPersistentObject *object = OBJECT_FROM_RING(self, here, "cc_items");
@@ -460,7 +460,7 @@
assert(v);
assert(v->ob_refcnt == 0);
/* Need to be very hairy here because a dictionary is about
- to decref an already deleted object.
+ to decref an already deleted object.
*/
#ifdef Py_TRACE_REFS
@@ -468,7 +468,7 @@
interpreter has untracked the reference. Track it again.
*/
_Py_NewReference(v);
- /* Don't increment total refcount as a result of the
+ /* Don't increment total refcount as a result of the
shenanigans played in this function. The _Py_NewReference()
call above creates artificial references to v.
*/
@@ -485,7 +485,7 @@
Py_INCREF(v);
/* XXX Should we call _Py_ForgetReference() on error exit? */
- if (PyDict_DelItem(self->data, oid) < 0)
+ if (PyDict_DelItem(self->data, oid) < 0)
return;
Py_DECREF((ccobject *)((cPersistentObject *)v)->cache);
((cPersistentObject *)v)->cache = NULL;
@@ -506,7 +506,7 @@
CPersistentRing *here;
int c = 0;
- for (here = self->ring_home.next; here != &self->ring_home;
+ for (here = self->ring_home.r_next; here != &self->ring_home;
here = here->r_next)
c++;
return PyInt_FromLong(c);
@@ -571,15 +571,15 @@
Py_DECREF(self);
return -1;
}
- self->jar = jar;
+ self->jar = jar;
Py_INCREF(jar);
self->cache_size = cache_size;
self->non_ghost_count = 0;
self->klass_count = 0;
self->cache_drain_resistance = 0;
self->ring_lock = 0;
- self->ring_home.next = &self->ring_home;
- self->ring_home.prev = &self->ring_home;
+ self->ring_home.r_next = &self->ring_home;
+ self->ring_home.r_prev = &self->ring_home;
return 0;
}
@@ -598,7 +598,7 @@
int pos = 0;
PyObject *k, *v;
/* Clearing the cache is delicate.
-
+
A non-ghost object will show up in the ring and in the dict. If
we deallocating the dict before clearing the ring, the GC will
decref each object in the dict. Since the dict references are
@@ -614,20 +614,20 @@
It should be impossible for anyone to be modifying the cache.
*/
- while (self->ring_home.next != &self->ring_home) {
- CPersistentRing *here = self->ring_home.next;
+ while (self->ring_home.r_next != &self->ring_home) {
+ CPersistentRing *here = self->ring_home.r_next;
cPersistentObject *o = OBJECT_FROM_RING(self, here, "cc_clear");
-
+
if (o->cache) {
Py_INCREF(o); /* account for uncounted reference */
- if (PyDict_DelItem(self->data, o->oid) < 0)
+ if (PyDict_DelItem(self->data, o->oid) < 0)
return -1;
}
o->cache = NULL;
Py_DECREF(self);
- self->ring_home.next = here->r_next;
- o->ring.prev = NULL;
- o->ring.next = NULL;
+ self->ring_home.r_next = here->r_next;
+ o->ring.r_prev = NULL;
+ o->ring.r_next = NULL;
Py_DECREF(o);
here = here->r_next;
}
@@ -659,11 +659,11 @@
if (err) \
return err; \
}
-
+
VISIT(self->jar);
VISIT(self->setklassstate);
- here = self->ring_home.next;
+ here = self->ring_home.r_next;
/* It is possible that an object is traversed after it is cleared.
In that case, there is no ring.
@@ -677,7 +677,7 @@
here = here->r_next;
}
#undef VISIT
-
+
return 0;
}
@@ -686,7 +686,7 @@
{
return PyObject_Length(self->data);
}
-
+
static PyObject *
cc_subscript(ccobject *self, PyObject *key)
{
@@ -719,7 +719,7 @@
XXX Need a better test.
*/
- PyErr_SetString(PyExc_TypeError,
+ PyErr_SetString(PyExc_TypeError,
"Cache values must be persistent objects.");
return -1;
}
@@ -743,7 +743,7 @@
if (PyErr_Occurred()) {
Py_DECREF(oid);
return -1;
- }
+ }
Py_DECREF(oid);
if (result) {
PyErr_SetString(PyExc_ValueError, "Cache key does not match oid");
@@ -775,7 +775,7 @@
}
if (PyType_Check(v)) {
- if (PyDict_SetItem(self->data, key, v) < 0)
+ if (PyDict_SetItem(self->data, key, v) < 0)
return -1;
self->klass_count++;
return 0;
@@ -784,28 +784,28 @@
if (cache) {
if (cache != (PerCache *)self)
/* This object is already in a different cache. */
- PyErr_SetString(PyExc_ValueError,
+ PyErr_SetString(PyExc_ValueError,
"Cache values may only be in one cache.");
return -1;
- }
+ }
/* else:
-
+
This object is already one of ours, which is ok. It
would be very strange if someone was trying to register
- the same object under a different key.
+ the same object under a different key.
*/
}
-
- if (PyDict_SetItem(self->data, key, v) < 0)
+
+ if (PyDict_SetItem(self->data, key, v) < 0)
return -1;
/* the dict should have a borrowed reference */
Py_DECREF(v);
-
+
p = (cPersistentObject *)v;
Py_INCREF(self);
p->cache = (PerCache *)self;
if (p->state >= 0) {
- /* insert this non-ghost object into the ring just
+ /* insert this non-ghost object into the ring just
behind the home position. */
self->non_ghost_count++;
ring_add(&self->ring_home, &p->ring);
@@ -892,7 +892,7 @@
static PyMemberDef cc_members[] = {
{"cache_size", T_INT, offsetof(ccobject, cache_size)},
- {"cache_drain_resistance", T_INT,
+ {"cache_drain_resistance", T_INT,
offsetof(ccobject, cache_drain_resistance)},
{"cache_non_ghost_count", T_INT, offsetof(ccobject, non_ghost_count), RO},
{"cache_klass_count", T_INT, offsetof(ccobject, klass_count), RO},