/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/_chk_map_pyx.pyx

  • Committer: John Arbash Meinel
  • Date: 2009-10-20 22:13:23 UTC
  • mto: This revision was merged to the branch mainline in revision 4771.
  • Revision ID: john@arbash-meinel.com-20091020221323-vvukgazqxkicb70n
A bit broken, but getting there.

Start being much stricter about requiring StaticTuples everywhere.
I may go back and loosen this restriction, but getting the code base
StaticTuple pure is probably a good idea. The main reason to be 'looser'
is so that things don't fail 'in the wild' just because someone
calls an api with a tuple rather than a StaticTuple.
However, I'd like the internals to be 'pure' if possible.
We'll see.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
    cdef char *c_out
104
104
    # cdef PyObject *bit
105
105
 
106
 
    if not PyTuple_CheckExact(key) and not StaticTuple_CheckExact(key):
107
 
        raise TypeError('key %r is not a tuple' % (key,))
 
106
    if not StaticTuple_CheckExact(key):
 
107
        raise TypeError('key %r is not a StaticTuple' % (key,))
108
108
    num_bits = len(key)
109
109
    # 4 bytes per crc32, and another 1 byte between bits
110
110
    num_out_bytes = (9 * num_bits) - 1
143
143
    cdef char *c_out
144
144
    # cdef PyObject *bit
145
145
 
146
 
    if not PyTuple_CheckExact(key) and not StaticTuple_CheckExact(key):
147
 
        raise TypeError('key %r is not a tuple' % (key,))
 
146
    if not StaticTuple_CheckExact(key):
 
147
        raise TypeError('key %r is not a StaticTuple' % (key,))
148
148
    num_bits = len(key)
149
149
    # 4 bytes per crc32, and another 1 byte between bits
150
150
    num_out_bytes = (5 * num_bits) - 1
282
282
            cur = next_line + 1
283
283
        entry_bits = StaticTuple_New(width)
284
284
        for i from 0 <= i < num_prefix_bits:
 
285
            # TODO: Use PyList_GetItem, or turn prefix_bits into a
 
286
            #       tuple/StaticTuple
285
287
            entry = prefix_bits[i]
286
288
            # SET_ITEM 'steals' a reference
287
289
            Py_INCREF(entry)
359
361
        _unknown = chk_map._unknown
360
362
    result = _InternalNode(search_key_func=search_key_func)
361
363
 
 
364
    if not StaticTuple_CheckExact(key):
 
365
        raise TypeError('key %r is not a StaticTuple' % (key,))
362
366
    if not PyString_CheckExact(bytes):
363
367
        raise TypeError('bytes must be a plain string not %s' % (type(bytes),))
364
368
 
415
419
    result._node_width = len(item_prefix)
416
420
    result._search_prefix = PyString_FromStringAndSize(prefix, prefix_length)
417
421
    return result
418
 
 
419
 
 
420
 
_key_type = StaticTuple