summaryrefslogtreecommitdiffstats
path: root/Modules/gcmodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-06-30 21:31:03 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-06-30 21:31:03 (GMT)
commit93cd83e4aed7b926cb04d1b656b094973ae3552b (patch)
tree646682c26673ec0cca1b55a877341f92c56033d9 /Modules/gcmodule.c
parent8839617cc9f026f349f7f371025131f224271b9f (diff)
downloadcpython-93cd83e4aed7b926cb04d1b656b094973ae3552b.zip
cpython-93cd83e4aed7b926cb04d1b656b094973ae3552b.tar.gz
cpython-93cd83e4aed7b926cb04d1b656b094973ae3552b.tar.bz2
visit_decref(): Two optimizations.
1. You're not supposed to call this with a NULL argument, although the docs could be clearer about that. The other visit_XYZ() functions don't bother to check. This doesn't either now, although it does assert non-NULL-ness now. 2. It doesn't matter whether the object is currently tracked, so don't bother checking that either (if it isn't currently tracked, it may have some nonsense value in gc_refs, but it doesn't hurt to decrement gibberish, and it's cheaper to do so than to make everyone test for trackedness). It would be nice to get rid of the other tests on IS_TRACKED. Perhaps trackedness should not be a matter of not being in any gc list, but should be a matter of being in a new "untracked" gc list. This list simply wouldn't be involved in the collection mechanism. A newly created object would be put in the untracked list. Tracking would simply unlink it and move it into the gen0 list. Untracking would do the reverse. No test+branch needed then. visit_move() may be vulnerable then, though, and I don't know how this would work with the trashcan.
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r--Modules/gcmodule.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index b3a688c..29d62bf 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -196,11 +196,9 @@ visit_decref(PyObject *op, void *data)
* getting collected. That would be a waste of time, but wouldn't
* cause an error.
*/
- if (op && PyObject_IS_GC(op)) {
- if (IS_TRACKED(op)) {
- AS_GC(op)->gc.gc_refs--;
- }
- }
+ assert(op != NULL);
+ if (PyObject_IS_GC(op))
+ AS_GC(op)->gc.gc_refs--;
return 0;
}