Rev 2485: Avoid a Py_INCREF by using a void * in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex
John Arbash Meinel
john at arbash-meinel.com
Fri May 4 05:47:28 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex
------------------------------------------------------------
revno: 2485
revision-id: john at arbash-meinel.com-20070504044714-xgbrxg27p83yis89
parent: john at arbash-meinel.com-20070504043751-5unx865kqw9scyyu
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_pyrex
timestamp: Thu 2007-05-03 23:47:14 -0500
message:
Avoid a Py_INCREF by using a void *
modified:
bzrlib/compiled/dirstate_helpers.pyx dirstate_helpers.pyx-20070503201057-u425eni465q4idwn-3
-------------- next part --------------
=== modified file 'bzrlib/compiled/dirstate_helpers.pyx'
--- a/bzrlib/compiled/dirstate_helpers.pyx 2007-05-04 04:37:51 +0000
+++ b/bzrlib/compiled/dirstate_helpers.pyx 2007-05-04 04:47:14 +0000
@@ -26,8 +26,8 @@
# GetItem returns a borrowed reference
void *PyDict_GetItem(object p, object key)
int PyDict_SetItem(object p, object key, object val) except -1
- object PyList_GetItem(object lst, int index)
- object PyTuple_GetItem(object tpl, int index)
+ void *PyList_GetItem_void "PyList_GET_ITEM" (object lst, int index)
+ object PyTuple_GetItem_object "PyTuple_GET_ITEM" (void* tpl, int index)
int PyList_CheckExact(object)
int PyTuple_CheckExact(object)
@@ -72,7 +72,8 @@
cdef int _mid
cdef object dirname_split
cdef object cur_split
- cdef object block
+ cdef void *block
+ cdef object cur
if hi is None:
_hi = len(dirblocks)
@@ -87,15 +88,11 @@
_mid = (_lo+_hi)/2
# Grab the dirname for the current dirblock
# block = dirblocks[_mid]
- block = PyList_GetItem(dirblocks, _mid)
- Py_INCREF(block) # PyList_GetItem doesn't increment the ref counter,
- # but pyrex assumes objects have proper reference
- # counts. We were trying to have block not care
- # but that doesn't seem possible
- if not PyTuple_CheckExact(block):
+ block = PyList_GetItem_void(dirblocks, _mid)
+ if not PyTuple_CheckExact(<object>block):
raise TypeError('We expect to have a list of tuples')
# cur = block[0]
- cur = PyTuple_GetItem(block, 0)
+ cur = PyTuple_GetItem_object(block, 0)
Py_INCREF(cur)
cur_split = cur.split('/')
if cur_split < dirname_split: _lo = _mid+1
More information about the bazaar-commits
mailing list