Rev 2502: Ask the field converter to determine the current directory in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex

John Arbash Meinel john at arbash-meinel.com
Fri May 4 21:00:27 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex

------------------------------------------------------------
revno: 2502
revision-id: john at arbash-meinel.com-20070504200015-yli1te8jfhk3xpjc
parent: john at arbash-meinel.com-20070504194612-ryl2chfi4dd53c2h
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_pyrex
timestamp: Fri 2007-05-04 15:00:15 -0500
message:
  Ask the field converter to determine the current directory
  rather than parsing it out of the returned entry.
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 19:46:12 +0000
+++ b/bzrlib/compiled/dirstate_helpers.pyx	2007-05-04 20:00:15 +0000
@@ -191,7 +191,8 @@
     return cur
 
 
-cdef object _fields_to_entry_0_parents(PyListObject *fields, int offset):
+cdef object _fields_to_entry_0_parents(PyListObject *fields, int offset,
+                                       void **dirname, char **dirname_str):
     cdef object path_name_file_id_key
     cdef char *size_str
     cdef unsigned long int size
@@ -199,6 +200,8 @@
     cdef int is_executable
     cdef PyObject **base
     base = fields.ob_item + offset
+    dirname[0] = base[0]
+    dirname_str[0] = PyString_AS_STRING_void(base[0])
     path_name_file_id_key = (<object>(base[0]),
                              <object>(base[1]),
                              <object>(base[2]),
@@ -228,9 +231,7 @@
     cdef object entry
     cdef void* dirname
     cdef char* dirname_str
-    cdef int dirname_size
     cdef char* current_dirname_str
-    cdef int current_dirname_size
 
     if not PyList_CheckExact(fields):
         raise TypeError('fields must be a list')
@@ -238,20 +239,15 @@
     state._dirblocks = [('', []), ('', [])]
     current_block = state._dirblocks[0][1]
     current_dirname_str = ''
-    current_dirname_size = 0
 
     while pos < field_count:
-        entry = _fields_to_entry_0_parents(<PyListObject *>fields, pos)
+        entry = _fields_to_entry_0_parents(<PyListObject *>fields, pos,
+                                           &dirname, &dirname_str)
         pos = pos + entry_size
-        dirname = PyTuple_GetItem_void_void(
-                    PyTuple_GetItem_void_void(<void*>entry, 0), 0)
-        dirname_str = PyString_AS_STRING_void(dirname)
-        dirname_size = PyString_GET_SIZE_void(dirname)
         if (strcmp(dirname_str, current_dirname_str) != 0):
             # new block - different dirname
             current_block = []
             current_dirname_str = dirname_str
-            current_dirname_size = dirname_size
             PyList_Append(state._dirblocks,
                           (<object>dirname, current_block))
         PyList_Append(current_block, entry)



More information about the bazaar-commits mailing list