~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_btree_serializer_pyx.pyx

  • Committer: John Arbash Meinel
  • Date: 2009-10-08 15:51:34 UTC
  • mfrom: (4679.7.1 2.1-static-tuple-btree)
  • mto: This revision was merged to the branch mainline in revision 4749.
  • Revision ID: john@arbash-meinel.com-20091008155134-2in91irsp62rcgei
Merge in the 2.1-static-tuple-btree branch, and restore the string intern tweaks.

The tweaks basically involve not interning 'sha1:' chk strings, which we can
be reasonably confident are only accessed as tuples, and thus get interned
into the more efficient SimpleSet. Even further, we know that we won't be
combining them into larger tuples [like we do with (file_id, revision_id)].
This saves quite a bit of space in the string interned dict, since chk
keys actually make up the bulk of our keys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
    return result
105
105
 
106
106
from bzrlib import _static_tuple_c
107
 
cdef object _ST
108
 
_ST = _static_tuple_c.StaticTuple
109
107
# This sets up the StaticTuple C_API functionality
110
108
import_static_tuple_c()
111
109
 
159
157
        cdef char *temp_ptr
160
158
        cdef int loop_counter
161
159
        cdef StaticTuple key
162
 
        
 
160
 
163
161
        key = StaticTuple_New(self.key_length)
164
162
        for loop_counter from 0 <= loop_counter < self.key_length:
165
163
            # grab a key segment
175
173
                                                   last - self._start)))
176
174
                    raise AssertionError(failure_string)
177
175
            # capture the key string
178
 
            if (self.key_length == 1 
 
176
            if (self.key_length == 1
179
177
                and (temp_ptr - self._start) == 45
180
178
                and strncmp(self._start, 'sha1:', 5) == 0):
181
179
                key_element = safe_string_from_size(self._start,
283
281
                    if temp_ptr == NULL:
284
282
                        # key runs to the end
285
283
                        temp_ptr = ref_ptr
286
 
                                        
 
284
 
287
285
                    PyList_Append(ref_list, self.extract_key(temp_ptr))
288
286
                ref_list = StaticTuple_Intern(StaticTuple(*ref_list))
289
287
                Py_INCREF(ref_list)