1
/* Generated by Cython 0.14.1 on Mon Jan 16 15:59:41 2012 */
3
#define PY_SSIZE_T_CLEAN
6
#error Python headers needed to compile C extensions, please install development version of Python.
9
#include <stddef.h> /* For offsetof */
11
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
14
#if !defined(WIN32) && !defined(MS_WINDOWS)
27
#define DL_IMPORT(t) t
30
#define DL_EXPORT(t) t
34
#define PY_LONG_LONG LONG_LONG
37
#if PY_VERSION_HEX < 0x02040000
38
#define METH_COEXIST 0
39
#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
40
#define PyDict_Contains(d,o) PySequence_Contains(d,o)
43
#if PY_VERSION_HEX < 0x02050000
44
typedef int Py_ssize_t;
45
#define PY_SSIZE_T_MAX INT_MAX
46
#define PY_SSIZE_T_MIN INT_MIN
47
#define PY_FORMAT_SIZE_T ""
48
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
49
#define PyInt_AsSsize_t(o) PyInt_AsLong(o)
50
#define PyNumber_Index(o) PyNumber_Int(o)
51
#define PyIndex_Check(o) PyNumber_Check(o)
52
#define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
55
#if PY_VERSION_HEX < 0x02060000
56
#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
57
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
58
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
59
#define PyVarObject_HEAD_INIT(type, size) \
60
PyObject_HEAD_INIT(type) size,
61
#define PyType_Modified(t)
73
Py_ssize_t *suboffsets;
77
#define PyBUF_SIMPLE 0
78
#define PyBUF_WRITABLE 0x0001
79
#define PyBUF_FORMAT 0x0004
80
#define PyBUF_ND 0x0008
81
#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
82
#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
83
#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
84
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
85
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
89
#if PY_MAJOR_VERSION < 3
90
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
92
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
95
#if PY_MAJOR_VERSION >= 3
96
#define Py_TPFLAGS_CHECKTYPES 0
97
#define Py_TPFLAGS_HAVE_INDEX 0
100
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
101
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
104
#if PY_MAJOR_VERSION >= 3
105
#define PyBaseString_Type PyUnicode_Type
106
#define PyStringObject PyUnicodeObject
107
#define PyString_Type PyUnicode_Type
108
#define PyString_Check PyUnicode_Check
109
#define PyString_CheckExact PyUnicode_CheckExact
112
#if PY_VERSION_HEX < 0x02060000
113
#define PyBytesObject PyStringObject
114
#define PyBytes_Type PyString_Type
115
#define PyBytes_Check PyString_Check
116
#define PyBytes_CheckExact PyString_CheckExact
117
#define PyBytes_FromString PyString_FromString
118
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
119
#define PyBytes_FromFormat PyString_FromFormat
120
#define PyBytes_DecodeEscape PyString_DecodeEscape
121
#define PyBytes_AsString PyString_AsString
122
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
123
#define PyBytes_Size PyString_Size
124
#define PyBytes_AS_STRING PyString_AS_STRING
125
#define PyBytes_GET_SIZE PyString_GET_SIZE
126
#define PyBytes_Repr PyString_Repr
127
#define PyBytes_Concat PyString_Concat
128
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
131
#if PY_VERSION_HEX < 0x02060000
132
#define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
133
#define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
135
#ifndef PySet_CheckExact
136
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
139
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
141
#if PY_MAJOR_VERSION >= 3
142
#define PyIntObject PyLongObject
143
#define PyInt_Type PyLong_Type
144
#define PyInt_Check(op) PyLong_Check(op)
145
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
146
#define PyInt_FromString PyLong_FromString
147
#define PyInt_FromUnicode PyLong_FromUnicode
148
#define PyInt_FromLong PyLong_FromLong
149
#define PyInt_FromSize_t PyLong_FromSize_t
150
#define PyInt_FromSsize_t PyLong_FromSsize_t
151
#define PyInt_AsLong PyLong_AsLong
152
#define PyInt_AS_LONG PyLong_AS_LONG
153
#define PyInt_AsSsize_t PyLong_AsSsize_t
154
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
155
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
158
#if PY_MAJOR_VERSION >= 3
159
#define PyBoolObject PyLongObject
163
#if PY_MAJOR_VERSION >= 3
164
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
165
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
167
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
168
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
171
#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
172
#define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
173
#define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
174
#define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
176
#define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
177
(PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
178
(likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
179
(PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
180
#define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
181
(PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
182
(likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
183
(PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
184
#define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
185
(PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
186
(likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
187
(PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
190
#if PY_MAJOR_VERSION >= 3
191
#define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
194
#if PY_VERSION_HEX < 0x02050000
195
#define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
196
#define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
197
#define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
199
#define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
200
#define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
201
#define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
204
#if PY_VERSION_HEX < 0x02050000
205
#define __Pyx_NAMESTR(n) ((char *)(n))
206
#define __Pyx_DOCSTR(n) ((char *)(n))
208
#define __Pyx_NAMESTR(n) (n)
209
#define __Pyx_DOCSTR(n) (n)
213
#define __PYX_EXTERN_C extern "C"
215
#define __PYX_EXTERN_C extern
218
#if defined(WIN32) || defined(MS_WINDOWS)
219
#define _USE_MATH_DEFINES
222
#define __PYX_HAVE_API__bzrlib___btree_serializer_pyx
223
#include "python-compat.h"
226
#include "_static_tuple_c.h"
228
#ifdef PYREX_WITHOUT_ASSERTIONS
229
#define CYTHON_WITHOUT_ASSERTIONS
233
/* inline attribute */
234
#ifndef CYTHON_INLINE
235
#if defined(__GNUC__)
236
#define CYTHON_INLINE __inline__
237
#elif defined(_MSC_VER)
238
#define CYTHON_INLINE __inline
239
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
240
#define CYTHON_INLINE inline
242
#define CYTHON_INLINE
246
/* unused attribute */
247
#ifndef CYTHON_UNUSED
248
# if defined(__GNUC__)
249
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
250
# define CYTHON_UNUSED __attribute__ ((__unused__))
252
# define CYTHON_UNUSED
254
# elif defined(__ICC) || defined(__INTEL_COMPILER)
255
# define CYTHON_UNUSED __attribute__ ((__unused__))
257
# define CYTHON_UNUSED
261
typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
264
/* Type Conversion Predeclarations */
266
#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
267
#define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s))
269
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
270
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
271
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
273
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
274
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
275
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
277
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
281
/* Test for GCC > 2.95 */
282
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
283
#define likely(x) __builtin_expect(!!(x), 1)
284
#define unlikely(x) __builtin_expect(!!(x), 0)
285
#else /* __GNUC__ > 2 ... */
286
#define likely(x) (x)
287
#define unlikely(x) (x)
288
#endif /* __GNUC__ > 2 ... */
290
#define likely(x) (x)
291
#define unlikely(x) (x)
292
#endif /* __GNUC__ */
294
static PyObject *__pyx_m;
295
static PyObject *__pyx_b;
296
static PyObject *__pyx_empty_tuple;
297
static PyObject *__pyx_empty_bytes;
298
static int __pyx_lineno;
299
static int __pyx_clineno = 0;
300
static const char * __pyx_cfilenm= __FILE__;
301
static const char *__pyx_filename;
304
static const char *__pyx_f[] = {
305
"_btree_serializer_pyx.pyx",
306
"_static_tuple_c.pxd",
309
/* Type declarations */
311
/* "bzrlib/_btree_serializer_pyx.pyx":337
312
* # One slightly ugly option would be to cache block offsets in a global.
313
* # However, that leads to thread-safety issues, etc.
314
* ctypedef struct gc_chk_sha1_record: # <<<<<<<<<<<<<<
315
* long long block_offset
316
* unsigned int block_length
320
PY_LONG_LONG block_offset;
321
unsigned int block_length;
322
unsigned int record_start;
323
unsigned int record_end;
325
} __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record;
327
/* "bzrlib/_btree_serializer_pyx.pyx":123
330
* cdef class BTreeLeafParser: # <<<<<<<<<<<<<<
331
* """Parse the leaf nodes of a BTree index.
335
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser {
337
struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *__pyx_vtab;
348
/* "bzrlib/_btree_serializer_pyx.pyx":518
351
* cdef class GCCHKSHA1LeafNode: # <<<<<<<<<<<<<<
352
* """Track all the entries for a given leaf node."""
356
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode {
358
struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_vtab;
359
__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *records;
361
__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *last_record;
363
unsigned char common_shift;
364
unsigned char offsets[257];
368
struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode {
369
StaticTuple *(*_record_to_value_and_refs)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *);
370
StaticTuple *(*_record_to_item)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *);
371
__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *(*_lookup_record)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *);
372
int (*_count_records)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *, char *);
373
PyObject *(*_parse_bytes)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, PyObject *);
374
char *(*_parse_one_entry)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *, char *, __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *);
375
int (*_offset_for_sha1)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *);
376
PyObject *(*_compute_common)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *);
378
static struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_vtabptr_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
381
/* "bzrlib/_btree_serializer_pyx.pyx":123
384
* cdef class BTreeLeafParser: # <<<<<<<<<<<<<<
385
* """Parse the leaf nodes of a BTree index.
389
struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser {
390
PyObject *(*extract_key)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *, char *);
391
int (*process_line)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *);
393
static struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *__pyx_vtabptr_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser;
395
#ifndef CYTHON_REFNANNY
396
#define CYTHON_REFNANNY 0
401
void (*INCREF)(void*, PyObject*, int);
402
void (*DECREF)(void*, PyObject*, int);
403
void (*GOTREF)(void*, PyObject*, int);
404
void (*GIVEREF)(void*, PyObject*, int);
405
void* (*SetupContext)(const char*, int, const char*);
406
void (*FinishContext)(void**);
407
} __Pyx_RefNannyAPIStruct;
408
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
409
static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
410
PyObject *m = NULL, *p = NULL;
412
m = PyImport_ImportModule((char *)modname);
414
p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
416
r = PyLong_AsVoidPtr(p);
420
return (__Pyx_RefNannyAPIStruct *)r;
422
#define __Pyx_RefNannySetupContext(name) void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
423
#define __Pyx_RefNannyFinishContext() __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
424
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
425
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
426
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
427
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
428
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
430
#define __Pyx_RefNannySetupContext(name)
431
#define __Pyx_RefNannyFinishContext()
432
#define __Pyx_INCREF(r) Py_INCREF(r)
433
#define __Pyx_DECREF(r) Py_DECREF(r)
434
#define __Pyx_GOTREF(r)
435
#define __Pyx_GIVEREF(r)
436
#define __Pyx_XDECREF(r) Py_XDECREF(r)
437
#endif /* CYTHON_REFNANNY */
438
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
439
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
441
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
443
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
444
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
446
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
448
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
449
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
451
static void __Pyx_RaiseDoubleKeywordsError(
452
const char* func_name, PyObject* kw_name); /*proto*/
454
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/
456
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
458
static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */
461
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
464
r = PyObject_GetItem(o, j);
470
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
471
__Pyx_GetItemInt_List_Fast(o, i) : \
472
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
474
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
475
if (likely(o != Py_None)) {
476
if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
477
PyObject *r = PyList_GET_ITEM(o, i);
481
else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
482
PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
487
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
490
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
491
__Pyx_GetItemInt_Tuple_Fast(o, i) : \
492
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
494
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
495
if (likely(o != Py_None)) {
496
if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
497
PyObject *r = PyTuple_GET_ITEM(o, i);
501
else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
502
PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
507
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
511
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
512
__Pyx_GetItemInt_Fast(o, i) : \
513
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
515
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
517
if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
518
r = PyList_GET_ITEM(o, i);
521
else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
522
r = PyTuple_GET_ITEM(o, i);
525
else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
526
r = PySequence_GetItem(o, i);
529
r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
534
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
536
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
538
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
540
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
542
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
544
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
546
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
548
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
550
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
552
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
554
static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
556
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
558
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
560
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
562
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
564
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
566
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
568
static void __Pyx_WriteUnraisable(const char *name); /*proto*/
570
static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
572
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict); /*proto*/
574
static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
576
static void __Pyx_AddTraceback(const char *funcname); /*proto*/
578
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
579
/* Module declarations from bzrlib._static_tuple_c */
581
/* Module declarations from bzrlib._static_tuple_c */
583
static PyTypeObject *__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = 0;
584
/* Module declarations from bzrlib._btree_serializer_pyx */
586
static PyTypeObject *__pyx_ptype_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser = 0;
587
static PyTypeObject *__pyx_ptype_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode = 0;
588
static int __pyx_v_6bzrlib_21_btree_serializer_pyx__unhexbuf[256];
589
static char *__pyx_v_6bzrlib_21_btree_serializer_pyx__hexbuf;
590
static void *__pyx_f_6bzrlib_21_btree_serializer_pyx__my_memrchr(void *, int, size_t); /*proto*/
591
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx_safe_string_from_size(char *, Py_ssize_t); /*proto*/
592
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx_safe_interned_string_from_size(char *, Py_ssize_t); /*proto*/
593
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx__populate_unhexbuf(void); /*proto*/
594
static int __pyx_f_6bzrlib_21_btree_serializer_pyx__unhexlify_sha1(char *, char *); /*proto*/
595
static void __pyx_f_6bzrlib_21_btree_serializer_pyx__hexlify_sha1(char *, char *); /*proto*/
596
static int __pyx_f_6bzrlib_21_btree_serializer_pyx__key_to_sha1(PyObject *, char *); /*proto*/
597
static StaticTuple *__pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_key(char *); /*proto*/
598
static unsigned int __pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_uint(char *); /*proto*/
599
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx__format_record(__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *); /*proto*/
600
#define __Pyx_MODULE_NAME "bzrlib._btree_serializer_pyx"
601
static int __pyx_module_is_main_bzrlib___btree_serializer_pyx = 0;
603
/* Implementation of bzrlib._btree_serializer_pyx */
604
static PyObject *__pyx_builtin_AssertionError;
605
static PyObject *__pyx_builtin_ValueError;
606
static PyObject *__pyx_builtin_KeyError;
607
static PyObject *__pyx_builtin_TypeError;
608
static char __pyx_k_1[] = "tried to create a string with an invalid size: %d @0x%x";
609
static char __pyx_k_2[] = "invalid key, wanted segment from ";
610
static char __pyx_k_3[] = "sha1:";
611
static char __pyx_k_4[] = "last < self._start";
612
static char __pyx_k_6[] = "type=leaf";
613
static char __pyx_k_7[] = "Node did not start with \"type=leaf\": %r";
614
static char __pyx_k_8[] = "Failed to find the value area";
615
static char __pyx_k_10[] = " 0 0";
616
static char __pyx_k_12[] = "invalid key, loop_counter != self.ref_list_length";
617
static char __pyx_k_14[] = "unexpected reference data present";
618
static char __pyx_k_16[] = "self.bytes is not a string.";
619
static char __pyx_k_18[] = "not a 40-byte hex digest";
620
static char __pyx_k_20[] = "not a 20-byte binary digest";
621
static char __pyx_k_22[] = "sha1_bin must be a str of exactly 20 bytes";
622
static char __pyx_k_24[] = "%s %u %u %u";
623
static char __pyx_k_25[] = "%lu %u %u %u";
624
static char __pyx_k_26[] = "_record_to_value_and_refs";
625
static char __pyx_k_27[] = "key %r is not present";
626
static char __pyx_k_28[] = "We only support parsing plain 8-bit strings.";
627
static char __pyx_k_30[] = "type=leaf\n";
628
static char __pyx_k_31[] = "bytes did not start with 'type=leaf\\n': %r";
629
static char __pyx_k_32[] = "Something went wrong while parsing.";
630
static char __pyx_k_34[] = "line did not start with sha1: %r";
631
static char __pyx_k_35[] = "Line did not contain 40 hex bytes";
632
static char __pyx_k_37[] = "We failed to unhexlify";
633
static char __pyx_k_39[] = "only 1 null, not 2 as expected";
634
static char __pyx_k_41[] = "Failed to parse block offset";
635
static char __pyx_k_43[] = "Failed to parse block length";
636
static char __pyx_k_46[] = "Failed to parse record end";
637
static char __pyx_k_48[] = "We expected a tuple() or StaticTuple() for node not: %s";
638
static char __pyx_k_49[] = "With ref_lists, we expected 4 entries not: %s";
639
static char __pyx_k_50[] = "Without ref_lists, we need at least 3 entries not: %s";
640
static char __pyx_k_51[] = "\000";
641
static char __pyx_k_52[] = "We expect references to be tuples not: %s";
642
static char __pyx_k_53[] = "We expect reference bits to be strings not: %s";
643
static char __pyx_k_54[] = "Expected a plain str for value not: %s";
644
static char __pyx_k_55[] = "Pyrex extensions to btree node parsing.";
645
static char __pyx_k_56[] = "bzrlib._btree_serializer_pyx";
646
static char __pyx_k__sys[] = "sys";
647
static char __pyx_k__join[] = "join";
648
static char __pyx_k__keys[] = "keys";
649
static char __pyx_k__node[] = "node";
650
static char __pyx_k__sha1[] = "sha1";
651
static char __pyx_k__bytes[] = "bytes";
652
static char __pyx_k__parse[] = "parse";
653
static char __pyx_k___start[] = "_start";
654
static char __pyx_k__offsets[] = "offsets";
655
static char __pyx_k__records[] = "records";
656
static char __pyx_k__KeyError[] = "KeyError";
657
static char __pyx_k____main__[] = "__main__";
658
static char __pyx_k____test__[] = "__test__";
659
static char __pyx_k___cur_str[] = "_cur_str";
660
static char __pyx_k___end_str[] = "_end_str";
661
static char __pyx_k__last_key[] = "last_key";
662
static char __pyx_k__TypeError[] = "TypeError";
663
static char __pyx_k__ValueError[] = "ValueError";
664
static char __pyx_k__key_length[] = "key_length";
665
static char __pyx_k__record_end[] = "record_end";
666
static char __pyx_k___py_hexlify[] = "_py_hexlify";
667
static char __pyx_k__extract_key[] = "extract_key";
668
static char __pyx_k__last_record[] = "last_record";
669
static char __pyx_k__num_records[] = "num_records";
670
static char __pyx_k___parse_bytes[] = "_parse_bytes";
671
static char __pyx_k__block_length[] = "block_length";
672
static char __pyx_k__block_offset[] = "block_offset";
673
static char __pyx_k__common_shift[] = "common_shift";
674
static char __pyx_k__process_line[] = "process_line";
675
static char __pyx_k__record_start[] = "record_start";
676
static char __pyx_k___flatten_node[] = "_flatten_node";
677
static char __pyx_k___header_found[] = "_header_found";
678
static char __pyx_k___py_unhexlify[] = "_py_unhexlify";
679
static char __pyx_k__AssertionError[] = "AssertionError";
680
static char __pyx_k___count_records[] = "_count_records";
681
static char __pyx_k___lookup_record[] = "_lookup_record";
682
static char __pyx_k___compute_common[] = "_compute_common";
683
static char __pyx_k___parse_into_chk[] = "_parse_into_chk";
684
static char __pyx_k___py_key_to_sha1[] = "_py_key_to_sha1";
685
static char __pyx_k___py_sha1_to_key[] = "_py_sha1_to_key";
686
static char __pyx_k___record_to_item[] = "_record_to_item";
687
static char __pyx_k__ref_list_length[] = "ref_list_length";
688
static char __pyx_k__reference_lists[] = "reference_lists";
689
static char __pyx_k__0123456789abcdef[] = "0123456789abcdef";
690
static char __pyx_k___offset_for_sha1[] = "_offset_for_sha1";
691
static char __pyx_k___parse_one_entry[] = "_parse_one_entry";
692
static char __pyx_k___parse_leaf_lines[] = "_parse_leaf_lines";
693
static PyObject *__pyx_kp_s_1;
694
static PyObject *__pyx_kp_s_12;
695
static PyObject *__pyx_kp_s_14;
696
static PyObject *__pyx_kp_s_16;
697
static PyObject *__pyx_kp_s_18;
698
static PyObject *__pyx_kp_s_2;
699
static PyObject *__pyx_kp_s_20;
700
static PyObject *__pyx_kp_s_22;
701
static PyObject *__pyx_n_s_26;
702
static PyObject *__pyx_kp_s_27;
703
static PyObject *__pyx_kp_s_28;
704
static PyObject *__pyx_kp_s_31;
705
static PyObject *__pyx_kp_s_32;
706
static PyObject *__pyx_kp_s_34;
707
static PyObject *__pyx_kp_s_35;
708
static PyObject *__pyx_kp_s_37;
709
static PyObject *__pyx_kp_s_39;
710
static PyObject *__pyx_kp_s_4;
711
static PyObject *__pyx_kp_s_41;
712
static PyObject *__pyx_kp_s_43;
713
static PyObject *__pyx_kp_s_46;
714
static PyObject *__pyx_kp_s_48;
715
static PyObject *__pyx_kp_s_49;
716
static PyObject *__pyx_kp_s_50;
717
static PyObject *__pyx_kp_s_51;
718
static PyObject *__pyx_kp_s_52;
719
static PyObject *__pyx_kp_s_53;
720
static PyObject *__pyx_kp_s_54;
721
static PyObject *__pyx_n_s_56;
722
static PyObject *__pyx_kp_s_7;
723
static PyObject *__pyx_kp_s_8;
724
static PyObject *__pyx_n_s__AssertionError;
725
static PyObject *__pyx_n_s__KeyError;
726
static PyObject *__pyx_n_s__TypeError;
727
static PyObject *__pyx_n_s__ValueError;
728
static PyObject *__pyx_n_s____main__;
729
static PyObject *__pyx_n_s____test__;
730
static PyObject *__pyx_n_s___compute_common;
731
static PyObject *__pyx_n_s___count_records;
732
static PyObject *__pyx_n_s___cur_str;
733
static PyObject *__pyx_n_s___end_str;
734
static PyObject *__pyx_n_s___flatten_node;
735
static PyObject *__pyx_n_s___header_found;
736
static PyObject *__pyx_n_s___lookup_record;
737
static PyObject *__pyx_n_s___offset_for_sha1;
738
static PyObject *__pyx_n_s___parse_bytes;
739
static PyObject *__pyx_n_s___parse_into_chk;
740
static PyObject *__pyx_n_s___parse_leaf_lines;
741
static PyObject *__pyx_n_s___parse_one_entry;
742
static PyObject *__pyx_n_s___py_hexlify;
743
static PyObject *__pyx_n_s___py_key_to_sha1;
744
static PyObject *__pyx_n_s___py_sha1_to_key;
745
static PyObject *__pyx_n_s___py_unhexlify;
746
static PyObject *__pyx_n_s___record_to_item;
747
static PyObject *__pyx_n_s___start;
748
static PyObject *__pyx_n_s__block_length;
749
static PyObject *__pyx_n_s__block_offset;
750
static PyObject *__pyx_n_s__bytes;
751
static PyObject *__pyx_n_s__common_shift;
752
static PyObject *__pyx_n_s__extract_key;
753
static PyObject *__pyx_n_s__join;
754
static PyObject *__pyx_n_s__key_length;
755
static PyObject *__pyx_n_s__keys;
756
static PyObject *__pyx_n_s__last_key;
757
static PyObject *__pyx_n_s__last_record;
758
static PyObject *__pyx_n_s__node;
759
static PyObject *__pyx_n_s__num_records;
760
static PyObject *__pyx_n_s__offsets;
761
static PyObject *__pyx_n_s__parse;
762
static PyObject *__pyx_n_s__process_line;
763
static PyObject *__pyx_n_s__record_end;
764
static PyObject *__pyx_n_s__record_start;
765
static PyObject *__pyx_n_s__records;
766
static PyObject *__pyx_n_s__ref_list_length;
767
static PyObject *__pyx_n_s__reference_lists;
768
static PyObject *__pyx_n_s__sha1;
769
static PyObject *__pyx_n_s__sys;
770
static PyObject *__pyx_int_0;
771
static PyObject *__pyx_int_1;
772
static PyObject *__pyx_int_2147483648;
773
static PyObject *__pyx_int_4294967295;
774
static PyObject *__pyx_k_tuple_5;
775
static PyObject *__pyx_k_tuple_9;
776
static PyObject *__pyx_k_tuple_11;
777
static PyObject *__pyx_k_tuple_13;
778
static PyObject *__pyx_k_tuple_15;
779
static PyObject *__pyx_k_tuple_17;
780
static PyObject *__pyx_k_tuple_19;
781
static PyObject *__pyx_k_tuple_21;
782
static PyObject *__pyx_k_tuple_23;
783
static PyObject *__pyx_k_tuple_29;
784
static PyObject *__pyx_k_tuple_33;
785
static PyObject *__pyx_k_tuple_36;
786
static PyObject *__pyx_k_tuple_38;
787
static PyObject *__pyx_k_tuple_40;
788
static PyObject *__pyx_k_tuple_42;
789
static PyObject *__pyx_k_tuple_44;
790
static PyObject *__pyx_k_tuple_45;
791
static PyObject *__pyx_k_tuple_47;
793
/* "bzrlib/_btree_serializer_pyx.pyx":81
795
* # TODO: Find some way to import this from _dirstate_helpers
796
* cdef void* _my_memrchr(void *s, int c, size_t n): # cannot_raise # <<<<<<<<<<<<<<
797
* # memrchr seems to be a GNU extension, so we have to implement it ourselves
798
* # It is not present in any win32 standard library
801
static void *__pyx_f_6bzrlib_21_btree_serializer_pyx__my_memrchr(void *__pyx_v_s, int __pyx_v_c, size_t __pyx_v_n) {
806
__Pyx_RefNannySetupContext("_my_memrchr");
808
/* "bzrlib/_btree_serializer_pyx.pyx":87
811
* start = <char*>s # <<<<<<<<<<<<<<
812
* pos = start + n - 1
813
* while pos >= start:
815
__pyx_v_start = ((char *)__pyx_v_s);
817
/* "bzrlib/_btree_serializer_pyx.pyx":88
820
* pos = start + n - 1 # <<<<<<<<<<<<<<
821
* while pos >= start:
824
__pyx_v_pos = ((__pyx_v_start + __pyx_v_n) - 1);
826
/* "bzrlib/_btree_serializer_pyx.pyx":89
828
* pos = start + n - 1
829
* while pos >= start: # <<<<<<<<<<<<<<
834
__pyx_t_1 = (__pyx_v_pos >= __pyx_v_start);
835
if (!__pyx_t_1) break;
837
/* "bzrlib/_btree_serializer_pyx.pyx":90
838
* pos = start + n - 1
839
* while pos >= start:
840
* if pos[0] == c: # <<<<<<<<<<<<<<
844
__pyx_t_1 = ((__pyx_v_pos[0]) == __pyx_v_c);
847
/* "bzrlib/_btree_serializer_pyx.pyx":91
848
* while pos >= start:
850
* return <void*>pos # <<<<<<<<<<<<<<
854
__pyx_r = ((void *)__pyx_v_pos);
860
/* "bzrlib/_btree_serializer_pyx.pyx":92
863
* pos = pos - 1 # <<<<<<<<<<<<<<
867
__pyx_v_pos = (__pyx_v_pos - 1);
870
/* "bzrlib/_btree_serializer_pyx.pyx":93
873
* return NULL # <<<<<<<<<<<<<<
882
__Pyx_RefNannyFinishContext();
886
/* "bzrlib/_btree_serializer_pyx.pyx":97
888
* # TODO: Import this from _dirstate_helpers when it is merged
889
* cdef object safe_string_from_size(char *s, Py_ssize_t size): # <<<<<<<<<<<<<<
891
* raise AssertionError(
894
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx_safe_string_from_size(char *__pyx_v_s, Py_ssize_t __pyx_v_size) {
895
PyObject *__pyx_r = NULL;
897
PyObject *__pyx_t_2 = NULL;
898
PyObject *__pyx_t_3 = NULL;
899
PyObject *__pyx_t_4 = NULL;
900
__Pyx_RefNannySetupContext("safe_string_from_size");
902
/* "bzrlib/_btree_serializer_pyx.pyx":98
903
* # TODO: Import this from _dirstate_helpers when it is merged
904
* cdef object safe_string_from_size(char *s, Py_ssize_t size):
905
* if size < 0: # <<<<<<<<<<<<<<
906
* raise AssertionError(
907
* 'tried to create a string with an invalid size: %d @0x%x'
909
__pyx_t_1 = (__pyx_v_size < 0);
912
/* "bzrlib/_btree_serializer_pyx.pyx":101
913
* raise AssertionError(
914
* 'tried to create a string with an invalid size: %d @0x%x'
915
* % (size, <int>s)) # <<<<<<<<<<<<<<
916
* return PyString_FromStringAndSize(s, size)
919
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
920
__Pyx_GOTREF(__pyx_t_2);
921
__pyx_t_3 = PyInt_FromLong(((int)__pyx_v_s)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
922
__Pyx_GOTREF(__pyx_t_3);
923
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
924
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
925
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
926
__Pyx_GIVEREF(__pyx_t_2);
927
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
928
__Pyx_GIVEREF(__pyx_t_3);
931
__pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
932
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
933
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
934
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
935
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
936
PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
937
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
939
__pyx_t_3 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
940
__Pyx_GOTREF(__pyx_t_3);
941
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
942
__Pyx_Raise(__pyx_t_3, 0, 0);
943
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
944
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
949
/* "bzrlib/_btree_serializer_pyx.pyx":102
950
* 'tried to create a string with an invalid size: %d @0x%x'
952
* return PyString_FromStringAndSize(s, size) # <<<<<<<<<<<<<<
956
__Pyx_XDECREF(__pyx_r);
957
__pyx_t_3 = PyString_FromStringAndSize(__pyx_v_s, __pyx_v_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
958
__Pyx_GOTREF(__pyx_t_3);
963
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
966
__Pyx_XDECREF(__pyx_t_2);
967
__Pyx_XDECREF(__pyx_t_3);
968
__Pyx_XDECREF(__pyx_t_4);
969
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.safe_string_from_size");
972
__Pyx_XGIVEREF(__pyx_r);
973
__Pyx_RefNannyFinishContext();
977
/* "bzrlib/_btree_serializer_pyx.pyx":105
980
* cdef object safe_interned_string_from_size(char *s, Py_ssize_t size): # <<<<<<<<<<<<<<
981
* cdef PyObject *py_str
985
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx_safe_interned_string_from_size(char *__pyx_v_s, Py_ssize_t __pyx_v_size) {
986
PyObject *__pyx_v_py_str;
987
PyObject *__pyx_v_result;
988
PyObject *__pyx_r = NULL;
990
PyObject *__pyx_t_2 = NULL;
991
PyObject *__pyx_t_3 = NULL;
992
PyObject *__pyx_t_4 = NULL;
993
__Pyx_RefNannySetupContext("safe_interned_string_from_size");
994
__pyx_v_result = Py_None; __Pyx_INCREF(Py_None);
996
/* "bzrlib/_btree_serializer_pyx.pyx":107
997
* cdef object safe_interned_string_from_size(char *s, Py_ssize_t size):
998
* cdef PyObject *py_str
999
* if size < 0: # <<<<<<<<<<<<<<
1000
* raise AssertionError(
1001
* 'tried to create a string with an invalid size: %d @0x%x'
1003
__pyx_t_1 = (__pyx_v_size < 0);
1006
/* "bzrlib/_btree_serializer_pyx.pyx":110
1007
* raise AssertionError(
1008
* 'tried to create a string with an invalid size: %d @0x%x'
1009
* % (size, <int>s)) # <<<<<<<<<<<<<<
1010
* py_str = PyString_FromStringAndSize_ptr(s, size)
1011
* PyString_InternInPlace(&py_str)
1013
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1014
__Pyx_GOTREF(__pyx_t_2);
1015
__pyx_t_3 = PyInt_FromLong(((int)__pyx_v_s)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1016
__Pyx_GOTREF(__pyx_t_3);
1017
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1018
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
1019
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
1020
__Pyx_GIVEREF(__pyx_t_2);
1021
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
1022
__Pyx_GIVEREF(__pyx_t_3);
1025
__pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1026
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
1027
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
1028
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1029
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
1030
PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
1031
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
1033
__pyx_t_3 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1034
__Pyx_GOTREF(__pyx_t_3);
1035
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
1036
__Pyx_Raise(__pyx_t_3, 0, 0);
1037
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1038
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1043
/* "bzrlib/_btree_serializer_pyx.pyx":111
1044
* 'tried to create a string with an invalid size: %d @0x%x'
1046
* py_str = PyString_FromStringAndSize_ptr(s, size) # <<<<<<<<<<<<<<
1047
* PyString_InternInPlace(&py_str)
1048
* result = <object>py_str
1050
__pyx_v_py_str = PyString_FromStringAndSize(__pyx_v_s, __pyx_v_size);
1052
/* "bzrlib/_btree_serializer_pyx.pyx":112
1054
* py_str = PyString_FromStringAndSize_ptr(s, size)
1055
* PyString_InternInPlace(&py_str) # <<<<<<<<<<<<<<
1056
* result = <object>py_str
1057
* # Casting a PyObject* to an <object> triggers an INCREF from Pyrex, so we
1059
PyString_InternInPlace((&__pyx_v_py_str));
1061
/* "bzrlib/_btree_serializer_pyx.pyx":113
1062
* py_str = PyString_FromStringAndSize_ptr(s, size)
1063
* PyString_InternInPlace(&py_str)
1064
* result = <object>py_str # <<<<<<<<<<<<<<
1065
* # Casting a PyObject* to an <object> triggers an INCREF from Pyrex, so we
1066
* # DECREF it to avoid geting immortal strings
1068
__Pyx_INCREF(((PyObject *)__pyx_v_py_str));
1069
__Pyx_DECREF(__pyx_v_result);
1070
__pyx_v_result = ((PyObject *)__pyx_v_py_str);
1072
/* "bzrlib/_btree_serializer_pyx.pyx":116
1073
* # Casting a PyObject* to an <object> triggers an INCREF from Pyrex, so we
1074
* # DECREF it to avoid geting immortal strings
1075
* Py_DECREF_ptr(py_str) # <<<<<<<<<<<<<<
1079
Py_DECREF(__pyx_v_py_str);
1081
/* "bzrlib/_btree_serializer_pyx.pyx":117
1082
* # DECREF it to avoid geting immortal strings
1083
* Py_DECREF_ptr(py_str)
1084
* return result # <<<<<<<<<<<<<<
1086
* # This sets up the StaticTuple C_API functionality
1088
__Pyx_XDECREF(__pyx_r);
1089
__Pyx_INCREF(__pyx_v_result);
1090
__pyx_r = __pyx_v_result;
1093
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
1096
__Pyx_XDECREF(__pyx_t_2);
1097
__Pyx_XDECREF(__pyx_t_3);
1098
__Pyx_XDECREF(__pyx_t_4);
1099
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.safe_interned_string_from_size");
1102
__Pyx_DECREF(__pyx_v_result);
1103
__Pyx_XGIVEREF(__pyx_r);
1104
__Pyx_RefNannyFinishContext();
1108
/* "bzrlib/_btree_serializer_pyx.pyx":153
1109
* cdef int _header_found
1111
* def __init__(self, bytes, key_length, ref_list_length): # <<<<<<<<<<<<<<
1112
* self.bytes = bytes
1113
* self.key_length = key_length
1116
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1117
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1118
PyObject *__pyx_v_bytes = 0;
1119
PyObject *__pyx_v_key_length = 0;
1120
PyObject *__pyx_v_ref_list_length = 0;
1123
PyObject *__pyx_t_2 = NULL;
1124
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bytes,&__pyx_n_s__key_length,&__pyx_n_s__ref_list_length,0};
1125
__Pyx_RefNannySetupContext("__init__");
1126
if (unlikely(__pyx_kwds)) {
1127
Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
1128
PyObject* values[3] = {0,0,0};
1129
switch (PyTuple_GET_SIZE(__pyx_args)) {
1130
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1131
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1132
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1134
default: goto __pyx_L5_argtuple_error;
1136
switch (PyTuple_GET_SIZE(__pyx_args)) {
1138
values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bytes);
1139
if (likely(values[0])) kw_args--;
1140
else goto __pyx_L5_argtuple_error;
1142
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key_length);
1143
if (likely(values[1])) kw_args--;
1145
__Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1148
values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref_list_length);
1149
if (likely(values[2])) kw_args--;
1151
__Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1154
if (unlikely(kw_args > 0)) {
1155
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1157
__pyx_v_bytes = values[0];
1158
__pyx_v_key_length = values[1];
1159
__pyx_v_ref_list_length = values[2];
1160
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
1161
goto __pyx_L5_argtuple_error;
1163
__pyx_v_bytes = PyTuple_GET_ITEM(__pyx_args, 0);
1164
__pyx_v_key_length = PyTuple_GET_ITEM(__pyx_args, 1);
1165
__pyx_v_ref_list_length = PyTuple_GET_ITEM(__pyx_args, 2);
1167
goto __pyx_L4_argument_unpacking_done;
1168
__pyx_L5_argtuple_error:;
1169
__Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1171
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.BTreeLeafParser.__init__");
1172
__Pyx_RefNannyFinishContext();
1174
__pyx_L4_argument_unpacking_done:;
1176
/* "bzrlib/_btree_serializer_pyx.pyx":154
1178
* def __init__(self, bytes, key_length, ref_list_length):
1179
* self.bytes = bytes # <<<<<<<<<<<<<<
1180
* self.key_length = key_length
1181
* self.ref_list_length = ref_list_length
1183
__Pyx_INCREF(__pyx_v_bytes);
1184
__Pyx_GIVEREF(__pyx_v_bytes);
1185
__Pyx_GOTREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->bytes);
1186
__Pyx_DECREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->bytes);
1187
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->bytes = __pyx_v_bytes;
1189
/* "bzrlib/_btree_serializer_pyx.pyx":155
1190
* def __init__(self, bytes, key_length, ref_list_length):
1191
* self.bytes = bytes
1192
* self.key_length = key_length # <<<<<<<<<<<<<<
1193
* self.ref_list_length = ref_list_length
1196
__pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_key_length); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1197
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->key_length = __pyx_t_1;
1199
/* "bzrlib/_btree_serializer_pyx.pyx":156
1200
* self.bytes = bytes
1201
* self.key_length = key_length
1202
* self.ref_list_length = ref_list_length # <<<<<<<<<<<<<<
1204
* self._cur_str = NULL
1206
__pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_ref_list_length); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1207
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->ref_list_length = __pyx_t_1;
1209
/* "bzrlib/_btree_serializer_pyx.pyx":157
1210
* self.key_length = key_length
1211
* self.ref_list_length = ref_list_length
1212
* self.keys = [] # <<<<<<<<<<<<<<
1213
* self._cur_str = NULL
1214
* self._end_str = NULL
1216
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1217
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
1218
__Pyx_GIVEREF(((PyObject *)__pyx_t_2));
1219
__Pyx_GOTREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->keys);
1220
__Pyx_DECREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->keys);
1221
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->keys = ((PyObject *)__pyx_t_2);
1224
/* "bzrlib/_btree_serializer_pyx.pyx":158
1225
* self.ref_list_length = ref_list_length
1227
* self._cur_str = NULL # <<<<<<<<<<<<<<
1228
* self._end_str = NULL
1229
* self._header_found = 0
1231
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->_cur_str = NULL;
1233
/* "bzrlib/_btree_serializer_pyx.pyx":159
1235
* self._cur_str = NULL
1236
* self._end_str = NULL # <<<<<<<<<<<<<<
1237
* self._header_found = 0
1240
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->_end_str = NULL;
1242
/* "bzrlib/_btree_serializer_pyx.pyx":160
1243
* self._cur_str = NULL
1244
* self._end_str = NULL
1245
* self._header_found = 0 # <<<<<<<<<<<<<<
1249
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->_header_found = 0;
1254
__Pyx_XDECREF(__pyx_t_2);
1255
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.BTreeLeafParser.__init__");
1258
__Pyx_RefNannyFinishContext();
1262
/* "bzrlib/_btree_serializer_pyx.pyx":163
1265
* cdef extract_key(self, char * last): # <<<<<<<<<<<<<<
1270
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser_extract_key(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self, char *__pyx_v_last) {
1271
char *__pyx_v_temp_ptr;
1272
int __pyx_v_loop_counter;
1273
StaticTuple *__pyx_v_key;
1274
PyObject *__pyx_v_failure_string;
1275
PyObject *__pyx_v_key_element;
1276
PyObject *__pyx_r = NULL;
1277
PyObject *__pyx_t_1 = NULL;
1280
PyObject *__pyx_t_4 = NULL;
1284
__Pyx_RefNannySetupContext("extract_key");
1285
__pyx_v_key = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
1286
__pyx_v_failure_string = Py_None; __Pyx_INCREF(Py_None);
1287
__pyx_v_key_element = Py_None; __Pyx_INCREF(Py_None);
1289
/* "bzrlib/_btree_serializer_pyx.pyx":173
1290
* cdef StaticTuple key
1292
* key = StaticTuple_New(self.key_length) # <<<<<<<<<<<<<<
1293
* for loop_counter from 0 <= loop_counter < self.key_length:
1294
* # grab a key segment
1296
__pyx_t_1 = ((PyObject *)StaticTuple_New(__pyx_v_self->key_length)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1297
__Pyx_GOTREF(__pyx_t_1);
1298
__Pyx_DECREF(((PyObject *)__pyx_v_key));
1299
__pyx_v_key = ((StaticTuple *)__pyx_t_1);
1302
/* "bzrlib/_btree_serializer_pyx.pyx":174
1304
* key = StaticTuple_New(self.key_length)
1305
* for loop_counter from 0 <= loop_counter < self.key_length: # <<<<<<<<<<<<<<
1306
* # grab a key segment
1307
* temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
1309
__pyx_t_2 = __pyx_v_self->key_length;
1310
for (__pyx_v_loop_counter = 0; __pyx_v_loop_counter < __pyx_t_2; __pyx_v_loop_counter++) {
1312
/* "bzrlib/_btree_serializer_pyx.pyx":176
1313
* for loop_counter from 0 <= loop_counter < self.key_length:
1314
* # grab a key segment
1315
* temp_ptr = <char*>memchr(self._start, c'\0', last - self._start) # <<<<<<<<<<<<<<
1316
* if temp_ptr == NULL:
1317
* if loop_counter + 1 == self.key_length:
1319
__pyx_v_temp_ptr = ((char *)memchr(__pyx_v_self->_start, '\x00', (__pyx_v_last - __pyx_v_self->_start)));
1321
/* "bzrlib/_btree_serializer_pyx.pyx":177
1322
* # grab a key segment
1323
* temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
1324
* if temp_ptr == NULL: # <<<<<<<<<<<<<<
1325
* if loop_counter + 1 == self.key_length:
1328
__pyx_t_3 = (__pyx_v_temp_ptr == NULL);
1331
/* "bzrlib/_btree_serializer_pyx.pyx":178
1332
* temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
1333
* if temp_ptr == NULL:
1334
* if loop_counter + 1 == self.key_length: # <<<<<<<<<<<<<<
1338
__pyx_t_3 = ((__pyx_v_loop_counter + 1) == __pyx_v_self->key_length);
1341
/* "bzrlib/_btree_serializer_pyx.pyx":180
1342
* if loop_counter + 1 == self.key_length:
1344
* temp_ptr = last # <<<<<<<<<<<<<<
1348
__pyx_v_temp_ptr = __pyx_v_last;
1353
/* "bzrlib/_btree_serializer_pyx.pyx":185
1354
* failure_string = ("invalid key, wanted segment from " +
1355
* repr(safe_string_from_size(self._start,
1356
* last - self._start))) # <<<<<<<<<<<<<<
1357
* raise AssertionError(failure_string)
1358
* # capture the key string
1360
__pyx_t_1 = __pyx_f_6bzrlib_21_btree_serializer_pyx_safe_string_from_size(__pyx_v_self->_start, (__pyx_v_last - __pyx_v_self->_start)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1361
__Pyx_GOTREF(__pyx_t_1);
1362
__pyx_t_4 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1363
__Pyx_GOTREF(__pyx_t_4);
1364
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1365
__pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_s_2), __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1366
__Pyx_GOTREF(__pyx_t_1);
1367
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1368
__Pyx_DECREF(__pyx_v_failure_string);
1369
__pyx_v_failure_string = __pyx_t_1;
1372
/* "bzrlib/_btree_serializer_pyx.pyx":186
1373
* repr(safe_string_from_size(self._start,
1374
* last - self._start)))
1375
* raise AssertionError(failure_string) # <<<<<<<<<<<<<<
1376
* # capture the key string
1377
* if (self.key_length == 1
1379
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1380
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
1381
__Pyx_INCREF(__pyx_v_failure_string);
1382
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_failure_string);
1383
__Pyx_GIVEREF(__pyx_v_failure_string);
1384
__pyx_t_4 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1385
__Pyx_GOTREF(__pyx_t_4);
1386
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
1387
__Pyx_Raise(__pyx_t_4, 0, 0);
1388
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1389
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1396
/* "bzrlib/_btree_serializer_pyx.pyx":188
1397
* raise AssertionError(failure_string)
1398
* # capture the key string
1399
* if (self.key_length == 1 # <<<<<<<<<<<<<<
1400
* and (temp_ptr - self._start) == 45
1401
* and strncmp(self._start, 'sha1:', 5) == 0):
1403
__pyx_t_3 = (__pyx_v_self->key_length == 1);
1406
/* "bzrlib/_btree_serializer_pyx.pyx":189
1407
* # capture the key string
1408
* if (self.key_length == 1
1409
* and (temp_ptr - self._start) == 45 # <<<<<<<<<<<<<<
1410
* and strncmp(self._start, 'sha1:', 5) == 0):
1411
* key_element = safe_string_from_size(self._start,
1413
__pyx_t_5 = ((__pyx_v_temp_ptr - __pyx_v_self->_start) == 45);
1416
/* "bzrlib/_btree_serializer_pyx.pyx":190
1417
* if (self.key_length == 1
1418
* and (temp_ptr - self._start) == 45
1419
* and strncmp(self._start, 'sha1:', 5) == 0): # <<<<<<<<<<<<<<
1420
* key_element = safe_string_from_size(self._start,
1421
* temp_ptr - self._start)
1423
__pyx_t_6 = (strncmp(__pyx_v_self->_start, __pyx_k_3, 5) == 0);
1424
__pyx_t_7 = __pyx_t_6;
1426
__pyx_t_7 = __pyx_t_5;
1428
__pyx_t_5 = __pyx_t_7;
1430
__pyx_t_5 = __pyx_t_3;
1434
/* "bzrlib/_btree_serializer_pyx.pyx":192
1435
* and strncmp(self._start, 'sha1:', 5) == 0):
1436
* key_element = safe_string_from_size(self._start,
1437
* temp_ptr - self._start) # <<<<<<<<<<<<<<
1439
* key_element = safe_interned_string_from_size(self._start,
1441
__pyx_t_4 = __pyx_f_6bzrlib_21_btree_serializer_pyx_safe_string_from_size(__pyx_v_self->_start, (__pyx_v_temp_ptr - __pyx_v_self->_start)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1442
__Pyx_GOTREF(__pyx_t_4);
1443
__Pyx_DECREF(__pyx_v_key_element);
1444
__pyx_v_key_element = __pyx_t_4;
1450
/* "bzrlib/_btree_serializer_pyx.pyx":195
1452
* key_element = safe_interned_string_from_size(self._start,
1453
* temp_ptr - self._start) # <<<<<<<<<<<<<<
1454
* # advance our pointer
1455
* self._start = temp_ptr + 1
1457
__pyx_t_4 = __pyx_f_6bzrlib_21_btree_serializer_pyx_safe_interned_string_from_size(__pyx_v_self->_start, (__pyx_v_temp_ptr - __pyx_v_self->_start)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1458
__Pyx_GOTREF(__pyx_t_4);
1459
__Pyx_DECREF(__pyx_v_key_element);
1460
__pyx_v_key_element = __pyx_t_4;
1465
/* "bzrlib/_btree_serializer_pyx.pyx":197
1466
* temp_ptr - self._start)
1467
* # advance our pointer
1468
* self._start = temp_ptr + 1 # <<<<<<<<<<<<<<
1469
* Py_INCREF(key_element)
1470
* StaticTuple_SET_ITEM(key, loop_counter, key_element)
1472
__pyx_v_self->_start = (__pyx_v_temp_ptr + 1);
1474
/* "bzrlib/_btree_serializer_pyx.pyx":198
1475
* # advance our pointer
1476
* self._start = temp_ptr + 1
1477
* Py_INCREF(key_element) # <<<<<<<<<<<<<<
1478
* StaticTuple_SET_ITEM(key, loop_counter, key_element)
1479
* key = StaticTuple_Intern(key)
1481
Py_INCREF(__pyx_v_key_element);
1483
/* "bzrlib/_btree_serializer_pyx.pyx":199
1484
* self._start = temp_ptr + 1
1485
* Py_INCREF(key_element)
1486
* StaticTuple_SET_ITEM(key, loop_counter, key_element) # <<<<<<<<<<<<<<
1487
* key = StaticTuple_Intern(key)
1490
StaticTuple_SET_ITEM(__pyx_v_key, __pyx_v_loop_counter, __pyx_v_key_element);
1493
/* "bzrlib/_btree_serializer_pyx.pyx":200
1494
* Py_INCREF(key_element)
1495
* StaticTuple_SET_ITEM(key, loop_counter, key_element)
1496
* key = StaticTuple_Intern(key) # <<<<<<<<<<<<<<
1500
__pyx_t_4 = ((PyObject *)StaticTuple_Intern(__pyx_v_key)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1501
__Pyx_GOTREF(__pyx_t_4);
1502
__Pyx_DECREF(((PyObject *)__pyx_v_key));
1503
__pyx_v_key = ((StaticTuple *)__pyx_t_4);
1506
/* "bzrlib/_btree_serializer_pyx.pyx":201
1507
* StaticTuple_SET_ITEM(key, loop_counter, key_element)
1508
* key = StaticTuple_Intern(key)
1509
* return key # <<<<<<<<<<<<<<
1511
* cdef int process_line(self) except -1:
1513
__Pyx_XDECREF(__pyx_r);
1514
__Pyx_INCREF(((PyObject *)__pyx_v_key));
1515
__pyx_r = ((PyObject *)__pyx_v_key);
1518
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
1521
__Pyx_XDECREF(__pyx_t_1);
1522
__Pyx_XDECREF(__pyx_t_4);
1523
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.BTreeLeafParser.extract_key");
1526
__Pyx_DECREF((PyObject *)__pyx_v_key);
1527
__Pyx_DECREF(__pyx_v_failure_string);
1528
__Pyx_DECREF(__pyx_v_key_element);
1529
__Pyx_XGIVEREF(__pyx_r);
1530
__Pyx_RefNannyFinishContext();
1534
/* "bzrlib/_btree_serializer_pyx.pyx":203
1537
* cdef int process_line(self) except -1: # <<<<<<<<<<<<<<
1538
* """Process a line in the bytes."""
1542
static int __pyx_f_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser_process_line(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self) {
1544
char *__pyx_v_temp_ptr;
1545
char *__pyx_v_ref_ptr;
1546
char *__pyx_v_next_start;
1547
int __pyx_v_loop_counter;
1548
Py_ssize_t __pyx_v_str_len;
1549
PyObject *__pyx_v_key;
1550
PyObject *__pyx_v_value;
1551
StaticTuple *__pyx_v_ref_lists;
1552
PyObject *__pyx_v_ref_list;
1553
StaticTuple *__pyx_v_node_value;
1556
PyObject *__pyx_t_2 = NULL;
1557
PyObject *__pyx_t_3 = NULL;
1561
PyObject *__pyx_t_7 = NULL;
1562
__Pyx_RefNannySetupContext("process_line");
1563
__pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
1564
__pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
1565
__pyx_v_ref_lists = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
1566
__pyx_v_ref_list = Py_None; __Pyx_INCREF(Py_None);
1567
__pyx_v_node_value = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
1569
/* "bzrlib/_btree_serializer_pyx.pyx":212
1570
* cdef Py_ssize_t str_len
1572
* self._start = self._cur_str # <<<<<<<<<<<<<<
1573
* # Find the next newline
1574
* last = <char*>memchr(self._start, c'\n', self._end_str - self._start)
1576
__pyx_v_self->_start = __pyx_v_self->_cur_str;
1578
/* "bzrlib/_btree_serializer_pyx.pyx":214
1579
* self._start = self._cur_str
1580
* # Find the next newline
1581
* last = <char*>memchr(self._start, c'\n', self._end_str - self._start) # <<<<<<<<<<<<<<
1583
* # Process until the end of the file
1585
__pyx_v_last = ((char *)memchr(__pyx_v_self->_start, '\n', (__pyx_v_self->_end_str - __pyx_v_self->_start)));
1587
/* "bzrlib/_btree_serializer_pyx.pyx":215
1588
* # Find the next newline
1589
* last = <char*>memchr(self._start, c'\n', self._end_str - self._start)
1590
* if last == NULL: # <<<<<<<<<<<<<<
1591
* # Process until the end of the file
1592
* last = self._end_str
1594
__pyx_t_1 = (__pyx_v_last == NULL);
1597
/* "bzrlib/_btree_serializer_pyx.pyx":217
1599
* # Process until the end of the file
1600
* last = self._end_str # <<<<<<<<<<<<<<
1601
* self._cur_str = self._end_str
1604
__pyx_v_last = __pyx_v_self->_end_str;
1606
/* "bzrlib/_btree_serializer_pyx.pyx":218
1607
* # Process until the end of the file
1608
* last = self._end_str
1609
* self._cur_str = self._end_str # <<<<<<<<<<<<<<
1611
* # And the next string is right after it
1613
__pyx_v_self->_cur_str = __pyx_v_self->_end_str;
1618
/* "bzrlib/_btree_serializer_pyx.pyx":221
1620
* # And the next string is right after it
1621
* self._cur_str = last + 1 # <<<<<<<<<<<<<<
1622
* # The last character is right before the '\n'
1625
__pyx_v_self->_cur_str = (__pyx_v_last + 1);
1629
/* "bzrlib/_btree_serializer_pyx.pyx":224
1630
* # The last character is right before the '\n'
1632
* if last == self._start: # <<<<<<<<<<<<<<
1636
__pyx_t_1 = (__pyx_v_last == __pyx_v_self->_start);
1639
/* "bzrlib/_btree_serializer_pyx.pyx":226
1640
* if last == self._start:
1642
* return 0 # <<<<<<<<<<<<<<
1643
* if last < self._start:
1644
* # Unexpected error condition - fail
1652
/* "bzrlib/_btree_serializer_pyx.pyx":227
1655
* if last < self._start: # <<<<<<<<<<<<<<
1656
* # Unexpected error condition - fail
1657
* raise AssertionError("last < self._start")
1659
__pyx_t_1 = (__pyx_v_last < __pyx_v_self->_start);
1662
/* "bzrlib/_btree_serializer_pyx.pyx":229
1663
* if last < self._start:
1664
* # Unexpected error condition - fail
1665
* raise AssertionError("last < self._start") # <<<<<<<<<<<<<<
1666
* if 0 == self._header_found:
1667
* # The first line in a leaf node is the header "type=leaf\n"
1669
__pyx_t_2 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1670
__Pyx_GOTREF(__pyx_t_2);
1671
__Pyx_Raise(__pyx_t_2, 0, 0);
1672
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1673
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1678
/* "bzrlib/_btree_serializer_pyx.pyx":230
1679
* # Unexpected error condition - fail
1680
* raise AssertionError("last < self._start")
1681
* if 0 == self._header_found: # <<<<<<<<<<<<<<
1682
* # The first line in a leaf node is the header "type=leaf\n"
1683
* if strncmp("type=leaf", self._start, last - self._start) == 0:
1685
__pyx_t_1 = (0 == __pyx_v_self->_header_found);
1688
/* "bzrlib/_btree_serializer_pyx.pyx":232
1689
* if 0 == self._header_found:
1690
* # The first line in a leaf node is the header "type=leaf\n"
1691
* if strncmp("type=leaf", self._start, last - self._start) == 0: # <<<<<<<<<<<<<<
1692
* self._header_found = 1
1695
__pyx_t_1 = (strncmp(__pyx_k_6, __pyx_v_self->_start, (__pyx_v_last - __pyx_v_self->_start)) == 0);
1698
/* "bzrlib/_btree_serializer_pyx.pyx":233
1699
* # The first line in a leaf node is the header "type=leaf\n"
1700
* if strncmp("type=leaf", self._start, last - self._start) == 0:
1701
* self._header_found = 1 # <<<<<<<<<<<<<<
1705
__pyx_v_self->_header_found = 1;
1707
/* "bzrlib/_btree_serializer_pyx.pyx":234
1708
* if strncmp("type=leaf", self._start, last - self._start) == 0:
1709
* self._header_found = 1
1710
* return 0 # <<<<<<<<<<<<<<
1712
* raise AssertionError('Node did not start with "type=leaf": %r'
1720
/* "bzrlib/_btree_serializer_pyx.pyx":237
1722
* raise AssertionError('Node did not start with "type=leaf": %r'
1723
* % (safe_string_from_size(self._start, last - self._start))) # <<<<<<<<<<<<<<
1725
* key = self.extract_key(last)
1727
__pyx_t_2 = __pyx_f_6bzrlib_21_btree_serializer_pyx_safe_string_from_size(__pyx_v_self->_start, (__pyx_v_last - __pyx_v_self->_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1728
__Pyx_GOTREF(__pyx_t_2);
1729
__pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1730
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
1731
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1732
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1733
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
1734
PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
1735
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
1737
__pyx_t_3 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1738
__Pyx_GOTREF(__pyx_t_3);
1739
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
1740
__Pyx_Raise(__pyx_t_3, 0, 0);
1741
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1742
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1749
/* "bzrlib/_btree_serializer_pyx.pyx":239
1750
* % (safe_string_from_size(self._start, last - self._start)))
1752
* key = self.extract_key(last) # <<<<<<<<<<<<<<
1753
* # find the value area
1754
* temp_ptr = <char*>_my_memrchr(self._start, c'\0', last - self._start)
1756
__pyx_t_3 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self->__pyx_vtab)->extract_key(__pyx_v_self, __pyx_v_last); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1757
__Pyx_GOTREF(__pyx_t_3);
1758
__Pyx_DECREF(__pyx_v_key);
1759
__pyx_v_key = __pyx_t_3;
1762
/* "bzrlib/_btree_serializer_pyx.pyx":241
1763
* key = self.extract_key(last)
1764
* # find the value area
1765
* temp_ptr = <char*>_my_memrchr(self._start, c'\0', last - self._start) # <<<<<<<<<<<<<<
1766
* if temp_ptr == NULL:
1769
__pyx_v_temp_ptr = ((char *)__pyx_f_6bzrlib_21_btree_serializer_pyx__my_memrchr(__pyx_v_self->_start, '\x00', (__pyx_v_last - __pyx_v_self->_start)));
1771
/* "bzrlib/_btree_serializer_pyx.pyx":242
1772
* # find the value area
1773
* temp_ptr = <char*>_my_memrchr(self._start, c'\0', last - self._start)
1774
* if temp_ptr == NULL: # <<<<<<<<<<<<<<
1776
* raise AssertionError("Failed to find the value area")
1778
__pyx_t_1 = (__pyx_v_temp_ptr == NULL);
1781
/* "bzrlib/_btree_serializer_pyx.pyx":244
1782
* if temp_ptr == NULL:
1784
* raise AssertionError("Failed to find the value area") # <<<<<<<<<<<<<<
1786
* # Because of how conversions were done, we ended up with *lots* of
1788
__pyx_t_3 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1789
__Pyx_GOTREF(__pyx_t_3);
1790
__Pyx_Raise(__pyx_t_3, 0, 0);
1791
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1792
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1797
/* "bzrlib/_btree_serializer_pyx.pyx":252
1798
* # something like '12607215 328306 0 0', which ends up consuming 1MB
1799
* # of memory, just for those strings.
1800
* str_len = last - temp_ptr - 1 # <<<<<<<<<<<<<<
1802
* and strncmp(" 0 0", last - 4, 4) == 0):
1804
__pyx_v_str_len = ((__pyx_v_last - __pyx_v_temp_ptr) - 1);
1806
/* "bzrlib/_btree_serializer_pyx.pyx":253
1807
* # of memory, just for those strings.
1808
* str_len = last - temp_ptr - 1
1809
* if (str_len > 4 # <<<<<<<<<<<<<<
1810
* and strncmp(" 0 0", last - 4, 4) == 0):
1811
* # This drops peak mem for bzr.dev from 87.4MB => 86.2MB
1813
__pyx_t_1 = (__pyx_v_str_len > 4);
1816
/* "bzrlib/_btree_serializer_pyx.pyx":254
1817
* str_len = last - temp_ptr - 1
1819
* and strncmp(" 0 0", last - 4, 4) == 0): # <<<<<<<<<<<<<<
1820
* # This drops peak mem for bzr.dev from 87.4MB => 86.2MB
1821
* # For Launchpad 236MB => 232MB
1823
__pyx_t_4 = (strncmp(__pyx_k_10, (__pyx_v_last - 4), 4) == 0);
1824
__pyx_t_5 = __pyx_t_4;
1826
__pyx_t_5 = __pyx_t_1;
1830
/* "bzrlib/_btree_serializer_pyx.pyx":257
1831
* # This drops peak mem for bzr.dev from 87.4MB => 86.2MB
1832
* # For Launchpad 236MB => 232MB
1833
* value = safe_interned_string_from_size(temp_ptr + 1, str_len) # <<<<<<<<<<<<<<
1835
* value = safe_string_from_size(temp_ptr + 1, str_len)
1837
__pyx_t_3 = __pyx_f_6bzrlib_21_btree_serializer_pyx_safe_interned_string_from_size((__pyx_v_temp_ptr + 1), __pyx_v_str_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1838
__Pyx_GOTREF(__pyx_t_3);
1839
__Pyx_DECREF(__pyx_v_value);
1840
__pyx_v_value = __pyx_t_3;
1846
/* "bzrlib/_btree_serializer_pyx.pyx":259
1847
* value = safe_interned_string_from_size(temp_ptr + 1, str_len)
1849
* value = safe_string_from_size(temp_ptr + 1, str_len) # <<<<<<<<<<<<<<
1850
* # shrink the references end point
1853
__pyx_t_3 = __pyx_f_6bzrlib_21_btree_serializer_pyx_safe_string_from_size((__pyx_v_temp_ptr + 1), __pyx_v_str_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1854
__Pyx_GOTREF(__pyx_t_3);
1855
__Pyx_DECREF(__pyx_v_value);
1856
__pyx_v_value = __pyx_t_3;
1861
/* "bzrlib/_btree_serializer_pyx.pyx":261
1862
* value = safe_string_from_size(temp_ptr + 1, str_len)
1863
* # shrink the references end point
1864
* last = temp_ptr # <<<<<<<<<<<<<<
1866
* if self.ref_list_length:
1868
__pyx_v_last = __pyx_v_temp_ptr;
1872
/* "bzrlib/_btree_serializer_pyx.pyx":263
1875
* if self.ref_list_length: # <<<<<<<<<<<<<<
1876
* ref_lists = StaticTuple_New(self.ref_list_length)
1879
if (__pyx_v_self->ref_list_length) {
1881
/* "bzrlib/_btree_serializer_pyx.pyx":264
1883
* if self.ref_list_length:
1884
* ref_lists = StaticTuple_New(self.ref_list_length) # <<<<<<<<<<<<<<
1886
* while loop_counter < self.ref_list_length:
1888
__pyx_t_3 = ((PyObject *)StaticTuple_New(__pyx_v_self->ref_list_length)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1889
__Pyx_GOTREF(__pyx_t_3);
1890
__Pyx_DECREF(((PyObject *)__pyx_v_ref_lists));
1891
__pyx_v_ref_lists = ((StaticTuple *)__pyx_t_3);
1894
/* "bzrlib/_btree_serializer_pyx.pyx":265
1895
* if self.ref_list_length:
1896
* ref_lists = StaticTuple_New(self.ref_list_length)
1897
* loop_counter = 0 # <<<<<<<<<<<<<<
1898
* while loop_counter < self.ref_list_length:
1901
__pyx_v_loop_counter = 0;
1903
/* "bzrlib/_btree_serializer_pyx.pyx":266
1904
* ref_lists = StaticTuple_New(self.ref_list_length)
1906
* while loop_counter < self.ref_list_length: # <<<<<<<<<<<<<<
1908
* # extract a reference list
1911
__pyx_t_5 = (__pyx_v_loop_counter < __pyx_v_self->ref_list_length);
1912
if (!__pyx_t_5) break;
1914
/* "bzrlib/_btree_serializer_pyx.pyx":267
1916
* while loop_counter < self.ref_list_length:
1917
* ref_list = [] # <<<<<<<<<<<<<<
1918
* # extract a reference list
1919
* loop_counter = loop_counter + 1
1921
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1922
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
1923
__Pyx_DECREF(__pyx_v_ref_list);
1924
__pyx_v_ref_list = ((PyObject *)__pyx_t_3);
1927
/* "bzrlib/_btree_serializer_pyx.pyx":269
1929
* # extract a reference list
1930
* loop_counter = loop_counter + 1 # <<<<<<<<<<<<<<
1931
* if last < self._start:
1932
* raise AssertionError("last < self._start")
1934
__pyx_v_loop_counter = (__pyx_v_loop_counter + 1);
1936
/* "bzrlib/_btree_serializer_pyx.pyx":270
1937
* # extract a reference list
1938
* loop_counter = loop_counter + 1
1939
* if last < self._start: # <<<<<<<<<<<<<<
1940
* raise AssertionError("last < self._start")
1941
* # find the next reference list end point:
1943
__pyx_t_5 = (__pyx_v_last < __pyx_v_self->_start);
1946
/* "bzrlib/_btree_serializer_pyx.pyx":271
1947
* loop_counter = loop_counter + 1
1948
* if last < self._start:
1949
* raise AssertionError("last < self._start") # <<<<<<<<<<<<<<
1950
* # find the next reference list end point:
1951
* temp_ptr = <char*>memchr(self._start, c'\t', last - self._start)
1953
__pyx_t_3 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1954
__Pyx_GOTREF(__pyx_t_3);
1955
__Pyx_Raise(__pyx_t_3, 0, 0);
1956
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1957
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1962
/* "bzrlib/_btree_serializer_pyx.pyx":273
1963
* raise AssertionError("last < self._start")
1964
* # find the next reference list end point:
1965
* temp_ptr = <char*>memchr(self._start, c'\t', last - self._start) # <<<<<<<<<<<<<<
1966
* if temp_ptr == NULL:
1967
* # Only valid for the last list
1969
__pyx_v_temp_ptr = ((char *)memchr(__pyx_v_self->_start, '\t', (__pyx_v_last - __pyx_v_self->_start)));
1971
/* "bzrlib/_btree_serializer_pyx.pyx":274
1972
* # find the next reference list end point:
1973
* temp_ptr = <char*>memchr(self._start, c'\t', last - self._start)
1974
* if temp_ptr == NULL: # <<<<<<<<<<<<<<
1975
* # Only valid for the last list
1976
* if loop_counter != self.ref_list_length:
1978
__pyx_t_5 = (__pyx_v_temp_ptr == NULL);
1981
/* "bzrlib/_btree_serializer_pyx.pyx":276
1982
* if temp_ptr == NULL:
1983
* # Only valid for the last list
1984
* if loop_counter != self.ref_list_length: # <<<<<<<<<<<<<<
1986
* raise AssertionError(
1988
__pyx_t_5 = (__pyx_v_loop_counter != __pyx_v_self->ref_list_length);
1991
/* "bzrlib/_btree_serializer_pyx.pyx":278
1992
* if loop_counter != self.ref_list_length:
1994
* raise AssertionError( # <<<<<<<<<<<<<<
1995
* "invalid key, loop_counter != self.ref_list_length")
1998
__pyx_t_3 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1999
__Pyx_GOTREF(__pyx_t_3);
2000
__Pyx_Raise(__pyx_t_3, 0, 0);
2001
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2002
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2007
/* "bzrlib/_btree_serializer_pyx.pyx":282
2009
* # scan to the end of the ref list area
2010
* ref_ptr = last # <<<<<<<<<<<<<<
2014
__pyx_v_ref_ptr = __pyx_v_last;
2016
/* "bzrlib/_btree_serializer_pyx.pyx":283
2017
* # scan to the end of the ref list area
2019
* next_start = last # <<<<<<<<<<<<<<
2021
* # scan to the end of this ref list
2023
__pyx_v_next_start = __pyx_v_last;
2030
/* "bzrlib/_btree_serializer_pyx.pyx":286
2032
* # scan to the end of this ref list
2033
* ref_ptr = temp_ptr # <<<<<<<<<<<<<<
2034
* next_start = temp_ptr + 1
2035
* # Now, there may be multiple keys in the ref list.
2037
__pyx_v_ref_ptr = __pyx_v_temp_ptr;
2039
/* "bzrlib/_btree_serializer_pyx.pyx":287
2040
* # scan to the end of this ref list
2041
* ref_ptr = temp_ptr
2042
* next_start = temp_ptr + 1 # <<<<<<<<<<<<<<
2043
* # Now, there may be multiple keys in the ref list.
2044
* while self._start < ref_ptr:
2046
__pyx_v_next_start = (__pyx_v_temp_ptr + 1);
2050
/* "bzrlib/_btree_serializer_pyx.pyx":289
2051
* next_start = temp_ptr + 1
2052
* # Now, there may be multiple keys in the ref list.
2053
* while self._start < ref_ptr: # <<<<<<<<<<<<<<
2054
* # loop finding keys and extracting them
2055
* temp_ptr = <char*>memchr(self._start, c'\r',
2058
__pyx_t_5 = (__pyx_v_self->_start < __pyx_v_ref_ptr);
2059
if (!__pyx_t_5) break;
2061
/* "bzrlib/_btree_serializer_pyx.pyx":292
2062
* # loop finding keys and extracting them
2063
* temp_ptr = <char*>memchr(self._start, c'\r',
2064
* ref_ptr - self._start) # <<<<<<<<<<<<<<
2065
* if temp_ptr == NULL:
2066
* # key runs to the end
2068
__pyx_v_temp_ptr = ((char *)memchr(__pyx_v_self->_start, '\r', (__pyx_v_ref_ptr - __pyx_v_self->_start)));
2070
/* "bzrlib/_btree_serializer_pyx.pyx":293
2071
* temp_ptr = <char*>memchr(self._start, c'\r',
2072
* ref_ptr - self._start)
2073
* if temp_ptr == NULL: # <<<<<<<<<<<<<<
2074
* # key runs to the end
2075
* temp_ptr = ref_ptr
2077
__pyx_t_5 = (__pyx_v_temp_ptr == NULL);
2080
/* "bzrlib/_btree_serializer_pyx.pyx":295
2081
* if temp_ptr == NULL:
2082
* # key runs to the end
2083
* temp_ptr = ref_ptr # <<<<<<<<<<<<<<
2085
* PyList_Append(ref_list, self.extract_key(temp_ptr))
2087
__pyx_v_temp_ptr = __pyx_v_ref_ptr;
2092
/* "bzrlib/_btree_serializer_pyx.pyx":297
2093
* temp_ptr = ref_ptr
2095
* PyList_Append(ref_list, self.extract_key(temp_ptr)) # <<<<<<<<<<<<<<
2096
* ref_list = StaticTuple_Intern(StaticTuple(*ref_list))
2097
* Py_INCREF(ref_list)
2099
__pyx_t_3 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self->__pyx_vtab)->extract_key(__pyx_v_self, __pyx_v_temp_ptr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2100
__Pyx_GOTREF(__pyx_t_3);
2101
__pyx_t_6 = PyList_Append(__pyx_v_ref_list, __pyx_t_3); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2102
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2105
/* "bzrlib/_btree_serializer_pyx.pyx":298
2107
* PyList_Append(ref_list, self.extract_key(temp_ptr))
2108
* ref_list = StaticTuple_Intern(StaticTuple(*ref_list)) # <<<<<<<<<<<<<<
2109
* Py_INCREF(ref_list)
2110
* StaticTuple_SET_ITEM(ref_lists, loop_counter - 1, ref_list)
2112
__pyx_t_3 = PySequence_Tuple(__pyx_v_ref_list); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2113
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
2114
__pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2115
__Pyx_GOTREF(__pyx_t_2);
2116
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
2117
__pyx_t_3 = ((PyObject *)StaticTuple_Intern(((StaticTuple *)__pyx_t_2))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2118
__Pyx_GOTREF(__pyx_t_3);
2119
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2120
__Pyx_DECREF(__pyx_v_ref_list);
2121
__pyx_v_ref_list = __pyx_t_3;
2124
/* "bzrlib/_btree_serializer_pyx.pyx":299
2125
* PyList_Append(ref_list, self.extract_key(temp_ptr))
2126
* ref_list = StaticTuple_Intern(StaticTuple(*ref_list))
2127
* Py_INCREF(ref_list) # <<<<<<<<<<<<<<
2128
* StaticTuple_SET_ITEM(ref_lists, loop_counter - 1, ref_list)
2129
* # prepare for the next reference list
2131
Py_INCREF(__pyx_v_ref_list);
2133
/* "bzrlib/_btree_serializer_pyx.pyx":300
2134
* ref_list = StaticTuple_Intern(StaticTuple(*ref_list))
2135
* Py_INCREF(ref_list)
2136
* StaticTuple_SET_ITEM(ref_lists, loop_counter - 1, ref_list) # <<<<<<<<<<<<<<
2137
* # prepare for the next reference list
2138
* self._start = next_start
2140
StaticTuple_SET_ITEM(__pyx_v_ref_lists, (__pyx_v_loop_counter - 1), __pyx_v_ref_list);
2142
/* "bzrlib/_btree_serializer_pyx.pyx":302
2143
* StaticTuple_SET_ITEM(ref_lists, loop_counter - 1, ref_list)
2144
* # prepare for the next reference list
2145
* self._start = next_start # <<<<<<<<<<<<<<
2146
* node_value = StaticTuple(value, ref_lists)
2149
__pyx_v_self->_start = __pyx_v_next_start;
2152
/* "bzrlib/_btree_serializer_pyx.pyx":303
2153
* # prepare for the next reference list
2154
* self._start = next_start
2155
* node_value = StaticTuple(value, ref_lists) # <<<<<<<<<<<<<<
2157
* if last != self._start:
2159
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2160
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
2161
__Pyx_INCREF(__pyx_v_value);
2162
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value);
2163
__Pyx_GIVEREF(__pyx_v_value);
2164
__Pyx_INCREF(((PyObject *)__pyx_v_ref_lists));
2165
PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_ref_lists));
2166
__Pyx_GIVEREF(((PyObject *)__pyx_v_ref_lists));
2167
__pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2168
__Pyx_GOTREF(__pyx_t_2);
2169
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
2170
__Pyx_DECREF(((PyObject *)__pyx_v_node_value));
2171
__pyx_v_node_value = ((StaticTuple *)__pyx_t_2);
2177
/* "bzrlib/_btree_serializer_pyx.pyx":305
2178
* node_value = StaticTuple(value, ref_lists)
2180
* if last != self._start: # <<<<<<<<<<<<<<
2181
* # unexpected reference data present
2182
* raise AssertionError("unexpected reference data present")
2184
__pyx_t_5 = (__pyx_v_last != __pyx_v_self->_start);
2187
/* "bzrlib/_btree_serializer_pyx.pyx":307
2188
* if last != self._start:
2189
* # unexpected reference data present
2190
* raise AssertionError("unexpected reference data present") # <<<<<<<<<<<<<<
2191
* node_value = StaticTuple(value, StaticTuple())
2192
* PyList_Append(self.keys, StaticTuple(key, node_value))
2194
__pyx_t_2 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2195
__Pyx_GOTREF(__pyx_t_2);
2196
__Pyx_Raise(__pyx_t_2, 0, 0);
2197
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2198
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2203
/* "bzrlib/_btree_serializer_pyx.pyx":308
2204
* # unexpected reference data present
2205
* raise AssertionError("unexpected reference data present")
2206
* node_value = StaticTuple(value, StaticTuple()) # <<<<<<<<<<<<<<
2207
* PyList_Append(self.keys, StaticTuple(key, node_value))
2210
__pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2211
__Pyx_GOTREF(__pyx_t_2);
2212
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2213
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
2214
__Pyx_INCREF(__pyx_v_value);
2215
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value);
2216
__Pyx_GIVEREF(__pyx_v_value);
2217
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
2218
__Pyx_GIVEREF(__pyx_t_2);
2220
__pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2221
__Pyx_GOTREF(__pyx_t_2);
2222
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
2223
__Pyx_DECREF(((PyObject *)__pyx_v_node_value));
2224
__pyx_v_node_value = ((StaticTuple *)__pyx_t_2);
2229
/* "bzrlib/_btree_serializer_pyx.pyx":309
2230
* raise AssertionError("unexpected reference data present")
2231
* node_value = StaticTuple(value, StaticTuple())
2232
* PyList_Append(self.keys, StaticTuple(key, node_value)) # <<<<<<<<<<<<<<
2236
__pyx_t_2 = __pyx_v_self->keys;
2237
__Pyx_INCREF(__pyx_t_2);
2238
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2239
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
2240
__Pyx_INCREF(__pyx_v_key);
2241
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_key);
2242
__Pyx_GIVEREF(__pyx_v_key);
2243
__Pyx_INCREF(((PyObject *)__pyx_v_node_value));
2244
PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_node_value));
2245
__Pyx_GIVEREF(((PyObject *)__pyx_v_node_value));
2246
__pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2247
__Pyx_GOTREF(__pyx_t_7);
2248
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
2249
__pyx_t_6 = PyList_Append(__pyx_t_2, __pyx_t_7); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2250
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2251
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2253
/* "bzrlib/_btree_serializer_pyx.pyx":310
2254
* node_value = StaticTuple(value, StaticTuple())
2255
* PyList_Append(self.keys, StaticTuple(key, node_value))
2256
* return 0 # <<<<<<<<<<<<<<
2266
__Pyx_XDECREF(__pyx_t_2);
2267
__Pyx_XDECREF(__pyx_t_3);
2268
__Pyx_XDECREF(__pyx_t_7);
2269
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.BTreeLeafParser.process_line");
2272
__Pyx_DECREF(__pyx_v_key);
2273
__Pyx_DECREF(__pyx_v_value);
2274
__Pyx_DECREF((PyObject *)__pyx_v_ref_lists);
2275
__Pyx_DECREF(__pyx_v_ref_list);
2276
__Pyx_DECREF((PyObject *)__pyx_v_node_value);
2277
__Pyx_RefNannyFinishContext();
2281
/* "bzrlib/_btree_serializer_pyx.pyx":312
2284
* def parse(self): # <<<<<<<<<<<<<<
2285
* cdef Py_ssize_t byte_count
2286
* if not PyString_CheckExact(self.bytes):
2289
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser_1parse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
2290
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser_1parse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
2291
Py_ssize_t __pyx_v_byte_count;
2292
PyObject *__pyx_r = NULL;
2293
PyObject *__pyx_t_1 = NULL;
2297
__Pyx_RefNannySetupContext("parse");
2299
/* "bzrlib/_btree_serializer_pyx.pyx":314
2301
* cdef Py_ssize_t byte_count
2302
* if not PyString_CheckExact(self.bytes): # <<<<<<<<<<<<<<
2303
* raise AssertionError('self.bytes is not a string.')
2304
* byte_count = PyString_Size(self.bytes)
2306
__pyx_t_1 = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->bytes;
2307
__Pyx_INCREF(__pyx_t_1);
2308
__pyx_t_2 = (!PyString_CheckExact(__pyx_t_1));
2309
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2312
/* "bzrlib/_btree_serializer_pyx.pyx":315
2313
* cdef Py_ssize_t byte_count
2314
* if not PyString_CheckExact(self.bytes):
2315
* raise AssertionError('self.bytes is not a string.') # <<<<<<<<<<<<<<
2316
* byte_count = PyString_Size(self.bytes)
2317
* self._cur_str = PyString_AsString(self.bytes)
2319
__pyx_t_1 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2320
__Pyx_GOTREF(__pyx_t_1);
2321
__Pyx_Raise(__pyx_t_1, 0, 0);
2322
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2323
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2328
/* "bzrlib/_btree_serializer_pyx.pyx":316
2329
* if not PyString_CheckExact(self.bytes):
2330
* raise AssertionError('self.bytes is not a string.')
2331
* byte_count = PyString_Size(self.bytes) # <<<<<<<<<<<<<<
2332
* self._cur_str = PyString_AsString(self.bytes)
2333
* # This points to the last character in the string
2335
__pyx_t_1 = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->bytes;
2336
__Pyx_INCREF(__pyx_t_1);
2337
__pyx_v_byte_count = PyString_Size(__pyx_t_1);
2338
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2340
/* "bzrlib/_btree_serializer_pyx.pyx":317
2341
* raise AssertionError('self.bytes is not a string.')
2342
* byte_count = PyString_Size(self.bytes)
2343
* self._cur_str = PyString_AsString(self.bytes) # <<<<<<<<<<<<<<
2344
* # This points to the last character in the string
2345
* self._end_str = self._cur_str + byte_count
2347
__pyx_t_1 = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->bytes;
2348
__Pyx_INCREF(__pyx_t_1);
2349
__pyx_t_3 = PyString_AsString(__pyx_t_1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2350
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2351
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->_cur_str = __pyx_t_3;
2353
/* "bzrlib/_btree_serializer_pyx.pyx":319
2354
* self._cur_str = PyString_AsString(self.bytes)
2355
* # This points to the last character in the string
2356
* self._end_str = self._cur_str + byte_count # <<<<<<<<<<<<<<
2357
* while self._cur_str < self._end_str:
2358
* self.process_line()
2360
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->_end_str = (((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->_cur_str + __pyx_v_byte_count);
2362
/* "bzrlib/_btree_serializer_pyx.pyx":320
2363
* # This points to the last character in the string
2364
* self._end_str = self._cur_str + byte_count
2365
* while self._cur_str < self._end_str: # <<<<<<<<<<<<<<
2366
* self.process_line()
2370
__pyx_t_2 = (((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->_cur_str < ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->_end_str);
2371
if (!__pyx_t_2) break;
2373
/* "bzrlib/_btree_serializer_pyx.pyx":321
2374
* self._end_str = self._cur_str + byte_count
2375
* while self._cur_str < self._end_str:
2376
* self.process_line() # <<<<<<<<<<<<<<
2380
__pyx_t_4 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->__pyx_vtab)->process_line(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2383
/* "bzrlib/_btree_serializer_pyx.pyx":322
2384
* while self._cur_str < self._end_str:
2385
* self.process_line()
2386
* return self.keys # <<<<<<<<<<<<<<
2390
__Pyx_XDECREF(__pyx_r);
2391
__Pyx_INCREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->keys);
2392
__pyx_r = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self)->keys;
2395
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
2398
__Pyx_XDECREF(__pyx_t_1);
2399
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.BTreeLeafParser.parse");
2402
__Pyx_XGIVEREF(__pyx_r);
2403
__Pyx_RefNannyFinishContext();
2407
/* "bzrlib/_btree_serializer_pyx.pyx":325
2410
* def _parse_leaf_lines(bytes, key_length, ref_list_length): # <<<<<<<<<<<<<<
2411
* parser = BTreeLeafParser(bytes, key_length, ref_list_length)
2412
* return parser.parse()
2415
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx__parse_leaf_lines(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2416
static PyMethodDef __pyx_mdef_6bzrlib_21_btree_serializer_pyx__parse_leaf_lines = {__Pyx_NAMESTR("_parse_leaf_lines"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx__parse_leaf_lines, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
2417
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx__parse_leaf_lines(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2418
PyObject *__pyx_v_bytes = 0;
2419
PyObject *__pyx_v_key_length = 0;
2420
PyObject *__pyx_v_ref_list_length = 0;
2421
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_parser;
2422
PyObject *__pyx_r = NULL;
2423
PyObject *__pyx_t_1 = NULL;
2424
PyObject *__pyx_t_2 = NULL;
2425
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bytes,&__pyx_n_s__key_length,&__pyx_n_s__ref_list_length,0};
2426
__Pyx_RefNannySetupContext("_parse_leaf_lines");
2427
__pyx_self = __pyx_self;
2428
if (unlikely(__pyx_kwds)) {
2429
Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
2430
PyObject* values[3] = {0,0,0};
2431
switch (PyTuple_GET_SIZE(__pyx_args)) {
2432
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2433
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2434
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2436
default: goto __pyx_L5_argtuple_error;
2438
switch (PyTuple_GET_SIZE(__pyx_args)) {
2440
values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bytes);
2441
if (likely(values[0])) kw_args--;
2442
else goto __pyx_L5_argtuple_error;
2444
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key_length);
2445
if (likely(values[1])) kw_args--;
2447
__Pyx_RaiseArgtupleInvalid("_parse_leaf_lines", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2450
values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref_list_length);
2451
if (likely(values[2])) kw_args--;
2453
__Pyx_RaiseArgtupleInvalid("_parse_leaf_lines", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2456
if (unlikely(kw_args > 0)) {
2457
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parse_leaf_lines") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2459
__pyx_v_bytes = values[0];
2460
__pyx_v_key_length = values[1];
2461
__pyx_v_ref_list_length = values[2];
2462
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
2463
goto __pyx_L5_argtuple_error;
2465
__pyx_v_bytes = PyTuple_GET_ITEM(__pyx_args, 0);
2466
__pyx_v_key_length = PyTuple_GET_ITEM(__pyx_args, 1);
2467
__pyx_v_ref_list_length = PyTuple_GET_ITEM(__pyx_args, 2);
2469
goto __pyx_L4_argument_unpacking_done;
2470
__pyx_L5_argtuple_error:;
2471
__Pyx_RaiseArgtupleInvalid("_parse_leaf_lines", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2473
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._parse_leaf_lines");
2474
__Pyx_RefNannyFinishContext();
2476
__pyx_L4_argument_unpacking_done:;
2477
__pyx_v_parser = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)Py_None); __Pyx_INCREF(Py_None);
2479
/* "bzrlib/_btree_serializer_pyx.pyx":326
2481
* def _parse_leaf_lines(bytes, key_length, ref_list_length):
2482
* parser = BTreeLeafParser(bytes, key_length, ref_list_length) # <<<<<<<<<<<<<<
2483
* return parser.parse()
2486
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2487
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
2488
__Pyx_INCREF(__pyx_v_bytes);
2489
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_bytes);
2490
__Pyx_GIVEREF(__pyx_v_bytes);
2491
__Pyx_INCREF(__pyx_v_key_length);
2492
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_key_length);
2493
__Pyx_GIVEREF(__pyx_v_key_length);
2494
__Pyx_INCREF(__pyx_v_ref_list_length);
2495
PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_ref_list_length);
2496
__Pyx_GIVEREF(__pyx_v_ref_list_length);
2497
__pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2498
__Pyx_GOTREF(__pyx_t_2);
2499
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
2500
__Pyx_DECREF(((PyObject *)__pyx_v_parser));
2501
__pyx_v_parser = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_t_2);
2504
/* "bzrlib/_btree_serializer_pyx.pyx":327
2505
* def _parse_leaf_lines(bytes, key_length, ref_list_length):
2506
* parser = BTreeLeafParser(bytes, key_length, ref_list_length)
2507
* return parser.parse() # <<<<<<<<<<<<<<
2511
__Pyx_XDECREF(__pyx_r);
2512
__pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_parser), __pyx_n_s__parse); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2513
__Pyx_GOTREF(__pyx_t_2);
2514
__pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2515
__Pyx_GOTREF(__pyx_t_1);
2516
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2517
__pyx_r = __pyx_t_1;
2521
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
2524
__Pyx_XDECREF(__pyx_t_1);
2525
__Pyx_XDECREF(__pyx_t_2);
2526
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._parse_leaf_lines");
2529
__Pyx_DECREF((PyObject *)__pyx_v_parser);
2530
__Pyx_XGIVEREF(__pyx_r);
2531
__Pyx_RefNannyFinishContext();
2535
/* "bzrlib/_btree_serializer_pyx.pyx":349
2536
* _hexbuf = '0123456789abcdef'
2538
* cdef _populate_unhexbuf(): # <<<<<<<<<<<<<<
2540
* for i from 0 <= i < 256:
2543
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx__populate_unhexbuf(void) {
2545
PyObject *__pyx_r = NULL;
2546
__Pyx_RefNannySetupContext("_populate_unhexbuf");
2548
/* "bzrlib/_btree_serializer_pyx.pyx":351
2549
* cdef _populate_unhexbuf():
2551
* for i from 0 <= i < 256: # <<<<<<<<<<<<<<
2553
* for i from 0 <= i < 10: # 0123456789 => map to the raw number
2555
for (__pyx_v_i = 0; __pyx_v_i < 256; __pyx_v_i++) {
2557
/* "bzrlib/_btree_serializer_pyx.pyx":352
2559
* for i from 0 <= i < 256:
2560
* _unhexbuf[i] = -1 # <<<<<<<<<<<<<<
2561
* for i from 0 <= i < 10: # 0123456789 => map to the raw number
2562
* _unhexbuf[(i + c'0')] = i
2564
(__pyx_v_6bzrlib_21_btree_serializer_pyx__unhexbuf[__pyx_v_i]) = -1;
2567
/* "bzrlib/_btree_serializer_pyx.pyx":353
2568
* for i from 0 <= i < 256:
2570
* for i from 0 <= i < 10: # 0123456789 => map to the raw number # <<<<<<<<<<<<<<
2571
* _unhexbuf[(i + c'0')] = i
2572
* for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16
2574
for (__pyx_v_i = 0; __pyx_v_i < 10; __pyx_v_i++) {
2576
/* "bzrlib/_btree_serializer_pyx.pyx":354
2578
* for i from 0 <= i < 10: # 0123456789 => map to the raw number
2579
* _unhexbuf[(i + c'0')] = i # <<<<<<<<<<<<<<
2580
* for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16
2581
* _unhexbuf[(i - 10 + c'a')] = i
2583
(__pyx_v_6bzrlib_21_btree_serializer_pyx__unhexbuf[(__pyx_v_i + '0')]) = __pyx_v_i;
2586
/* "bzrlib/_btree_serializer_pyx.pyx":355
2587
* for i from 0 <= i < 10: # 0123456789 => map to the raw number
2588
* _unhexbuf[(i + c'0')] = i
2589
* for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16 # <<<<<<<<<<<<<<
2590
* _unhexbuf[(i - 10 + c'a')] = i
2591
* for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16
2593
for (__pyx_v_i = 10; __pyx_v_i < 16; __pyx_v_i++) {
2595
/* "bzrlib/_btree_serializer_pyx.pyx":356
2596
* _unhexbuf[(i + c'0')] = i
2597
* for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16
2598
* _unhexbuf[(i - 10 + c'a')] = i # <<<<<<<<<<<<<<
2599
* for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16
2600
* _unhexbuf[(i - 10 + c'A')] = i
2602
(__pyx_v_6bzrlib_21_btree_serializer_pyx__unhexbuf[((__pyx_v_i - 10) + 'a')]) = __pyx_v_i;
2605
/* "bzrlib/_btree_serializer_pyx.pyx":357
2606
* for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16
2607
* _unhexbuf[(i - 10 + c'a')] = i
2608
* for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16 # <<<<<<<<<<<<<<
2609
* _unhexbuf[(i - 10 + c'A')] = i
2610
* _populate_unhexbuf()
2612
for (__pyx_v_i = 10; __pyx_v_i < 16; __pyx_v_i++) {
2614
/* "bzrlib/_btree_serializer_pyx.pyx":358
2615
* _unhexbuf[(i - 10 + c'a')] = i
2616
* for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16
2617
* _unhexbuf[(i - 10 + c'A')] = i # <<<<<<<<<<<<<<
2618
* _populate_unhexbuf()
2621
(__pyx_v_6bzrlib_21_btree_serializer_pyx__unhexbuf[((__pyx_v_i - 10) + 'A')]) = __pyx_v_i;
2624
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
2625
__Pyx_XGIVEREF(__pyx_r);
2626
__Pyx_RefNannyFinishContext();
2630
/* "bzrlib/_btree_serializer_pyx.pyx":362
2633
* cdef int _unhexlify_sha1(char *as_hex, char *as_bin): # cannot_raise # <<<<<<<<<<<<<<
2634
* """Take the hex sha1 in as_hex and make it binary in as_bin
2638
static int __pyx_f_6bzrlib_21_btree_serializer_pyx__unhexlify_sha1(char *__pyx_v_as_hex, char *__pyx_v_as_bin) {
2647
__Pyx_RefNannySetupContext("_unhexlify_sha1");
2649
/* "bzrlib/_btree_serializer_pyx.pyx":374
2650
* # binascii does this using isupper() and tolower() and ?: syntax. I'm
2651
* # guessing a simple lookup array should be faster.
2652
* j = 0 # <<<<<<<<<<<<<<
2653
* for i from 0 <= i < 20:
2654
* top = _unhexbuf[<unsigned char>(as_hex[j])]
2658
/* "bzrlib/_btree_serializer_pyx.pyx":375
2659
* # guessing a simple lookup array should be faster.
2661
* for i from 0 <= i < 20: # <<<<<<<<<<<<<<
2662
* top = _unhexbuf[<unsigned char>(as_hex[j])]
2665
for (__pyx_v_i = 0; __pyx_v_i < 20; __pyx_v_i++) {
2667
/* "bzrlib/_btree_serializer_pyx.pyx":376
2669
* for i from 0 <= i < 20:
2670
* top = _unhexbuf[<unsigned char>(as_hex[j])] # <<<<<<<<<<<<<<
2672
* bot = _unhexbuf[<unsigned char>(as_hex[j])]
2674
__pyx_v_top = (__pyx_v_6bzrlib_21_btree_serializer_pyx__unhexbuf[((unsigned char)(__pyx_v_as_hex[__pyx_v_j]))]);
2676
/* "bzrlib/_btree_serializer_pyx.pyx":377
2677
* for i from 0 <= i < 20:
2678
* top = _unhexbuf[<unsigned char>(as_hex[j])]
2679
* j = j + 1 # <<<<<<<<<<<<<<
2680
* bot = _unhexbuf[<unsigned char>(as_hex[j])]
2683
__pyx_v_j = (__pyx_v_j + 1);
2685
/* "bzrlib/_btree_serializer_pyx.pyx":378
2686
* top = _unhexbuf[<unsigned char>(as_hex[j])]
2688
* bot = _unhexbuf[<unsigned char>(as_hex[j])] # <<<<<<<<<<<<<<
2690
* if top == -1 or bot == -1:
2692
__pyx_v_bot = (__pyx_v_6bzrlib_21_btree_serializer_pyx__unhexbuf[((unsigned char)(__pyx_v_as_hex[__pyx_v_j]))]);
2694
/* "bzrlib/_btree_serializer_pyx.pyx":379
2696
* bot = _unhexbuf[<unsigned char>(as_hex[j])]
2697
* j = j + 1 # <<<<<<<<<<<<<<
2698
* if top == -1 or bot == -1:
2701
__pyx_v_j = (__pyx_v_j + 1);
2703
/* "bzrlib/_btree_serializer_pyx.pyx":380
2704
* bot = _unhexbuf[<unsigned char>(as_hex[j])]
2706
* if top == -1 or bot == -1: # <<<<<<<<<<<<<<
2708
* as_bin[i] = <unsigned char>((top << 4) + bot);
2710
__pyx_t_1 = (__pyx_v_top == -1);
2712
__pyx_t_2 = (__pyx_v_bot == -1);
2713
__pyx_t_3 = __pyx_t_2;
2715
__pyx_t_3 = __pyx_t_1;
2719
/* "bzrlib/_btree_serializer_pyx.pyx":381
2721
* if top == -1 or bot == -1:
2722
* return 0 # <<<<<<<<<<<<<<
2723
* as_bin[i] = <unsigned char>((top << 4) + bot);
2732
/* "bzrlib/_btree_serializer_pyx.pyx":382
2733
* if top == -1 or bot == -1:
2735
* as_bin[i] = <unsigned char>((top << 4) + bot); # <<<<<<<<<<<<<<
2739
(__pyx_v_as_bin[__pyx_v_i]) = ((unsigned char)((__pyx_v_top << 4) + __pyx_v_bot));
2742
/* "bzrlib/_btree_serializer_pyx.pyx":383
2744
* as_bin[i] = <unsigned char>((top << 4) + bot);
2745
* return 1 # <<<<<<<<<<<<<<
2754
__Pyx_RefNannyFinishContext();
2758
/* "bzrlib/_btree_serializer_pyx.pyx":386
2761
* def _py_unhexlify(as_hex): # <<<<<<<<<<<<<<
2762
* """For the test infrastructure, just thunks to _unhexlify_sha1"""
2763
* if len(as_hex) != 40 or not PyString_CheckExact(as_hex):
2766
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_1_py_unhexlify(PyObject *__pyx_self, PyObject *__pyx_v_as_hex); /*proto*/
2767
static char __pyx_doc_6bzrlib_21_btree_serializer_pyx_1_py_unhexlify[] = "For the test infrastructure, just thunks to _unhexlify_sha1";
2768
static PyMethodDef __pyx_mdef_6bzrlib_21_btree_serializer_pyx_1_py_unhexlify = {__Pyx_NAMESTR("_py_unhexlify"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_1_py_unhexlify, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_21_btree_serializer_pyx_1_py_unhexlify)};
2769
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_1_py_unhexlify(PyObject *__pyx_self, PyObject *__pyx_v_as_hex) {
2770
PyObject *__pyx_v_as_bin;
2771
PyObject *__pyx_r = NULL;
2772
Py_ssize_t __pyx_t_1;
2776
PyObject *__pyx_t_5 = NULL;
2778
__Pyx_RefNannySetupContext("_py_unhexlify");
2779
__pyx_self = __pyx_self;
2780
__pyx_v_as_bin = Py_None; __Pyx_INCREF(Py_None);
2782
/* "bzrlib/_btree_serializer_pyx.pyx":388
2783
* def _py_unhexlify(as_hex):
2784
* """For the test infrastructure, just thunks to _unhexlify_sha1"""
2785
* if len(as_hex) != 40 or not PyString_CheckExact(as_hex): # <<<<<<<<<<<<<<
2786
* raise ValueError('not a 40-byte hex digest')
2787
* as_bin = PyString_FromStringAndSize(NULL, 20)
2789
__pyx_t_1 = PyObject_Length(__pyx_v_as_hex); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2790
__pyx_t_2 = (__pyx_t_1 != 40);
2792
__pyx_t_3 = (!PyString_CheckExact(__pyx_v_as_hex));
2793
__pyx_t_4 = __pyx_t_3;
2795
__pyx_t_4 = __pyx_t_2;
2799
/* "bzrlib/_btree_serializer_pyx.pyx":389
2800
* """For the test infrastructure, just thunks to _unhexlify_sha1"""
2801
* if len(as_hex) != 40 or not PyString_CheckExact(as_hex):
2802
* raise ValueError('not a 40-byte hex digest') # <<<<<<<<<<<<<<
2803
* as_bin = PyString_FromStringAndSize(NULL, 20)
2804
* if _unhexlify_sha1(PyString_AS_STRING(as_hex), PyString_AS_STRING(as_bin)):
2806
__pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2807
__Pyx_GOTREF(__pyx_t_5);
2808
__Pyx_Raise(__pyx_t_5, 0, 0);
2809
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2810
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2815
/* "bzrlib/_btree_serializer_pyx.pyx":390
2816
* if len(as_hex) != 40 or not PyString_CheckExact(as_hex):
2817
* raise ValueError('not a 40-byte hex digest')
2818
* as_bin = PyString_FromStringAndSize(NULL, 20) # <<<<<<<<<<<<<<
2819
* if _unhexlify_sha1(PyString_AS_STRING(as_hex), PyString_AS_STRING(as_bin)):
2822
__pyx_t_5 = PyString_FromStringAndSize(NULL, 20); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2823
__Pyx_GOTREF(__pyx_t_5);
2824
__Pyx_DECREF(__pyx_v_as_bin);
2825
__pyx_v_as_bin = __pyx_t_5;
2828
/* "bzrlib/_btree_serializer_pyx.pyx":391
2829
* raise ValueError('not a 40-byte hex digest')
2830
* as_bin = PyString_FromStringAndSize(NULL, 20)
2831
* if _unhexlify_sha1(PyString_AS_STRING(as_hex), PyString_AS_STRING(as_bin)): # <<<<<<<<<<<<<<
2835
__pyx_t_6 = __pyx_f_6bzrlib_21_btree_serializer_pyx__unhexlify_sha1(PyString_AS_STRING(__pyx_v_as_hex), PyString_AS_STRING(__pyx_v_as_bin));
2838
/* "bzrlib/_btree_serializer_pyx.pyx":392
2839
* as_bin = PyString_FromStringAndSize(NULL, 20)
2840
* if _unhexlify_sha1(PyString_AS_STRING(as_hex), PyString_AS_STRING(as_bin)):
2841
* return as_bin # <<<<<<<<<<<<<<
2845
__Pyx_XDECREF(__pyx_r);
2846
__Pyx_INCREF(__pyx_v_as_bin);
2847
__pyx_r = __pyx_v_as_bin;
2853
/* "bzrlib/_btree_serializer_pyx.pyx":393
2854
* if _unhexlify_sha1(PyString_AS_STRING(as_hex), PyString_AS_STRING(as_bin)):
2856
* return None # <<<<<<<<<<<<<<
2860
__Pyx_XDECREF(__pyx_r);
2861
__Pyx_INCREF(Py_None);
2865
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
2868
__Pyx_XDECREF(__pyx_t_5);
2869
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._py_unhexlify");
2872
__Pyx_DECREF(__pyx_v_as_bin);
2873
__Pyx_XGIVEREF(__pyx_r);
2874
__Pyx_RefNannyFinishContext();
2878
/* "bzrlib/_btree_serializer_pyx.pyx":396
2881
* cdef void _hexlify_sha1(char *as_bin, char *as_hex): # cannot_raise # <<<<<<<<<<<<<<
2886
static void __pyx_f_6bzrlib_21_btree_serializer_pyx__hexlify_sha1(char *__pyx_v_as_bin, char *__pyx_v_as_hex) {
2890
__Pyx_RefNannySetupContext("_hexlify_sha1");
2892
/* "bzrlib/_btree_serializer_pyx.pyx":400
2895
* j = 0 # <<<<<<<<<<<<<<
2896
* for i from 0 <= i < 20:
2901
/* "bzrlib/_btree_serializer_pyx.pyx":401
2904
* for i from 0 <= i < 20: # <<<<<<<<<<<<<<
2906
* as_hex[j] = _hexbuf[(c>>4)&0xf]
2908
for (__pyx_v_i = 0; __pyx_v_i < 20; __pyx_v_i++) {
2910
/* "bzrlib/_btree_serializer_pyx.pyx":402
2912
* for i from 0 <= i < 20:
2913
* c = as_bin[i] # <<<<<<<<<<<<<<
2914
* as_hex[j] = _hexbuf[(c>>4)&0xf]
2917
__pyx_v_c = (__pyx_v_as_bin[__pyx_v_i]);
2919
/* "bzrlib/_btree_serializer_pyx.pyx":403
2920
* for i from 0 <= i < 20:
2922
* as_hex[j] = _hexbuf[(c>>4)&0xf] # <<<<<<<<<<<<<<
2924
* as_hex[j] = _hexbuf[(c)&0xf]
2926
(__pyx_v_as_hex[__pyx_v_j]) = (__pyx_v_6bzrlib_21_btree_serializer_pyx__hexbuf[((__pyx_v_c >> 4) & 0xf)]);
2928
/* "bzrlib/_btree_serializer_pyx.pyx":404
2930
* as_hex[j] = _hexbuf[(c>>4)&0xf]
2931
* j = j + 1 # <<<<<<<<<<<<<<
2932
* as_hex[j] = _hexbuf[(c)&0xf]
2935
__pyx_v_j = (__pyx_v_j + 1);
2937
/* "bzrlib/_btree_serializer_pyx.pyx":405
2938
* as_hex[j] = _hexbuf[(c>>4)&0xf]
2940
* as_hex[j] = _hexbuf[(c)&0xf] # <<<<<<<<<<<<<<
2944
(__pyx_v_as_hex[__pyx_v_j]) = (__pyx_v_6bzrlib_21_btree_serializer_pyx__hexbuf[(__pyx_v_c & 0xf)]);
2946
/* "bzrlib/_btree_serializer_pyx.pyx":406
2948
* as_hex[j] = _hexbuf[(c)&0xf]
2949
* j = j + 1 # <<<<<<<<<<<<<<
2953
__pyx_v_j = (__pyx_v_j + 1);
2956
__Pyx_RefNannyFinishContext();
2959
/* "bzrlib/_btree_serializer_pyx.pyx":409
2962
* def _py_hexlify(as_bin): # <<<<<<<<<<<<<<
2963
* """For test infrastructure, thunk to _hexlify_sha1"""
2964
* if len(as_bin) != 20 or not PyString_CheckExact(as_bin):
2967
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_2_py_hexlify(PyObject *__pyx_self, PyObject *__pyx_v_as_bin); /*proto*/
2968
static char __pyx_doc_6bzrlib_21_btree_serializer_pyx_2_py_hexlify[] = "For test infrastructure, thunk to _hexlify_sha1";
2969
static PyMethodDef __pyx_mdef_6bzrlib_21_btree_serializer_pyx_2_py_hexlify = {__Pyx_NAMESTR("_py_hexlify"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_2_py_hexlify, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_21_btree_serializer_pyx_2_py_hexlify)};
2970
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_2_py_hexlify(PyObject *__pyx_self, PyObject *__pyx_v_as_bin) {
2971
PyObject *__pyx_v_as_hex;
2972
PyObject *__pyx_r = NULL;
2973
Py_ssize_t __pyx_t_1;
2977
PyObject *__pyx_t_5 = NULL;
2978
__Pyx_RefNannySetupContext("_py_hexlify");
2979
__pyx_self = __pyx_self;
2980
__pyx_v_as_hex = Py_None; __Pyx_INCREF(Py_None);
2982
/* "bzrlib/_btree_serializer_pyx.pyx":411
2983
* def _py_hexlify(as_bin):
2984
* """For test infrastructure, thunk to _hexlify_sha1"""
2985
* if len(as_bin) != 20 or not PyString_CheckExact(as_bin): # <<<<<<<<<<<<<<
2986
* raise ValueError('not a 20-byte binary digest')
2987
* as_hex = PyString_FromStringAndSize(NULL, 40)
2989
__pyx_t_1 = PyObject_Length(__pyx_v_as_bin); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2990
__pyx_t_2 = (__pyx_t_1 != 20);
2992
__pyx_t_3 = (!PyString_CheckExact(__pyx_v_as_bin));
2993
__pyx_t_4 = __pyx_t_3;
2995
__pyx_t_4 = __pyx_t_2;
2999
/* "bzrlib/_btree_serializer_pyx.pyx":412
3000
* """For test infrastructure, thunk to _hexlify_sha1"""
3001
* if len(as_bin) != 20 or not PyString_CheckExact(as_bin):
3002
* raise ValueError('not a 20-byte binary digest') # <<<<<<<<<<<<<<
3003
* as_hex = PyString_FromStringAndSize(NULL, 40)
3004
* _hexlify_sha1(PyString_AS_STRING(as_bin), PyString_AS_STRING(as_hex))
3006
__pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3007
__Pyx_GOTREF(__pyx_t_5);
3008
__Pyx_Raise(__pyx_t_5, 0, 0);
3009
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3010
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3015
/* "bzrlib/_btree_serializer_pyx.pyx":413
3016
* if len(as_bin) != 20 or not PyString_CheckExact(as_bin):
3017
* raise ValueError('not a 20-byte binary digest')
3018
* as_hex = PyString_FromStringAndSize(NULL, 40) # <<<<<<<<<<<<<<
3019
* _hexlify_sha1(PyString_AS_STRING(as_bin), PyString_AS_STRING(as_hex))
3022
__pyx_t_5 = PyString_FromStringAndSize(NULL, 40); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3023
__Pyx_GOTREF(__pyx_t_5);
3024
__Pyx_DECREF(__pyx_v_as_hex);
3025
__pyx_v_as_hex = __pyx_t_5;
3028
/* "bzrlib/_btree_serializer_pyx.pyx":414
3029
* raise ValueError('not a 20-byte binary digest')
3030
* as_hex = PyString_FromStringAndSize(NULL, 40)
3031
* _hexlify_sha1(PyString_AS_STRING(as_bin), PyString_AS_STRING(as_hex)) # <<<<<<<<<<<<<<
3035
__pyx_f_6bzrlib_21_btree_serializer_pyx__hexlify_sha1(PyString_AS_STRING(__pyx_v_as_bin), PyString_AS_STRING(__pyx_v_as_hex));
3037
/* "bzrlib/_btree_serializer_pyx.pyx":415
3038
* as_hex = PyString_FromStringAndSize(NULL, 40)
3039
* _hexlify_sha1(PyString_AS_STRING(as_bin), PyString_AS_STRING(as_hex))
3040
* return as_hex # <<<<<<<<<<<<<<
3044
__Pyx_XDECREF(__pyx_r);
3045
__Pyx_INCREF(__pyx_v_as_hex);
3046
__pyx_r = __pyx_v_as_hex;
3049
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
3052
__Pyx_XDECREF(__pyx_t_5);
3053
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._py_hexlify");
3056
__Pyx_DECREF(__pyx_v_as_hex);
3057
__Pyx_XGIVEREF(__pyx_r);
3058
__Pyx_RefNannyFinishContext();
3062
/* "bzrlib/_btree_serializer_pyx.pyx":418
3065
* cdef int _key_to_sha1(key, char *sha1): # cannot_raise # <<<<<<<<<<<<<<
3066
* """Map a key into its sha1 content.
3070
static int __pyx_f_6bzrlib_21_btree_serializer_pyx__key_to_sha1(PyObject *__pyx_v_key, char *__pyx_v_sha1) {
3071
char *__pyx_v_c_val;
3072
PyObject *__pyx_v_p_val;
3076
__Pyx_RefNannySetupContext("_key_to_sha1");
3078
/* "bzrlib/_btree_serializer_pyx.pyx":428
3079
* cdef PyObject *p_val
3081
* if StaticTuple_CheckExact(key) and StaticTuple_GET_SIZE(key) == 1: # <<<<<<<<<<<<<<
3082
* p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0)
3083
* elif (PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1):
3085
if (StaticTuple_CheckExact(__pyx_v_key)) {
3086
if (!(likely(((__pyx_v_key) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_key, __pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3087
__pyx_t_1 = (StaticTuple_GET_SIZE(((StaticTuple *)__pyx_v_key)) == 1);
3088
__pyx_t_2 = __pyx_t_1;
3090
__pyx_t_2 = StaticTuple_CheckExact(__pyx_v_key);
3094
/* "bzrlib/_btree_serializer_pyx.pyx":429
3096
* if StaticTuple_CheckExact(key) and StaticTuple_GET_SIZE(key) == 1:
3097
* p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0) # <<<<<<<<<<<<<<
3098
* elif (PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1):
3099
* p_val = PyTuple_GET_ITEM_ptr_object(key, 0)
3101
if (!(likely(((__pyx_v_key) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_key, __pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3102
__pyx_v_p_val = ((PyObject *)StaticTuple_GET_ITEM(((StaticTuple *)__pyx_v_key), 0));
3106
/* "bzrlib/_btree_serializer_pyx.pyx":430
3107
* if StaticTuple_CheckExact(key) and StaticTuple_GET_SIZE(key) == 1:
3108
* p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0)
3109
* elif (PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1): # <<<<<<<<<<<<<<
3110
* p_val = PyTuple_GET_ITEM_ptr_object(key, 0)
3113
if (PyTuple_CheckExact(__pyx_v_key)) {
3114
__pyx_t_2 = (PyTuple_GET_SIZE(__pyx_v_key) == 1);
3115
__pyx_t_1 = __pyx_t_2;
3117
__pyx_t_1 = PyTuple_CheckExact(__pyx_v_key);
3121
/* "bzrlib/_btree_serializer_pyx.pyx":431
3122
* p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0)
3123
* elif (PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1):
3124
* p_val = PyTuple_GET_ITEM_ptr_object(key, 0) # <<<<<<<<<<<<<<
3126
* # Not a tuple or a StaticTuple
3128
__pyx_v_p_val = PyTuple_GET_ITEM(__pyx_v_key, 0);
3133
/* "bzrlib/_btree_serializer_pyx.pyx":434
3135
* # Not a tuple or a StaticTuple
3136
* return 0 # <<<<<<<<<<<<<<
3137
* if (PyString_CheckExact_ptr(p_val) and PyString_GET_SIZE_ptr(p_val) == 45):
3138
* c_val = PyString_AS_STRING_ptr(p_val)
3145
/* "bzrlib/_btree_serializer_pyx.pyx":435
3146
* # Not a tuple or a StaticTuple
3148
* if (PyString_CheckExact_ptr(p_val) and PyString_GET_SIZE_ptr(p_val) == 45): # <<<<<<<<<<<<<<
3149
* c_val = PyString_AS_STRING_ptr(p_val)
3152
if (PyString_CheckExact(__pyx_v_p_val)) {
3153
__pyx_t_1 = (PyString_GET_SIZE(__pyx_v_p_val) == 45);
3154
__pyx_t_2 = __pyx_t_1;
3156
__pyx_t_2 = PyString_CheckExact(__pyx_v_p_val);
3160
/* "bzrlib/_btree_serializer_pyx.pyx":436
3162
* if (PyString_CheckExact_ptr(p_val) and PyString_GET_SIZE_ptr(p_val) == 45):
3163
* c_val = PyString_AS_STRING_ptr(p_val) # <<<<<<<<<<<<<<
3167
__pyx_v_c_val = PyString_AS_STRING(__pyx_v_p_val);
3172
/* "bzrlib/_btree_serializer_pyx.pyx":438
3173
* c_val = PyString_AS_STRING_ptr(p_val)
3175
* return 0 # <<<<<<<<<<<<<<
3176
* if strncmp(c_val, 'sha1:', 5) != 0:
3184
/* "bzrlib/_btree_serializer_pyx.pyx":439
3187
* if strncmp(c_val, 'sha1:', 5) != 0: # <<<<<<<<<<<<<<
3189
* if not _unhexlify_sha1(c_val + 5, sha1):
3191
__pyx_t_2 = (strncmp(__pyx_v_c_val, __pyx_k_3, 5) != 0);
3194
/* "bzrlib/_btree_serializer_pyx.pyx":440
3196
* if strncmp(c_val, 'sha1:', 5) != 0:
3197
* return 0 # <<<<<<<<<<<<<<
3198
* if not _unhexlify_sha1(c_val + 5, sha1):
3207
/* "bzrlib/_btree_serializer_pyx.pyx":441
3208
* if strncmp(c_val, 'sha1:', 5) != 0:
3210
* if not _unhexlify_sha1(c_val + 5, sha1): # <<<<<<<<<<<<<<
3214
__pyx_t_2 = (!__pyx_f_6bzrlib_21_btree_serializer_pyx__unhexlify_sha1((__pyx_v_c_val + 5), __pyx_v_sha1));
3217
/* "bzrlib/_btree_serializer_pyx.pyx":442
3219
* if not _unhexlify_sha1(c_val + 5, sha1):
3220
* return 0 # <<<<<<<<<<<<<<
3230
/* "bzrlib/_btree_serializer_pyx.pyx":443
3231
* if not _unhexlify_sha1(c_val + 5, sha1):
3233
* return 1 # <<<<<<<<<<<<<<
3243
__Pyx_WriteUnraisable("bzrlib._btree_serializer_pyx._key_to_sha1");
3246
__Pyx_RefNannyFinishContext();
3250
/* "bzrlib/_btree_serializer_pyx.pyx":446
3253
* def _py_key_to_sha1(key): # <<<<<<<<<<<<<<
3254
* """Map a key to a simple sha1 string.
3258
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_3_py_key_to_sha1(PyObject *__pyx_self, PyObject *__pyx_v_key); /*proto*/
3259
static char __pyx_doc_6bzrlib_21_btree_serializer_pyx_3_py_key_to_sha1[] = "Map a key to a simple sha1 string.\n\n This is a testing thunk to the C function.\n ";
3260
static PyMethodDef __pyx_mdef_6bzrlib_21_btree_serializer_pyx_3_py_key_to_sha1 = {__Pyx_NAMESTR("_py_key_to_sha1"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_3_py_key_to_sha1, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_21_btree_serializer_pyx_3_py_key_to_sha1)};
3261
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_3_py_key_to_sha1(PyObject *__pyx_self, PyObject *__pyx_v_key) {
3262
PyObject *__pyx_v_as_bin_sha;
3263
PyObject *__pyx_r = NULL;
3264
PyObject *__pyx_t_1 = NULL;
3266
__Pyx_RefNannySetupContext("_py_key_to_sha1");
3267
__pyx_self = __pyx_self;
3268
__pyx_v_as_bin_sha = Py_None; __Pyx_INCREF(Py_None);
3270
/* "bzrlib/_btree_serializer_pyx.pyx":451
3271
* This is a testing thunk to the C function.
3273
* as_bin_sha = PyString_FromStringAndSize(NULL, 20) # <<<<<<<<<<<<<<
3274
* if _key_to_sha1(key, PyString_AS_STRING(as_bin_sha)):
3277
__pyx_t_1 = PyString_FromStringAndSize(NULL, 20); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3278
__Pyx_GOTREF(__pyx_t_1);
3279
__Pyx_DECREF(__pyx_v_as_bin_sha);
3280
__pyx_v_as_bin_sha = __pyx_t_1;
3283
/* "bzrlib/_btree_serializer_pyx.pyx":452
3285
* as_bin_sha = PyString_FromStringAndSize(NULL, 20)
3286
* if _key_to_sha1(key, PyString_AS_STRING(as_bin_sha)): # <<<<<<<<<<<<<<
3290
__pyx_t_2 = __pyx_f_6bzrlib_21_btree_serializer_pyx__key_to_sha1(__pyx_v_key, PyString_AS_STRING(__pyx_v_as_bin_sha));
3293
/* "bzrlib/_btree_serializer_pyx.pyx":453
3294
* as_bin_sha = PyString_FromStringAndSize(NULL, 20)
3295
* if _key_to_sha1(key, PyString_AS_STRING(as_bin_sha)):
3296
* return as_bin_sha # <<<<<<<<<<<<<<
3300
__Pyx_XDECREF(__pyx_r);
3301
__Pyx_INCREF(__pyx_v_as_bin_sha);
3302
__pyx_r = __pyx_v_as_bin_sha;
3308
/* "bzrlib/_btree_serializer_pyx.pyx":454
3309
* if _key_to_sha1(key, PyString_AS_STRING(as_bin_sha)):
3311
* return None # <<<<<<<<<<<<<<
3315
__Pyx_XDECREF(__pyx_r);
3316
__Pyx_INCREF(Py_None);
3320
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
3323
__Pyx_XDECREF(__pyx_t_1);
3324
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._py_key_to_sha1");
3327
__Pyx_DECREF(__pyx_v_as_bin_sha);
3328
__Pyx_XGIVEREF(__pyx_r);
3329
__Pyx_RefNannyFinishContext();
3333
/* "bzrlib/_btree_serializer_pyx.pyx":457
3336
* cdef StaticTuple _sha1_to_key(char *sha1): # <<<<<<<<<<<<<<
3337
* """Compute a ('sha1:abcd',) key for a given sha1."""
3338
* cdef StaticTuple key
3341
static StaticTuple *__pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_key(char *__pyx_v_sha1) {
3342
StaticTuple *__pyx_v_key;
3343
PyObject *__pyx_v_hexxed;
3344
char *__pyx_v_c_buf;
3345
StaticTuple *__pyx_r = NULL;
3346
PyObject *__pyx_t_1 = NULL;
3347
__Pyx_RefNannySetupContext("_sha1_to_key");
3348
__pyx_v_key = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
3349
__pyx_v_hexxed = Py_None; __Pyx_INCREF(Py_None);
3351
/* "bzrlib/_btree_serializer_pyx.pyx":462
3352
* cdef object hexxed
3354
* hexxed = PyString_FromStringAndSize(NULL, 45) # <<<<<<<<<<<<<<
3355
* c_buf = PyString_AS_STRING(hexxed)
3356
* memcpy(c_buf, 'sha1:', 5)
3358
__pyx_t_1 = PyString_FromStringAndSize(NULL, 45); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3359
__Pyx_GOTREF(__pyx_t_1);
3360
__Pyx_DECREF(__pyx_v_hexxed);
3361
__pyx_v_hexxed = __pyx_t_1;
3364
/* "bzrlib/_btree_serializer_pyx.pyx":463
3366
* hexxed = PyString_FromStringAndSize(NULL, 45)
3367
* c_buf = PyString_AS_STRING(hexxed) # <<<<<<<<<<<<<<
3368
* memcpy(c_buf, 'sha1:', 5)
3369
* _hexlify_sha1(sha1, c_buf+5)
3371
__pyx_v_c_buf = PyString_AS_STRING(__pyx_v_hexxed);
3373
/* "bzrlib/_btree_serializer_pyx.pyx":464
3374
* hexxed = PyString_FromStringAndSize(NULL, 45)
3375
* c_buf = PyString_AS_STRING(hexxed)
3376
* memcpy(c_buf, 'sha1:', 5) # <<<<<<<<<<<<<<
3377
* _hexlify_sha1(sha1, c_buf+5)
3378
* key = StaticTuple_New(1)
3380
memcpy(__pyx_v_c_buf, __pyx_k_3, 5);
3382
/* "bzrlib/_btree_serializer_pyx.pyx":465
3383
* c_buf = PyString_AS_STRING(hexxed)
3384
* memcpy(c_buf, 'sha1:', 5)
3385
* _hexlify_sha1(sha1, c_buf+5) # <<<<<<<<<<<<<<
3386
* key = StaticTuple_New(1)
3389
__pyx_f_6bzrlib_21_btree_serializer_pyx__hexlify_sha1(__pyx_v_sha1, (__pyx_v_c_buf + 5));
3391
/* "bzrlib/_btree_serializer_pyx.pyx":466
3392
* memcpy(c_buf, 'sha1:', 5)
3393
* _hexlify_sha1(sha1, c_buf+5)
3394
* key = StaticTuple_New(1) # <<<<<<<<<<<<<<
3396
* StaticTuple_SET_ITEM(key, 0, hexxed)
3398
__pyx_t_1 = ((PyObject *)StaticTuple_New(1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3399
__Pyx_GOTREF(__pyx_t_1);
3400
__Pyx_DECREF(((PyObject *)__pyx_v_key));
3401
__pyx_v_key = ((StaticTuple *)__pyx_t_1);
3404
/* "bzrlib/_btree_serializer_pyx.pyx":467
3405
* _hexlify_sha1(sha1, c_buf+5)
3406
* key = StaticTuple_New(1)
3407
* Py_INCREF(hexxed) # <<<<<<<<<<<<<<
3408
* StaticTuple_SET_ITEM(key, 0, hexxed)
3409
* # This is a bit expensive. To parse 120 keys takes 48us, to return them all
3411
Py_INCREF(__pyx_v_hexxed);
3413
/* "bzrlib/_btree_serializer_pyx.pyx":468
3414
* key = StaticTuple_New(1)
3416
* StaticTuple_SET_ITEM(key, 0, hexxed) # <<<<<<<<<<<<<<
3417
* # This is a bit expensive. To parse 120 keys takes 48us, to return them all
3418
* # can be done in 66.6us (so 18.6us to build them all).
3420
StaticTuple_SET_ITEM(__pyx_v_key, 0, __pyx_v_hexxed);
3422
/* "bzrlib/_btree_serializer_pyx.pyx":478
3423
* # We *could* hang the PyObject form off of the gc_chk_sha1_record for ones
3424
* # that we have deserialized. Something to think about, at least.
3425
* key = StaticTuple_Intern(key) # <<<<<<<<<<<<<<
3429
__pyx_t_1 = ((PyObject *)StaticTuple_Intern(__pyx_v_key)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3430
__Pyx_GOTREF(__pyx_t_1);
3431
__Pyx_DECREF(((PyObject *)__pyx_v_key));
3432
__pyx_v_key = ((StaticTuple *)__pyx_t_1);
3435
/* "bzrlib/_btree_serializer_pyx.pyx":479
3436
* # that we have deserialized. Something to think about, at least.
3437
* key = StaticTuple_Intern(key)
3438
* return key # <<<<<<<<<<<<<<
3442
__Pyx_XDECREF(((PyObject *)__pyx_r));
3443
__Pyx_INCREF(((PyObject *)__pyx_v_key));
3444
__pyx_r = __pyx_v_key;
3447
__pyx_r = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
3450
__Pyx_XDECREF(__pyx_t_1);
3451
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._sha1_to_key");
3454
__Pyx_DECREF((PyObject *)__pyx_v_key);
3455
__Pyx_DECREF(__pyx_v_hexxed);
3456
__Pyx_XGIVEREF((PyObject *)__pyx_r);
3457
__Pyx_RefNannyFinishContext();
3461
/* "bzrlib/_btree_serializer_pyx.pyx":482
3464
* def _py_sha1_to_key(sha1_bin): # <<<<<<<<<<<<<<
3465
* """Test thunk to check the sha1 mapping."""
3466
* if not PyString_CheckExact(sha1_bin) or PyString_GET_SIZE(sha1_bin) != 20:
3469
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_4_py_sha1_to_key(PyObject *__pyx_self, PyObject *__pyx_v_sha1_bin); /*proto*/
3470
static char __pyx_doc_6bzrlib_21_btree_serializer_pyx_4_py_sha1_to_key[] = "Test thunk to check the sha1 mapping.";
3471
static PyMethodDef __pyx_mdef_6bzrlib_21_btree_serializer_pyx_4_py_sha1_to_key = {__Pyx_NAMESTR("_py_sha1_to_key"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_4_py_sha1_to_key, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_21_btree_serializer_pyx_4_py_sha1_to_key)};
3472
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_4_py_sha1_to_key(PyObject *__pyx_self, PyObject *__pyx_v_sha1_bin) {
3473
PyObject *__pyx_r = NULL;
3477
PyObject *__pyx_t_4 = NULL;
3478
__Pyx_RefNannySetupContext("_py_sha1_to_key");
3479
__pyx_self = __pyx_self;
3481
/* "bzrlib/_btree_serializer_pyx.pyx":484
3482
* def _py_sha1_to_key(sha1_bin):
3483
* """Test thunk to check the sha1 mapping."""
3484
* if not PyString_CheckExact(sha1_bin) or PyString_GET_SIZE(sha1_bin) != 20: # <<<<<<<<<<<<<<
3485
* raise ValueError('sha1_bin must be a str of exactly 20 bytes')
3486
* return _sha1_to_key(PyString_AS_STRING(sha1_bin))
3488
__pyx_t_1 = (!PyString_CheckExact(__pyx_v_sha1_bin));
3490
__pyx_t_2 = (PyString_GET_SIZE(__pyx_v_sha1_bin) != 20);
3491
__pyx_t_3 = __pyx_t_2;
3493
__pyx_t_3 = __pyx_t_1;
3497
/* "bzrlib/_btree_serializer_pyx.pyx":485
3498
* """Test thunk to check the sha1 mapping."""
3499
* if not PyString_CheckExact(sha1_bin) or PyString_GET_SIZE(sha1_bin) != 20:
3500
* raise ValueError('sha1_bin must be a str of exactly 20 bytes') # <<<<<<<<<<<<<<
3501
* return _sha1_to_key(PyString_AS_STRING(sha1_bin))
3504
__pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3505
__Pyx_GOTREF(__pyx_t_4);
3506
__Pyx_Raise(__pyx_t_4, 0, 0);
3507
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3508
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3513
/* "bzrlib/_btree_serializer_pyx.pyx":486
3514
* if not PyString_CheckExact(sha1_bin) or PyString_GET_SIZE(sha1_bin) != 20:
3515
* raise ValueError('sha1_bin must be a str of exactly 20 bytes')
3516
* return _sha1_to_key(PyString_AS_STRING(sha1_bin)) # <<<<<<<<<<<<<<
3520
__Pyx_XDECREF(__pyx_r);
3521
__pyx_t_4 = ((PyObject *)__pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_key(PyString_AS_STRING(__pyx_v_sha1_bin))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3522
__Pyx_GOTREF(__pyx_t_4);
3523
__pyx_r = __pyx_t_4;
3527
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
3530
__Pyx_XDECREF(__pyx_t_4);
3531
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._py_sha1_to_key");
3534
__Pyx_XGIVEREF(__pyx_r);
3535
__Pyx_RefNannyFinishContext();
3539
/* "bzrlib/_btree_serializer_pyx.pyx":489
3542
* cdef unsigned int _sha1_to_uint(char *sha1): # cannot_raise # <<<<<<<<<<<<<<
3543
* cdef unsigned int val
3544
* # Must be in MSB, because that is how the content is sorted
3547
static unsigned int __pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_uint(char *__pyx_v_sha1) {
3548
unsigned int __pyx_v_val;
3549
unsigned int __pyx_r;
3550
__Pyx_RefNannySetupContext("_sha1_to_uint");
3552
/* "bzrlib/_btree_serializer_pyx.pyx":495
3553
* | ((<unsigned int>(sha1[1]) & 0xff) << 16)
3554
* | ((<unsigned int>(sha1[2]) & 0xff) << 8)
3555
* | ((<unsigned int>(sha1[3]) & 0xff) << 0)) # <<<<<<<<<<<<<<
3559
__pyx_v_val = (((((((unsigned int)(__pyx_v_sha1[0])) & 0xff) << 24) | ((((unsigned int)(__pyx_v_sha1[1])) & 0xff) << 16)) | ((((unsigned int)(__pyx_v_sha1[2])) & 0xff) << 8)) | ((((unsigned int)(__pyx_v_sha1[3])) & 0xff) << 0));
3561
/* "bzrlib/_btree_serializer_pyx.pyx":496
3562
* | ((<unsigned int>(sha1[2]) & 0xff) << 8)
3563
* | ((<unsigned int>(sha1[3]) & 0xff) << 0))
3564
* return val # <<<<<<<<<<<<<<
3568
__pyx_r = __pyx_v_val;
3573
__Pyx_RefNannyFinishContext();
3577
/* "bzrlib/_btree_serializer_pyx.pyx":499
3580
* cdef _format_record(gc_chk_sha1_record *record): # <<<<<<<<<<<<<<
3581
* # This is inefficient to go from a logical state back to a
3582
* # string, but it makes things work a bit better internally for now.
3585
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx__format_record(__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record) {
3586
PyObject *__pyx_v_block_offset_str;
3587
PyObject *__pyx_v_value;
3588
PyObject *__pyx_r = NULL;
3589
PyObject *__pyx_t_1 = NULL;
3590
PyObject *__pyx_t_2 = NULL;
3592
__Pyx_RefNannySetupContext("_format_record");
3593
__pyx_v_block_offset_str = Py_None; __Pyx_INCREF(Py_None);
3594
__pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
3596
/* "bzrlib/_btree_serializer_pyx.pyx":502
3597
* # This is inefficient to go from a logical state back to a
3598
* # string, but it makes things work a bit better internally for now.
3599
* if record.block_offset >= 0xFFFFFFFF: # <<<<<<<<<<<<<<
3600
* # %llu is what we really want, but unfortunately it was only added
3601
* # in python 2.7... :(
3603
__pyx_t_1 = PyLong_FromLongLong(__pyx_v_record->block_offset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3604
__Pyx_GOTREF(__pyx_t_1);
3605
__pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_4294967295, Py_GE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3606
__Pyx_GOTREF(__pyx_t_2);
3607
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3608
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3609
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3612
/* "bzrlib/_btree_serializer_pyx.pyx":505
3613
* # %llu is what we really want, but unfortunately it was only added
3614
* # in python 2.7... :(
3615
* block_offset_str = str(record.block_offset) # <<<<<<<<<<<<<<
3616
* value = PyString_FromFormat('%s %u %u %u',
3617
* PyString_AS_STRING(block_offset_str),
3619
__pyx_t_2 = PyLong_FromLongLong(__pyx_v_record->block_offset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3620
__Pyx_GOTREF(__pyx_t_2);
3621
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3622
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
3623
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
3624
__Pyx_GIVEREF(__pyx_t_2);
3626
__pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3627
__Pyx_GOTREF(__pyx_t_2);
3628
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
3629
__Pyx_DECREF(__pyx_v_block_offset_str);
3630
__pyx_v_block_offset_str = __pyx_t_2;
3633
/* "bzrlib/_btree_serializer_pyx.pyx":509
3634
* PyString_AS_STRING(block_offset_str),
3635
* record.block_length,
3636
* record.record_start, record.record_end) # <<<<<<<<<<<<<<
3638
* value = PyString_FromFormat('%lu %u %u %u',
3640
__pyx_t_2 = PyString_FromFormat(__pyx_k_24, PyString_AS_STRING(__pyx_v_block_offset_str), __pyx_v_record->block_length, __pyx_v_record->record_start, __pyx_v_record->record_end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3641
__Pyx_GOTREF(__pyx_t_2);
3642
__Pyx_DECREF(__pyx_v_value);
3643
__pyx_v_value = __pyx_t_2;
3649
/* "bzrlib/_btree_serializer_pyx.pyx":514
3650
* <unsigned long>record.block_offset,
3651
* record.block_length,
3652
* record.record_start, record.record_end) # <<<<<<<<<<<<<<
3656
__pyx_t_2 = PyString_FromFormat(__pyx_k_25, ((unsigned long)__pyx_v_record->block_offset), __pyx_v_record->block_length, __pyx_v_record->record_start, __pyx_v_record->record_end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3657
__Pyx_GOTREF(__pyx_t_2);
3658
__Pyx_DECREF(__pyx_v_value);
3659
__pyx_v_value = __pyx_t_2;
3664
/* "bzrlib/_btree_serializer_pyx.pyx":515
3665
* record.block_length,
3666
* record.record_start, record.record_end)
3667
* return value # <<<<<<<<<<<<<<
3671
__Pyx_XDECREF(__pyx_r);
3672
__Pyx_INCREF(__pyx_v_value);
3673
__pyx_r = __pyx_v_value;
3676
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
3679
__Pyx_XDECREF(__pyx_t_1);
3680
__Pyx_XDECREF(__pyx_t_2);
3681
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._format_record");
3684
__Pyx_DECREF(__pyx_v_block_offset_str);
3685
__Pyx_DECREF(__pyx_v_value);
3686
__Pyx_XGIVEREF(__pyx_r);
3687
__Pyx_RefNannyFinishContext();
3691
/* "bzrlib/_btree_serializer_pyx.pyx":536
3692
* cdef unsigned char offsets[257]
3694
* def __sizeof__(self): # <<<<<<<<<<<<<<
3695
* # :( Why doesn't Pyrex let me do a simple sizeof(GCCHKSHA1LeafNode)
3696
* # like Cython? Explicitly enumerating everything here seems to leave my
3699
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode___sizeof__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
3700
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode___sizeof__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
3701
PyObject *__pyx_r = NULL;
3702
PyObject *__pyx_t_1 = NULL;
3703
__Pyx_RefNannySetupContext("__sizeof__");
3705
/* "bzrlib/_btree_serializer_pyx.pyx":546
3706
* # return (sizeof(GCCHKSHA1LeafNode)
3707
* # + sizeof(gc_chk_sha1_record)*self.num_records)
3708
* return (sizeof(PyObject) + sizeof(void*) + sizeof(int) # <<<<<<<<<<<<<<
3709
* + sizeof(gc_chk_sha1_record*) + sizeof(PyObject *)
3710
* + sizeof(gc_chk_sha1_record*) + sizeof(char)
3712
__Pyx_XDECREF(__pyx_r);
3714
/* "bzrlib/_btree_serializer_pyx.pyx":550
3715
* + sizeof(gc_chk_sha1_record*) + sizeof(char)
3716
* + sizeof(unsigned char)*257
3717
* + sizeof(gc_chk_sha1_record)*self.num_records) # <<<<<<<<<<<<<<
3719
* def __dealloc__(self):
3721
__pyx_t_1 = __Pyx_PyInt_FromSize_t((((((((((sizeof(PyObject)) + (sizeof(void *))) + (sizeof(int))) + (sizeof(__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *))) + (sizeof(PyObject *))) + (sizeof(__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *))) + (sizeof(char))) + ((sizeof(unsigned char)) * 257)) + ((sizeof(__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record)) * ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->num_records))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3722
__Pyx_GOTREF(__pyx_t_1);
3723
__pyx_r = __pyx_t_1;
3727
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
3730
__Pyx_XDECREF(__pyx_t_1);
3731
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.__sizeof__");
3734
__Pyx_XGIVEREF(__pyx_r);
3735
__Pyx_RefNannyFinishContext();
3739
/* "bzrlib/_btree_serializer_pyx.pyx":552
3740
* + sizeof(gc_chk_sha1_record)*self.num_records)
3742
* def __dealloc__(self): # <<<<<<<<<<<<<<
3743
* if self.records != NULL:
3744
* PyMem_Free(self.records)
3747
static void __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
3748
static void __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_1__dealloc__(PyObject *__pyx_v_self) {
3750
__Pyx_RefNannySetupContext("__dealloc__");
3752
/* "bzrlib/_btree_serializer_pyx.pyx":553
3754
* def __dealloc__(self):
3755
* if self.records != NULL: # <<<<<<<<<<<<<<
3756
* PyMem_Free(self.records)
3757
* self.records = NULL
3759
__pyx_t_1 = (((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->records != NULL);
3762
/* "bzrlib/_btree_serializer_pyx.pyx":554
3763
* def __dealloc__(self):
3764
* if self.records != NULL:
3765
* PyMem_Free(self.records) # <<<<<<<<<<<<<<
3766
* self.records = NULL
3769
PyMem_Free(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->records);
3771
/* "bzrlib/_btree_serializer_pyx.pyx":555
3772
* if self.records != NULL:
3773
* PyMem_Free(self.records)
3774
* self.records = NULL # <<<<<<<<<<<<<<
3776
* def __init__(self, bytes):
3778
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->records = NULL;
3783
__Pyx_RefNannyFinishContext();
3786
/* "bzrlib/_btree_serializer_pyx.pyx":557
3787
* self.records = NULL
3789
* def __init__(self, bytes): # <<<<<<<<<<<<<<
3790
* self._parse_bytes(bytes)
3791
* self.last_key = None
3794
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_2__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3795
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_2__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3796
PyObject *__pyx_v_bytes = 0;
3798
PyObject *__pyx_t_1 = NULL;
3799
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bytes,0};
3800
__Pyx_RefNannySetupContext("__init__");
3801
if (unlikely(__pyx_kwds)) {
3802
Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3803
PyObject* values[1] = {0};
3804
switch (PyTuple_GET_SIZE(__pyx_args)) {
3805
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3807
default: goto __pyx_L5_argtuple_error;
3809
switch (PyTuple_GET_SIZE(__pyx_args)) {
3811
values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bytes);
3812
if (likely(values[0])) kw_args--;
3813
else goto __pyx_L5_argtuple_error;
3815
if (unlikely(kw_args > 0)) {
3816
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3818
__pyx_v_bytes = values[0];
3819
} else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
3820
goto __pyx_L5_argtuple_error;
3822
__pyx_v_bytes = PyTuple_GET_ITEM(__pyx_args, 0);
3824
goto __pyx_L4_argument_unpacking_done;
3825
__pyx_L5_argtuple_error:;
3826
__Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3828
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.__init__");
3829
__Pyx_RefNannyFinishContext();
3831
__pyx_L4_argument_unpacking_done:;
3833
/* "bzrlib/_btree_serializer_pyx.pyx":558
3835
* def __init__(self, bytes):
3836
* self._parse_bytes(bytes) # <<<<<<<<<<<<<<
3837
* self.last_key = None
3838
* self.last_record = NULL
3840
__pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->__pyx_vtab)->_parse_bytes(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), __pyx_v_bytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3841
__Pyx_GOTREF(__pyx_t_1);
3842
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3844
/* "bzrlib/_btree_serializer_pyx.pyx":559
3845
* def __init__(self, bytes):
3846
* self._parse_bytes(bytes)
3847
* self.last_key = None # <<<<<<<<<<<<<<
3848
* self.last_record = NULL
3851
__Pyx_INCREF(Py_None);
3852
__Pyx_GIVEREF(Py_None);
3853
__Pyx_GOTREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
3854
__Pyx_DECREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
3855
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key = Py_None;
3857
/* "bzrlib/_btree_serializer_pyx.pyx":560
3858
* self._parse_bytes(bytes)
3859
* self.last_key = None
3860
* self.last_record = NULL # <<<<<<<<<<<<<<
3864
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_record = NULL;
3869
__Pyx_XDECREF(__pyx_t_1);
3870
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.__init__");
3873
__Pyx_RefNannyFinishContext();
3877
/* "bzrlib/_btree_serializer_pyx.pyx":563
3880
* def __get__(self): # <<<<<<<<<<<<<<
3881
* if self.num_records > 0:
3882
* return _sha1_to_key(self.records[0].sha1)
3885
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key___get__(PyObject *__pyx_v_self); /*proto*/
3886
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key___get__(PyObject *__pyx_v_self) {
3887
PyObject *__pyx_r = NULL;
3889
PyObject *__pyx_t_2 = NULL;
3890
__Pyx_RefNannySetupContext("__get__");
3892
/* "bzrlib/_btree_serializer_pyx.pyx":564
3894
* def __get__(self):
3895
* if self.num_records > 0: # <<<<<<<<<<<<<<
3896
* return _sha1_to_key(self.records[0].sha1)
3899
__pyx_t_1 = (((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->num_records > 0);
3902
/* "bzrlib/_btree_serializer_pyx.pyx":565
3903
* def __get__(self):
3904
* if self.num_records > 0:
3905
* return _sha1_to_key(self.records[0].sha1) # <<<<<<<<<<<<<<
3909
__Pyx_XDECREF(__pyx_r);
3910
__pyx_t_2 = ((PyObject *)__pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_key((((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->records[0]).sha1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3911
__Pyx_GOTREF(__pyx_t_2);
3912
__pyx_r = __pyx_t_2;
3919
/* "bzrlib/_btree_serializer_pyx.pyx":566
3920
* if self.num_records > 0:
3921
* return _sha1_to_key(self.records[0].sha1)
3922
* return None # <<<<<<<<<<<<<<
3926
__Pyx_XDECREF(__pyx_r);
3927
__Pyx_INCREF(Py_None);
3931
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
3934
__Pyx_XDECREF(__pyx_t_2);
3935
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.min_key.__get__");
3938
__Pyx_XGIVEREF(__pyx_r);
3939
__Pyx_RefNannyFinishContext();
3943
/* "bzrlib/_btree_serializer_pyx.pyx":569
3946
* def __get__(self): # <<<<<<<<<<<<<<
3947
* if self.num_records > 0:
3948
* return _sha1_to_key(self.records[self.num_records-1].sha1)
3951
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key___get__(PyObject *__pyx_v_self); /*proto*/
3952
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key___get__(PyObject *__pyx_v_self) {
3953
PyObject *__pyx_r = NULL;
3955
PyObject *__pyx_t_2 = NULL;
3956
__Pyx_RefNannySetupContext("__get__");
3958
/* "bzrlib/_btree_serializer_pyx.pyx":570
3960
* def __get__(self):
3961
* if self.num_records > 0: # <<<<<<<<<<<<<<
3962
* return _sha1_to_key(self.records[self.num_records-1].sha1)
3965
__pyx_t_1 = (((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->num_records > 0);
3968
/* "bzrlib/_btree_serializer_pyx.pyx":571
3969
* def __get__(self):
3970
* if self.num_records > 0:
3971
* return _sha1_to_key(self.records[self.num_records-1].sha1) # <<<<<<<<<<<<<<
3975
__Pyx_XDECREF(__pyx_r);
3976
__pyx_t_2 = ((PyObject *)__pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_key((((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->records[(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->num_records - 1)]).sha1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3977
__Pyx_GOTREF(__pyx_t_2);
3978
__pyx_r = __pyx_t_2;
3985
/* "bzrlib/_btree_serializer_pyx.pyx":572
3986
* if self.num_records > 0:
3987
* return _sha1_to_key(self.records[self.num_records-1].sha1)
3988
* return None # <<<<<<<<<<<<<<
3990
* cdef StaticTuple _record_to_value_and_refs(self,
3992
__Pyx_XDECREF(__pyx_r);
3993
__Pyx_INCREF(Py_None);
3997
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
4000
__Pyx_XDECREF(__pyx_t_2);
4001
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.max_key.__get__");
4004
__Pyx_XGIVEREF(__pyx_r);
4005
__Pyx_RefNannyFinishContext();
4009
/* "bzrlib/_btree_serializer_pyx.pyx":574
4012
* cdef StaticTuple _record_to_value_and_refs(self, # <<<<<<<<<<<<<<
4013
* gc_chk_sha1_record *record):
4014
* """Extract the refs and value part of this record."""
4017
static StaticTuple *__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_value_and_refs(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record) {
4018
StaticTuple *__pyx_v_value_and_refs;
4019
StaticTuple *__pyx_v_empty;
4020
PyObject *__pyx_v_value;
4021
StaticTuple *__pyx_r = NULL;
4022
PyObject *__pyx_t_1 = NULL;
4023
__Pyx_RefNannySetupContext("_record_to_value_and_refs");
4024
__pyx_v_value_and_refs = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
4025
__pyx_v_empty = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
4026
__pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
4028
/* "bzrlib/_btree_serializer_pyx.pyx":579
4029
* cdef StaticTuple value_and_refs
4030
* cdef StaticTuple empty
4031
* value_and_refs = StaticTuple_New(2) # <<<<<<<<<<<<<<
4032
* value = _format_record(record)
4035
__pyx_t_1 = ((PyObject *)StaticTuple_New(2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4036
__Pyx_GOTREF(__pyx_t_1);
4037
__Pyx_DECREF(((PyObject *)__pyx_v_value_and_refs));
4038
__pyx_v_value_and_refs = ((StaticTuple *)__pyx_t_1);
4041
/* "bzrlib/_btree_serializer_pyx.pyx":580
4042
* cdef StaticTuple empty
4043
* value_and_refs = StaticTuple_New(2)
4044
* value = _format_record(record) # <<<<<<<<<<<<<<
4046
* StaticTuple_SET_ITEM(value_and_refs, 0, value)
4048
__pyx_t_1 = __pyx_f_6bzrlib_21_btree_serializer_pyx__format_record(__pyx_v_record); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4049
__Pyx_GOTREF(__pyx_t_1);
4050
__Pyx_DECREF(__pyx_v_value);
4051
__pyx_v_value = __pyx_t_1;
4054
/* "bzrlib/_btree_serializer_pyx.pyx":581
4055
* value_and_refs = StaticTuple_New(2)
4056
* value = _format_record(record)
4057
* Py_INCREF(value) # <<<<<<<<<<<<<<
4058
* StaticTuple_SET_ITEM(value_and_refs, 0, value)
4059
* # Always empty refs
4061
Py_INCREF(__pyx_v_value);
4063
/* "bzrlib/_btree_serializer_pyx.pyx":582
4064
* value = _format_record(record)
4066
* StaticTuple_SET_ITEM(value_and_refs, 0, value) # <<<<<<<<<<<<<<
4067
* # Always empty refs
4068
* empty = StaticTuple_New(0)
4070
StaticTuple_SET_ITEM(__pyx_v_value_and_refs, 0, __pyx_v_value);
4072
/* "bzrlib/_btree_serializer_pyx.pyx":584
4073
* StaticTuple_SET_ITEM(value_and_refs, 0, value)
4074
* # Always empty refs
4075
* empty = StaticTuple_New(0) # <<<<<<<<<<<<<<
4077
* StaticTuple_SET_ITEM(value_and_refs, 1, empty)
4079
__pyx_t_1 = ((PyObject *)StaticTuple_New(0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4080
__Pyx_GOTREF(__pyx_t_1);
4081
__Pyx_DECREF(((PyObject *)__pyx_v_empty));
4082
__pyx_v_empty = ((StaticTuple *)__pyx_t_1);
4085
/* "bzrlib/_btree_serializer_pyx.pyx":585
4086
* # Always empty refs
4087
* empty = StaticTuple_New(0)
4088
* Py_INCREF(empty) # <<<<<<<<<<<<<<
4089
* StaticTuple_SET_ITEM(value_and_refs, 1, empty)
4090
* return value_and_refs
4092
Py_INCREF(((PyObject *)__pyx_v_empty));
4094
/* "bzrlib/_btree_serializer_pyx.pyx":586
4095
* empty = StaticTuple_New(0)
4097
* StaticTuple_SET_ITEM(value_and_refs, 1, empty) # <<<<<<<<<<<<<<
4098
* return value_and_refs
4101
StaticTuple_SET_ITEM(__pyx_v_value_and_refs, 1, ((PyObject *)__pyx_v_empty));
4103
/* "bzrlib/_btree_serializer_pyx.pyx":587
4105
* StaticTuple_SET_ITEM(value_and_refs, 1, empty)
4106
* return value_and_refs # <<<<<<<<<<<<<<
4108
* cdef StaticTuple _record_to_item(self, gc_chk_sha1_record *record):
4110
__Pyx_XDECREF(((PyObject *)__pyx_r));
4111
__Pyx_INCREF(((PyObject *)__pyx_v_value_and_refs));
4112
__pyx_r = __pyx_v_value_and_refs;
4115
__pyx_r = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
4118
__Pyx_XDECREF(__pyx_t_1);
4119
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode._record_to_value_and_refs");
4122
__Pyx_DECREF((PyObject *)__pyx_v_value_and_refs);
4123
__Pyx_DECREF((PyObject *)__pyx_v_empty);
4124
__Pyx_DECREF(__pyx_v_value);
4125
__Pyx_XGIVEREF((PyObject *)__pyx_r);
4126
__Pyx_RefNannyFinishContext();
4130
/* "bzrlib/_btree_serializer_pyx.pyx":589
4131
* return value_and_refs
4133
* cdef StaticTuple _record_to_item(self, gc_chk_sha1_record *record): # <<<<<<<<<<<<<<
4134
* """Turn a given record back into a fully fledged item.
4138
static StaticTuple *__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_item(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record) {
4139
StaticTuple *__pyx_v_item;
4140
StaticTuple *__pyx_v_key;
4141
StaticTuple *__pyx_v_value_and_refs;
4142
StaticTuple *__pyx_r = NULL;
4143
PyObject *__pyx_t_1 = NULL;
4144
__Pyx_RefNannySetupContext("_record_to_item");
4145
__pyx_v_item = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
4146
__pyx_v_key = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
4147
__pyx_v_value_and_refs = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
4149
/* "bzrlib/_btree_serializer_pyx.pyx":596
4150
* cdef StaticTuple value_and_refs
4152
* key = _sha1_to_key(record.sha1) # <<<<<<<<<<<<<<
4153
* item = StaticTuple_New(2)
4156
__pyx_t_1 = ((PyObject *)__pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_key(__pyx_v_record->sha1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4157
__Pyx_GOTREF(__pyx_t_1);
4158
__Pyx_DECREF(((PyObject *)__pyx_v_key));
4159
__pyx_v_key = ((StaticTuple *)__pyx_t_1);
4162
/* "bzrlib/_btree_serializer_pyx.pyx":597
4164
* key = _sha1_to_key(record.sha1)
4165
* item = StaticTuple_New(2) # <<<<<<<<<<<<<<
4167
* StaticTuple_SET_ITEM(item, 0, key)
4169
__pyx_t_1 = ((PyObject *)StaticTuple_New(2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4170
__Pyx_GOTREF(__pyx_t_1);
4171
__Pyx_DECREF(((PyObject *)__pyx_v_item));
4172
__pyx_v_item = ((StaticTuple *)__pyx_t_1);
4175
/* "bzrlib/_btree_serializer_pyx.pyx":598
4176
* key = _sha1_to_key(record.sha1)
4177
* item = StaticTuple_New(2)
4178
* Py_INCREF(key) # <<<<<<<<<<<<<<
4179
* StaticTuple_SET_ITEM(item, 0, key)
4180
* value_and_refs = self._record_to_value_and_refs(record)
4182
Py_INCREF(((PyObject *)__pyx_v_key));
4184
/* "bzrlib/_btree_serializer_pyx.pyx":599
4185
* item = StaticTuple_New(2)
4187
* StaticTuple_SET_ITEM(item, 0, key) # <<<<<<<<<<<<<<
4188
* value_and_refs = self._record_to_value_and_refs(record)
4189
* Py_INCREF(value_and_refs)
4191
StaticTuple_SET_ITEM(__pyx_v_item, 0, ((PyObject *)__pyx_v_key));
4193
/* "bzrlib/_btree_serializer_pyx.pyx":600
4195
* StaticTuple_SET_ITEM(item, 0, key)
4196
* value_and_refs = self._record_to_value_and_refs(record) # <<<<<<<<<<<<<<
4197
* Py_INCREF(value_and_refs)
4198
* StaticTuple_SET_ITEM(item, 1, value_and_refs)
4200
__pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_record_to_value_and_refs(__pyx_v_self, __pyx_v_record)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4201
__Pyx_GOTREF(__pyx_t_1);
4202
__Pyx_DECREF(((PyObject *)__pyx_v_value_and_refs));
4203
__pyx_v_value_and_refs = ((StaticTuple *)__pyx_t_1);
4206
/* "bzrlib/_btree_serializer_pyx.pyx":601
4207
* StaticTuple_SET_ITEM(item, 0, key)
4208
* value_and_refs = self._record_to_value_and_refs(record)
4209
* Py_INCREF(value_and_refs) # <<<<<<<<<<<<<<
4210
* StaticTuple_SET_ITEM(item, 1, value_and_refs)
4213
Py_INCREF(((PyObject *)__pyx_v_value_and_refs));
4215
/* "bzrlib/_btree_serializer_pyx.pyx":602
4216
* value_and_refs = self._record_to_value_and_refs(record)
4217
* Py_INCREF(value_and_refs)
4218
* StaticTuple_SET_ITEM(item, 1, value_and_refs) # <<<<<<<<<<<<<<
4222
StaticTuple_SET_ITEM(__pyx_v_item, 1, ((PyObject *)__pyx_v_value_and_refs));
4224
/* "bzrlib/_btree_serializer_pyx.pyx":603
4225
* Py_INCREF(value_and_refs)
4226
* StaticTuple_SET_ITEM(item, 1, value_and_refs)
4227
* return item # <<<<<<<<<<<<<<
4229
* cdef gc_chk_sha1_record* _lookup_record(self, char *sha1) except? NULL:
4231
__Pyx_XDECREF(((PyObject *)__pyx_r));
4232
__Pyx_INCREF(((PyObject *)__pyx_v_item));
4233
__pyx_r = __pyx_v_item;
4236
__pyx_r = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
4239
__Pyx_XDECREF(__pyx_t_1);
4240
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode._record_to_item");
4243
__Pyx_DECREF((PyObject *)__pyx_v_item);
4244
__Pyx_DECREF((PyObject *)__pyx_v_key);
4245
__Pyx_DECREF((PyObject *)__pyx_v_value_and_refs);
4246
__Pyx_XGIVEREF((PyObject *)__pyx_r);
4247
__Pyx_RefNannyFinishContext();
4251
/* "bzrlib/_btree_serializer_pyx.pyx":605
4254
* cdef gc_chk_sha1_record* _lookup_record(self, char *sha1) except? NULL: # <<<<<<<<<<<<<<
4255
* """Find a gc_chk_sha1_record that matches the sha1 supplied."""
4256
* cdef int lo, hi, mid, the_cmp
4259
static __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__lookup_record(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_sha1) {
4263
int __pyx_v_the_cmp;
4265
long __pyx_v_local_n_cmp;
4266
__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_r;
4269
__Pyx_RefNannySetupContext("_lookup_record");
4271
/* "bzrlib/_btree_serializer_pyx.pyx":619
4272
* # the offset array dropped us from 23us to 20us and 156 comparisions
4274
* offset = self._offset_for_sha1(sha1) # <<<<<<<<<<<<<<
4275
* lo = self.offsets[offset]
4276
* hi = self.offsets[offset+1]
4278
__pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_offset_for_sha1(__pyx_v_self, __pyx_v_sha1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4279
__pyx_v_offset = __pyx_t_1;
4281
/* "bzrlib/_btree_serializer_pyx.pyx":620
4283
* offset = self._offset_for_sha1(sha1)
4284
* lo = self.offsets[offset] # <<<<<<<<<<<<<<
4285
* hi = self.offsets[offset+1]
4288
__pyx_v_lo = (__pyx_v_self->offsets[__pyx_v_offset]);
4290
/* "bzrlib/_btree_serializer_pyx.pyx":621
4291
* offset = self._offset_for_sha1(sha1)
4292
* lo = self.offsets[offset]
4293
* hi = self.offsets[offset+1] # <<<<<<<<<<<<<<
4295
* # if hi == 255 that means we potentially ran off the end of the
4297
__pyx_v_hi = (__pyx_v_self->offsets[(__pyx_v_offset + 1)]);
4299
/* "bzrlib/_btree_serializer_pyx.pyx":622
4300
* lo = self.offsets[offset]
4301
* hi = self.offsets[offset+1]
4302
* if hi == 255: # <<<<<<<<<<<<<<
4303
* # if hi == 255 that means we potentially ran off the end of the
4304
* # list, so push it up to num_records
4306
__pyx_t_2 = (__pyx_v_hi == 255);
4309
/* "bzrlib/_btree_serializer_pyx.pyx":627
4310
* # note that if 'lo' == 255, that is ok, because we can start
4311
* # searching from that part of the list.
4312
* hi = self.num_records # <<<<<<<<<<<<<<
4316
__pyx_v_hi = __pyx_v_self->num_records;
4321
/* "bzrlib/_btree_serializer_pyx.pyx":628
4322
* # searching from that part of the list.
4323
* hi = self.num_records
4324
* local_n_cmp = 0 # <<<<<<<<<<<<<<
4326
* mid = (lo + hi) / 2
4328
__pyx_v_local_n_cmp = 0;
4330
/* "bzrlib/_btree_serializer_pyx.pyx":629
4331
* hi = self.num_records
4333
* while lo < hi: # <<<<<<<<<<<<<<
4334
* mid = (lo + hi) / 2
4335
* the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
4338
__pyx_t_2 = (__pyx_v_lo < __pyx_v_hi);
4339
if (!__pyx_t_2) break;
4341
/* "bzrlib/_btree_serializer_pyx.pyx":630
4344
* mid = (lo + hi) / 2 # <<<<<<<<<<<<<<
4345
* the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
4348
__pyx_v_mid = __Pyx_div_long((__pyx_v_lo + __pyx_v_hi), 2);
4350
/* "bzrlib/_btree_serializer_pyx.pyx":631
4352
* mid = (lo + hi) / 2
4353
* the_cmp = memcmp(self.records[mid].sha1, sha1, 20) # <<<<<<<<<<<<<<
4355
* return &self.records[mid]
4357
__pyx_v_the_cmp = memcmp((__pyx_v_self->records[__pyx_v_mid]).sha1, __pyx_v_sha1, 20);
4359
/* "bzrlib/_btree_serializer_pyx.pyx":632
4360
* mid = (lo + hi) / 2
4361
* the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
4362
* if the_cmp == 0: # <<<<<<<<<<<<<<
4363
* return &self.records[mid]
4366
__pyx_t_2 = (__pyx_v_the_cmp == 0);
4369
/* "bzrlib/_btree_serializer_pyx.pyx":633
4370
* the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
4372
* return &self.records[mid] # <<<<<<<<<<<<<<
4376
__pyx_r = (&(__pyx_v_self->records[__pyx_v_mid]));
4381
/* "bzrlib/_btree_serializer_pyx.pyx":634
4383
* return &self.records[mid]
4384
* elif the_cmp < 0: # <<<<<<<<<<<<<<
4388
__pyx_t_2 = (__pyx_v_the_cmp < 0);
4391
/* "bzrlib/_btree_serializer_pyx.pyx":635
4392
* return &self.records[mid]
4394
* lo = mid + 1 # <<<<<<<<<<<<<<
4398
__pyx_v_lo = (__pyx_v_mid + 1);
4403
/* "bzrlib/_btree_serializer_pyx.pyx":637
4406
* hi = mid # <<<<<<<<<<<<<<
4410
__pyx_v_hi = __pyx_v_mid;
4415
/* "bzrlib/_btree_serializer_pyx.pyx":638
4418
* return NULL # <<<<<<<<<<<<<<
4420
* def __contains__(self, key):
4428
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode._lookup_record");
4431
__Pyx_RefNannyFinishContext();
4435
/* "bzrlib/_btree_serializer_pyx.pyx":640
4438
* def __contains__(self, key): # <<<<<<<<<<<<<<
4439
* cdef char sha1[20]
4440
* cdef gc_chk_sha1_record *record
4443
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_3__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
4444
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_3__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
4445
char __pyx_v_sha1[20];
4446
__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record;
4449
__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_t_2;
4451
__Pyx_RefNannySetupContext("__contains__");
4453
/* "bzrlib/_btree_serializer_pyx.pyx":643
4454
* cdef char sha1[20]
4455
* cdef gc_chk_sha1_record *record
4456
* if _key_to_sha1(key, sha1): # <<<<<<<<<<<<<<
4457
* # If it isn't a sha1 key, then it won't be in this leaf node
4458
* record = self._lookup_record(sha1)
4460
__pyx_t_1 = __pyx_f_6bzrlib_21_btree_serializer_pyx__key_to_sha1(__pyx_v_key, __pyx_v_sha1);
4463
/* "bzrlib/_btree_serializer_pyx.pyx":645
4464
* if _key_to_sha1(key, sha1):
4465
* # If it isn't a sha1 key, then it won't be in this leaf node
4466
* record = self._lookup_record(sha1) # <<<<<<<<<<<<<<
4467
* if record != NULL:
4468
* self.last_key = key
4470
__pyx_t_2 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->__pyx_vtab)->_lookup_record(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), __pyx_v_sha1); if (unlikely(__pyx_t_2 == NULL && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4471
__pyx_v_record = __pyx_t_2;
4473
/* "bzrlib/_btree_serializer_pyx.pyx":646
4474
* # If it isn't a sha1 key, then it won't be in this leaf node
4475
* record = self._lookup_record(sha1)
4476
* if record != NULL: # <<<<<<<<<<<<<<
4477
* self.last_key = key
4478
* self.last_record = record
4480
__pyx_t_3 = (__pyx_v_record != NULL);
4483
/* "bzrlib/_btree_serializer_pyx.pyx":647
4484
* record = self._lookup_record(sha1)
4485
* if record != NULL:
4486
* self.last_key = key # <<<<<<<<<<<<<<
4487
* self.last_record = record
4490
__Pyx_INCREF(__pyx_v_key);
4491
__Pyx_GIVEREF(__pyx_v_key);
4492
__Pyx_GOTREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
4493
__Pyx_DECREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
4494
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key = __pyx_v_key;
4496
/* "bzrlib/_btree_serializer_pyx.pyx":648
4497
* if record != NULL:
4498
* self.last_key = key
4499
* self.last_record = record # <<<<<<<<<<<<<<
4503
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_record = __pyx_v_record;
4505
/* "bzrlib/_btree_serializer_pyx.pyx":649
4506
* self.last_key = key
4507
* self.last_record = record
4508
* return True # <<<<<<<<<<<<<<
4521
/* "bzrlib/_btree_serializer_pyx.pyx":650
4522
* self.last_record = record
4524
* return False # <<<<<<<<<<<<<<
4526
* def __getitem__(self, key):
4534
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.__contains__");
4537
__Pyx_RefNannyFinishContext();
4541
/* "bzrlib/_btree_serializer_pyx.pyx":652
4544
* def __getitem__(self, key): # <<<<<<<<<<<<<<
4545
* cdef char sha1[20]
4546
* cdef gc_chk_sha1_record *record
4549
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_4__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
4550
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_4__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
4551
char __pyx_v_sha1[20];
4552
__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record;
4553
PyObject *__pyx_r = NULL;
4558
__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_t_5;
4559
PyObject *__pyx_t_6 = NULL;
4560
PyObject *__pyx_t_7 = NULL;
4561
__Pyx_RefNannySetupContext("__getitem__");
4563
/* "bzrlib/_btree_serializer_pyx.pyx":655
4564
* cdef char sha1[20]
4565
* cdef gc_chk_sha1_record *record
4566
* record = NULL # <<<<<<<<<<<<<<
4567
* if self.last_record != NULL and key is self.last_key:
4568
* record = self.last_record
4570
__pyx_v_record = NULL;
4572
/* "bzrlib/_btree_serializer_pyx.pyx":656
4573
* cdef gc_chk_sha1_record *record
4575
* if self.last_record != NULL and key is self.last_key: # <<<<<<<<<<<<<<
4576
* record = self.last_record
4577
* elif _key_to_sha1(key, sha1):
4579
__pyx_t_1 = (((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_record != NULL);
4581
__pyx_t_2 = (__pyx_v_key == ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
4582
__pyx_t_3 = __pyx_t_2;
4584
__pyx_t_3 = __pyx_t_1;
4588
/* "bzrlib/_btree_serializer_pyx.pyx":657
4590
* if self.last_record != NULL and key is self.last_key:
4591
* record = self.last_record # <<<<<<<<<<<<<<
4592
* elif _key_to_sha1(key, sha1):
4593
* record = self._lookup_record(sha1)
4595
__pyx_v_record = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_record;
4599
/* "bzrlib/_btree_serializer_pyx.pyx":658
4600
* if self.last_record != NULL and key is self.last_key:
4601
* record = self.last_record
4602
* elif _key_to_sha1(key, sha1): # <<<<<<<<<<<<<<
4603
* record = self._lookup_record(sha1)
4604
* if record == NULL:
4606
__pyx_t_4 = __pyx_f_6bzrlib_21_btree_serializer_pyx__key_to_sha1(__pyx_v_key, __pyx_v_sha1);
4609
/* "bzrlib/_btree_serializer_pyx.pyx":659
4610
* record = self.last_record
4611
* elif _key_to_sha1(key, sha1):
4612
* record = self._lookup_record(sha1) # <<<<<<<<<<<<<<
4613
* if record == NULL:
4614
* raise KeyError('key %r is not present' % (key,))
4616
__pyx_t_5 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->__pyx_vtab)->_lookup_record(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), __pyx_v_sha1); if (unlikely(__pyx_t_5 == NULL && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4617
__pyx_v_record = __pyx_t_5;
4622
/* "bzrlib/_btree_serializer_pyx.pyx":660
4623
* elif _key_to_sha1(key, sha1):
4624
* record = self._lookup_record(sha1)
4625
* if record == NULL: # <<<<<<<<<<<<<<
4626
* raise KeyError('key %r is not present' % (key,))
4627
* return self._record_to_value_and_refs(record)
4629
__pyx_t_3 = (__pyx_v_record == NULL);
4632
/* "bzrlib/_btree_serializer_pyx.pyx":661
4633
* record = self._lookup_record(sha1)
4634
* if record == NULL:
4635
* raise KeyError('key %r is not present' % (key,)) # <<<<<<<<<<<<<<
4636
* return self._record_to_value_and_refs(record)
4639
__pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4640
__Pyx_GOTREF(((PyObject *)__pyx_t_6));
4641
__Pyx_INCREF(__pyx_v_key);
4642
PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_key);
4643
__Pyx_GIVEREF(__pyx_v_key);
4644
__pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4645
__Pyx_GOTREF(((PyObject *)__pyx_t_7));
4646
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
4647
__pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4648
__Pyx_GOTREF(((PyObject *)__pyx_t_6));
4649
PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_7));
4650
__Pyx_GIVEREF(((PyObject *)__pyx_t_7));
4652
__pyx_t_7 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4653
__Pyx_GOTREF(__pyx_t_7);
4654
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
4655
__Pyx_Raise(__pyx_t_7, 0, 0);
4656
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
4657
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4662
/* "bzrlib/_btree_serializer_pyx.pyx":662
4663
* if record == NULL:
4664
* raise KeyError('key %r is not present' % (key,))
4665
* return self._record_to_value_and_refs(record) # <<<<<<<<<<<<<<
4667
* def __len__(self):
4669
__Pyx_XDECREF(__pyx_r);
4670
__pyx_t_7 = ((PyObject *)((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->__pyx_vtab)->_record_to_value_and_refs(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), __pyx_v_record)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4671
__Pyx_GOTREF(__pyx_t_7);
4672
__pyx_r = __pyx_t_7;
4676
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
4679
__Pyx_XDECREF(__pyx_t_6);
4680
__Pyx_XDECREF(__pyx_t_7);
4681
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.__getitem__");
4684
__Pyx_XGIVEREF(__pyx_r);
4685
__Pyx_RefNannyFinishContext();
4689
/* "bzrlib/_btree_serializer_pyx.pyx":664
4690
* return self._record_to_value_and_refs(record)
4692
* def __len__(self): # <<<<<<<<<<<<<<
4693
* return self.num_records
4697
static Py_ssize_t __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_5__len__(PyObject *__pyx_v_self); /*proto*/
4698
static Py_ssize_t __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_5__len__(PyObject *__pyx_v_self) {
4700
__Pyx_RefNannySetupContext("__len__");
4702
/* "bzrlib/_btree_serializer_pyx.pyx":665
4704
* def __len__(self):
4705
* return self.num_records # <<<<<<<<<<<<<<
4707
* def all_keys(self):
4709
__pyx_r = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->num_records;
4714
__Pyx_RefNannyFinishContext();
4718
/* "bzrlib/_btree_serializer_pyx.pyx":667
4719
* return self.num_records
4721
* def all_keys(self): # <<<<<<<<<<<<<<
4726
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_6all_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
4727
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_6all_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
4729
PyObject *__pyx_v_result;
4730
PyObject *__pyx_r = NULL;
4731
PyObject *__pyx_t_1 = NULL;
4734
__Pyx_RefNannySetupContext("all_keys");
4735
__pyx_v_result = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
4737
/* "bzrlib/_btree_serializer_pyx.pyx":669
4738
* def all_keys(self):
4740
* result = [] # <<<<<<<<<<<<<<
4741
* for i from 0 <= i < self.num_records:
4742
* PyList_Append(result, _sha1_to_key(self.records[i].sha1))
4744
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4745
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
4746
__Pyx_DECREF(((PyObject *)__pyx_v_result));
4747
__pyx_v_result = __pyx_t_1;
4750
/* "bzrlib/_btree_serializer_pyx.pyx":670
4753
* for i from 0 <= i < self.num_records: # <<<<<<<<<<<<<<
4754
* PyList_Append(result, _sha1_to_key(self.records[i].sha1))
4757
__pyx_t_2 = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->num_records;
4758
for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
4760
/* "bzrlib/_btree_serializer_pyx.pyx":671
4762
* for i from 0 <= i < self.num_records:
4763
* PyList_Append(result, _sha1_to_key(self.records[i].sha1)) # <<<<<<<<<<<<<<
4767
__pyx_t_1 = ((PyObject *)__pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_key((((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->records[__pyx_v_i]).sha1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4768
__Pyx_GOTREF(__pyx_t_1);
4769
__pyx_t_3 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4770
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4773
/* "bzrlib/_btree_serializer_pyx.pyx":672
4774
* for i from 0 <= i < self.num_records:
4775
* PyList_Append(result, _sha1_to_key(self.records[i].sha1))
4776
* return result # <<<<<<<<<<<<<<
4778
* def all_items(self):
4780
__Pyx_XDECREF(__pyx_r);
4781
__Pyx_INCREF(((PyObject *)__pyx_v_result));
4782
__pyx_r = ((PyObject *)__pyx_v_result);
4785
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
4788
__Pyx_XDECREF(__pyx_t_1);
4789
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.all_keys");
4792
__Pyx_DECREF(__pyx_v_result);
4793
__Pyx_XGIVEREF(__pyx_r);
4794
__Pyx_RefNannyFinishContext();
4798
/* "bzrlib/_btree_serializer_pyx.pyx":674
4801
* def all_items(self): # <<<<<<<<<<<<<<
4806
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7all_items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
4807
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7all_items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
4809
PyObject *__pyx_v_result;
4810
StaticTuple *__pyx_v_item;
4811
PyObject *__pyx_r = NULL;
4812
PyObject *__pyx_t_1 = NULL;
4815
__Pyx_RefNannySetupContext("all_items");
4816
__pyx_v_result = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
4817
__pyx_v_item = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
4819
/* "bzrlib/_btree_serializer_pyx.pyx":676
4820
* def all_items(self):
4822
* result = [] # <<<<<<<<<<<<<<
4823
* for i from 0 <= i < self.num_records:
4824
* item = self._record_to_item(&self.records[i])
4826
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4827
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
4828
__Pyx_DECREF(((PyObject *)__pyx_v_result));
4829
__pyx_v_result = __pyx_t_1;
4832
/* "bzrlib/_btree_serializer_pyx.pyx":677
4835
* for i from 0 <= i < self.num_records: # <<<<<<<<<<<<<<
4836
* item = self._record_to_item(&self.records[i])
4837
* PyList_Append(result, item)
4839
__pyx_t_2 = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->num_records;
4840
for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
4842
/* "bzrlib/_btree_serializer_pyx.pyx":678
4844
* for i from 0 <= i < self.num_records:
4845
* item = self._record_to_item(&self.records[i]) # <<<<<<<<<<<<<<
4846
* PyList_Append(result, item)
4849
__pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->__pyx_vtab)->_record_to_item(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), (&(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->records[__pyx_v_i])))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4850
__Pyx_GOTREF(__pyx_t_1);
4851
__Pyx_DECREF(((PyObject *)__pyx_v_item));
4852
__pyx_v_item = ((StaticTuple *)__pyx_t_1);
4855
/* "bzrlib/_btree_serializer_pyx.pyx":679
4856
* for i from 0 <= i < self.num_records:
4857
* item = self._record_to_item(&self.records[i])
4858
* PyList_Append(result, item) # <<<<<<<<<<<<<<
4862
__pyx_t_3 = PyList_Append(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_v_item)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4865
/* "bzrlib/_btree_serializer_pyx.pyx":680
4866
* item = self._record_to_item(&self.records[i])
4867
* PyList_Append(result, item)
4868
* return result # <<<<<<<<<<<<<<
4870
* cdef int _count_records(self, char *c_content, char *c_end): # cannot_raise
4872
__Pyx_XDECREF(__pyx_r);
4873
__Pyx_INCREF(((PyObject *)__pyx_v_result));
4874
__pyx_r = ((PyObject *)__pyx_v_result);
4877
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
4880
__Pyx_XDECREF(__pyx_t_1);
4881
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.all_items");
4884
__Pyx_DECREF(__pyx_v_result);
4885
__Pyx_DECREF((PyObject *)__pyx_v_item);
4886
__Pyx_XGIVEREF(__pyx_r);
4887
__Pyx_RefNannyFinishContext();
4891
/* "bzrlib/_btree_serializer_pyx.pyx":682
4894
* cdef int _count_records(self, char *c_content, char *c_end): # cannot_raise # <<<<<<<<<<<<<<
4895
* """Count how many records are in this section."""
4899
static int __pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__count_records(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_c_content, char *__pyx_v_c_end) {
4900
char *__pyx_v_c_cur;
4901
int __pyx_v_num_records;
4906
__Pyx_RefNannySetupContext("_count_records");
4908
/* "bzrlib/_btree_serializer_pyx.pyx":687
4909
* cdef int num_records
4911
* c_cur = c_content # <<<<<<<<<<<<<<
4913
* while c_cur != NULL and c_cur < c_end:
4915
__pyx_v_c_cur = __pyx_v_c_content;
4917
/* "bzrlib/_btree_serializer_pyx.pyx":688
4920
* num_records = 0 # <<<<<<<<<<<<<<
4921
* while c_cur != NULL and c_cur < c_end:
4922
* c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur);
4924
__pyx_v_num_records = 0;
4926
/* "bzrlib/_btree_serializer_pyx.pyx":689
4929
* while c_cur != NULL and c_cur < c_end: # <<<<<<<<<<<<<<
4930
* c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur);
4934
__pyx_t_1 = (__pyx_v_c_cur != NULL);
4936
__pyx_t_2 = (__pyx_v_c_cur < __pyx_v_c_end);
4937
__pyx_t_3 = __pyx_t_2;
4939
__pyx_t_3 = __pyx_t_1;
4941
if (!__pyx_t_3) break;
4943
/* "bzrlib/_btree_serializer_pyx.pyx":690
4945
* while c_cur != NULL and c_cur < c_end:
4946
* c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur); # <<<<<<<<<<<<<<
4950
__pyx_v_c_cur = ((char *)memchr(__pyx_v_c_cur, '\n', (__pyx_v_c_end - __pyx_v_c_cur)));
4952
/* "bzrlib/_btree_serializer_pyx.pyx":691
4953
* while c_cur != NULL and c_cur < c_end:
4954
* c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur);
4955
* if c_cur == NULL: # <<<<<<<<<<<<<<
4959
__pyx_t_3 = (__pyx_v_c_cur == NULL);
4962
/* "bzrlib/_btree_serializer_pyx.pyx":692
4963
* c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur);
4965
* break # <<<<<<<<<<<<<<
4967
* num_records = num_records + 1
4969
goto __pyx_L4_break;
4974
/* "bzrlib/_btree_serializer_pyx.pyx":693
4977
* c_cur = c_cur + 1 # <<<<<<<<<<<<<<
4978
* num_records = num_records + 1
4979
* return num_records
4981
__pyx_v_c_cur = (__pyx_v_c_cur + 1);
4983
/* "bzrlib/_btree_serializer_pyx.pyx":694
4986
* num_records = num_records + 1 # <<<<<<<<<<<<<<
4987
* return num_records
4990
__pyx_v_num_records = (__pyx_v_num_records + 1);
4994
/* "bzrlib/_btree_serializer_pyx.pyx":695
4996
* num_records = num_records + 1
4997
* return num_records # <<<<<<<<<<<<<<
4999
* cdef _parse_bytes(self, bytes):
5001
__pyx_r = __pyx_v_num_records;
5006
__Pyx_RefNannyFinishContext();
5010
/* "bzrlib/_btree_serializer_pyx.pyx":697
5011
* return num_records
5013
* cdef _parse_bytes(self, bytes): # <<<<<<<<<<<<<<
5014
* """Parse the string 'bytes' into content."""
5015
* cdef char *c_bytes
5018
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_bytes(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_bytes) {
5019
char *__pyx_v_c_bytes;
5020
char *__pyx_v_c_cur;
5021
char *__pyx_v_c_end;
5022
Py_ssize_t __pyx_v_n_bytes;
5023
int __pyx_v_num_records;
5025
__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_cur_record;
5026
PyObject *__pyx_r = NULL;
5028
PyObject *__pyx_t_2 = NULL;
5030
PyObject *__pyx_t_4 = NULL;
5035
__Pyx_RefNannySetupContext("_parse_bytes");
5037
/* "bzrlib/_btree_serializer_pyx.pyx":707
5038
* cdef gc_chk_sha1_record *cur_record
5040
* if not PyString_CheckExact(bytes): # <<<<<<<<<<<<<<
5041
* raise TypeError('We only support parsing plain 8-bit strings.')
5042
* # Pass 1, count how many records there will be
5044
__pyx_t_1 = (!PyString_CheckExact(__pyx_v_bytes));
5047
/* "bzrlib/_btree_serializer_pyx.pyx":708
5049
* if not PyString_CheckExact(bytes):
5050
* raise TypeError('We only support parsing plain 8-bit strings.') # <<<<<<<<<<<<<<
5051
* # Pass 1, count how many records there will be
5052
* n_bytes = PyString_GET_SIZE(bytes)
5054
__pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_29), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5055
__Pyx_GOTREF(__pyx_t_2);
5056
__Pyx_Raise(__pyx_t_2, 0, 0);
5057
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5058
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5063
/* "bzrlib/_btree_serializer_pyx.pyx":710
5064
* raise TypeError('We only support parsing plain 8-bit strings.')
5065
* # Pass 1, count how many records there will be
5066
* n_bytes = PyString_GET_SIZE(bytes) # <<<<<<<<<<<<<<
5067
* c_bytes = PyString_AS_STRING(bytes)
5068
* c_end = c_bytes + n_bytes
5070
__pyx_v_n_bytes = PyString_GET_SIZE(__pyx_v_bytes);
5072
/* "bzrlib/_btree_serializer_pyx.pyx":711
5073
* # Pass 1, count how many records there will be
5074
* n_bytes = PyString_GET_SIZE(bytes)
5075
* c_bytes = PyString_AS_STRING(bytes) # <<<<<<<<<<<<<<
5076
* c_end = c_bytes + n_bytes
5077
* if strncmp(c_bytes, 'type=leaf\n', 10):
5079
__pyx_v_c_bytes = PyString_AS_STRING(__pyx_v_bytes);
5081
/* "bzrlib/_btree_serializer_pyx.pyx":712
5082
* n_bytes = PyString_GET_SIZE(bytes)
5083
* c_bytes = PyString_AS_STRING(bytes)
5084
* c_end = c_bytes + n_bytes # <<<<<<<<<<<<<<
5085
* if strncmp(c_bytes, 'type=leaf\n', 10):
5086
* raise ValueError("bytes did not start with 'type=leaf\\n': %r"
5088
__pyx_v_c_end = (__pyx_v_c_bytes + __pyx_v_n_bytes);
5090
/* "bzrlib/_btree_serializer_pyx.pyx":713
5091
* c_bytes = PyString_AS_STRING(bytes)
5092
* c_end = c_bytes + n_bytes
5093
* if strncmp(c_bytes, 'type=leaf\n', 10): # <<<<<<<<<<<<<<
5094
* raise ValueError("bytes did not start with 'type=leaf\\n': %r"
5097
__pyx_t_3 = strncmp(__pyx_v_c_bytes, __pyx_k_30, 10);
5100
/* "bzrlib/_btree_serializer_pyx.pyx":715
5101
* if strncmp(c_bytes, 'type=leaf\n', 10):
5102
* raise ValueError("bytes did not start with 'type=leaf\\n': %r"
5103
* % (bytes[:10],)) # <<<<<<<<<<<<<<
5104
* c_cur = c_bytes + 10
5105
* num_records = self._count_records(c_cur, c_end)
5107
__pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_v_bytes, 0, 10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5108
__Pyx_GOTREF(__pyx_t_2);
5109
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5110
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
5111
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
5112
__Pyx_GIVEREF(__pyx_t_2);
5114
__pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5115
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
5116
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
5117
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5118
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
5119
PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
5120
__Pyx_GIVEREF(((PyObject *)__pyx_t_2));
5122
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5123
__Pyx_GOTREF(__pyx_t_2);
5124
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
5125
__Pyx_Raise(__pyx_t_2, 0, 0);
5126
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5127
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5132
/* "bzrlib/_btree_serializer_pyx.pyx":716
5133
* raise ValueError("bytes did not start with 'type=leaf\\n': %r"
5135
* c_cur = c_bytes + 10 # <<<<<<<<<<<<<<
5136
* num_records = self._count_records(c_cur, c_end)
5137
* # Now allocate the memory for these items, and go to town
5139
__pyx_v_c_cur = (__pyx_v_c_bytes + 10);
5141
/* "bzrlib/_btree_serializer_pyx.pyx":717
5143
* c_cur = c_bytes + 10
5144
* num_records = self._count_records(c_cur, c_end) # <<<<<<<<<<<<<<
5145
* # Now allocate the memory for these items, and go to town
5146
* self.records = <gc_chk_sha1_record*>PyMem_Malloc(num_records *
5148
__pyx_v_num_records = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_count_records(__pyx_v_self, __pyx_v_c_cur, __pyx_v_c_end);
5150
/* "bzrlib/_btree_serializer_pyx.pyx":719
5151
* num_records = self._count_records(c_cur, c_end)
5152
* # Now allocate the memory for these items, and go to town
5153
* self.records = <gc_chk_sha1_record*>PyMem_Malloc(num_records * # <<<<<<<<<<<<<<
5154
* (sizeof(unsigned short) + sizeof(gc_chk_sha1_record)))
5155
* self.num_records = num_records
5157
__pyx_v_self->records = ((__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *)PyMem_Malloc((__pyx_v_num_records * ((sizeof(unsigned short)) + (sizeof(__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record))))));
5159
/* "bzrlib/_btree_serializer_pyx.pyx":721
5160
* self.records = <gc_chk_sha1_record*>PyMem_Malloc(num_records *
5161
* (sizeof(unsigned short) + sizeof(gc_chk_sha1_record)))
5162
* self.num_records = num_records # <<<<<<<<<<<<<<
5163
* cur_record = self.records
5166
__pyx_v_self->num_records = __pyx_v_num_records;
5168
/* "bzrlib/_btree_serializer_pyx.pyx":722
5169
* (sizeof(unsigned short) + sizeof(gc_chk_sha1_record)))
5170
* self.num_records = num_records
5171
* cur_record = self.records # <<<<<<<<<<<<<<
5173
* while c_cur != NULL and c_cur < c_end and entry < num_records:
5175
__pyx_v_cur_record = __pyx_v_self->records;
5177
/* "bzrlib/_btree_serializer_pyx.pyx":723
5178
* self.num_records = num_records
5179
* cur_record = self.records
5180
* entry = 0 # <<<<<<<<<<<<<<
5181
* while c_cur != NULL and c_cur < c_end and entry < num_records:
5182
* c_cur = self._parse_one_entry(c_cur, c_end, cur_record)
5186
/* "bzrlib/_btree_serializer_pyx.pyx":724
5187
* cur_record = self.records
5189
* while c_cur != NULL and c_cur < c_end and entry < num_records: # <<<<<<<<<<<<<<
5190
* c_cur = self._parse_one_entry(c_cur, c_end, cur_record)
5191
* cur_record = cur_record + 1
5194
__pyx_t_1 = (__pyx_v_c_cur != NULL);
5196
__pyx_t_5 = (__pyx_v_c_cur < __pyx_v_c_end);
5198
__pyx_t_6 = (__pyx_v_entry < __pyx_v_num_records);
5199
__pyx_t_7 = __pyx_t_6;
5201
__pyx_t_7 = __pyx_t_5;
5203
__pyx_t_5 = __pyx_t_7;
5205
__pyx_t_5 = __pyx_t_1;
5207
if (!__pyx_t_5) break;
5209
/* "bzrlib/_btree_serializer_pyx.pyx":725
5211
* while c_cur != NULL and c_cur < c_end and entry < num_records:
5212
* c_cur = self._parse_one_entry(c_cur, c_end, cur_record) # <<<<<<<<<<<<<<
5213
* cur_record = cur_record + 1
5216
__pyx_t_8 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_parse_one_entry(__pyx_v_self, __pyx_v_c_cur, __pyx_v_c_end, __pyx_v_cur_record); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5217
__pyx_v_c_cur = __pyx_t_8;
5219
/* "bzrlib/_btree_serializer_pyx.pyx":726
5220
* while c_cur != NULL and c_cur < c_end and entry < num_records:
5221
* c_cur = self._parse_one_entry(c_cur, c_end, cur_record)
5222
* cur_record = cur_record + 1 # <<<<<<<<<<<<<<
5224
* if (entry != self.num_records
5226
__pyx_v_cur_record = (__pyx_v_cur_record + 1);
5228
/* "bzrlib/_btree_serializer_pyx.pyx":727
5229
* c_cur = self._parse_one_entry(c_cur, c_end, cur_record)
5230
* cur_record = cur_record + 1
5231
* entry = entry + 1 # <<<<<<<<<<<<<<
5232
* if (entry != self.num_records
5235
__pyx_v_entry = (__pyx_v_entry + 1);
5238
/* "bzrlib/_btree_serializer_pyx.pyx":728
5239
* cur_record = cur_record + 1
5241
* if (entry != self.num_records # <<<<<<<<<<<<<<
5243
* or cur_record != self.records + self.num_records):
5245
__pyx_t_5 = (__pyx_v_entry != __pyx_v_self->num_records);
5248
/* "bzrlib/_btree_serializer_pyx.pyx":730
5249
* if (entry != self.num_records
5251
* or cur_record != self.records + self.num_records): # <<<<<<<<<<<<<<
5252
* raise ValueError('Something went wrong while parsing.')
5253
* # Pass 3: build the offset map
5255
__pyx_t_1 = (__pyx_v_c_cur != __pyx_v_c_end);
5257
__pyx_t_7 = (__pyx_v_cur_record != (__pyx_v_self->records + __pyx_v_self->num_records));
5258
__pyx_t_6 = __pyx_t_7;
5260
__pyx_t_6 = __pyx_t_1;
5262
__pyx_t_1 = __pyx_t_6;
5264
__pyx_t_1 = __pyx_t_5;
5268
/* "bzrlib/_btree_serializer_pyx.pyx":731
5270
* or cur_record != self.records + self.num_records):
5271
* raise ValueError('Something went wrong while parsing.') # <<<<<<<<<<<<<<
5272
* # Pass 3: build the offset map
5273
* self._compute_common()
5275
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_33), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5276
__Pyx_GOTREF(__pyx_t_2);
5277
__Pyx_Raise(__pyx_t_2, 0, 0);
5278
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5279
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5284
/* "bzrlib/_btree_serializer_pyx.pyx":733
5285
* raise ValueError('Something went wrong while parsing.')
5286
* # Pass 3: build the offset map
5287
* self._compute_common() # <<<<<<<<<<<<<<
5289
* cdef char *_parse_one_entry(self, char *c_cur, char *c_end,
5291
__pyx_t_2 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_compute_common(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5292
__Pyx_GOTREF(__pyx_t_2);
5293
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5295
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
5298
__Pyx_XDECREF(__pyx_t_2);
5299
__Pyx_XDECREF(__pyx_t_4);
5300
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode._parse_bytes");
5303
__Pyx_XGIVEREF(__pyx_r);
5304
__Pyx_RefNannyFinishContext();
5308
/* "bzrlib/_btree_serializer_pyx.pyx":735
5309
* self._compute_common()
5311
* cdef char *_parse_one_entry(self, char *c_cur, char *c_end, # <<<<<<<<<<<<<<
5312
* gc_chk_sha1_record *cur_record) except NULL:
5313
* """Read a single sha record from the bytes.
5316
static char *__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_one_entry(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_c_cur, char *__pyx_v_c_end, __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_cur_record) {
5317
char *__pyx_v_c_next;
5320
PyObject *__pyx_t_2 = NULL;
5321
PyObject *__pyx_t_3 = NULL;
5325
__Pyx_RefNannySetupContext("_parse_one_entry");
5327
/* "bzrlib/_btree_serializer_pyx.pyx":742
5330
* if strncmp(c_cur, 'sha1:', 5): # <<<<<<<<<<<<<<
5331
* raise ValueError('line did not start with sha1: %r'
5332
* % (safe_string_from_size(c_cur, 10),))
5334
__pyx_t_1 = strncmp(__pyx_v_c_cur, __pyx_k_3, 5);
5337
/* "bzrlib/_btree_serializer_pyx.pyx":744
5338
* if strncmp(c_cur, 'sha1:', 5):
5339
* raise ValueError('line did not start with sha1: %r'
5340
* % (safe_string_from_size(c_cur, 10),)) # <<<<<<<<<<<<<<
5342
* c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
5344
__pyx_t_2 = __pyx_f_6bzrlib_21_btree_serializer_pyx_safe_string_from_size(__pyx_v_c_cur, 10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5345
__Pyx_GOTREF(__pyx_t_2);
5346
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5347
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
5348
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
5349
__Pyx_GIVEREF(__pyx_t_2);
5351
__pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_34), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5352
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
5353
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
5354
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5355
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
5356
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
5357
__Pyx_GIVEREF(((PyObject *)__pyx_t_2));
5359
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5360
__Pyx_GOTREF(__pyx_t_2);
5361
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
5362
__Pyx_Raise(__pyx_t_2, 0, 0);
5363
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5364
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5369
/* "bzrlib/_btree_serializer_pyx.pyx":745
5370
* raise ValueError('line did not start with sha1: %r'
5371
* % (safe_string_from_size(c_cur, 10),))
5372
* c_cur = c_cur + 5 # <<<<<<<<<<<<<<
5373
* c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
5374
* if c_next == NULL or (c_next - c_cur != 40):
5376
__pyx_v_c_cur = (__pyx_v_c_cur + 5);
5378
/* "bzrlib/_btree_serializer_pyx.pyx":746
5379
* % (safe_string_from_size(c_cur, 10),))
5381
* c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur) # <<<<<<<<<<<<<<
5382
* if c_next == NULL or (c_next - c_cur != 40):
5383
* raise ValueError('Line did not contain 40 hex bytes')
5385
__pyx_v_c_next = ((char *)memchr(__pyx_v_c_cur, '\x00', (__pyx_v_c_end - __pyx_v_c_cur)));
5387
/* "bzrlib/_btree_serializer_pyx.pyx":747
5389
* c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
5390
* if c_next == NULL or (c_next - c_cur != 40): # <<<<<<<<<<<<<<
5391
* raise ValueError('Line did not contain 40 hex bytes')
5392
* if not _unhexlify_sha1(c_cur, cur_record.sha1):
5394
__pyx_t_4 = (__pyx_v_c_next == NULL);
5396
__pyx_t_5 = ((__pyx_v_c_next - __pyx_v_c_cur) != 40);
5397
__pyx_t_6 = __pyx_t_5;
5399
__pyx_t_6 = __pyx_t_4;
5403
/* "bzrlib/_btree_serializer_pyx.pyx":748
5404
* c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
5405
* if c_next == NULL or (c_next - c_cur != 40):
5406
* raise ValueError('Line did not contain 40 hex bytes') # <<<<<<<<<<<<<<
5407
* if not _unhexlify_sha1(c_cur, cur_record.sha1):
5408
* raise ValueError('We failed to unhexlify')
5410
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_36), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5411
__Pyx_GOTREF(__pyx_t_2);
5412
__Pyx_Raise(__pyx_t_2, 0, 0);
5413
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5414
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5419
/* "bzrlib/_btree_serializer_pyx.pyx":749
5420
* if c_next == NULL or (c_next - c_cur != 40):
5421
* raise ValueError('Line did not contain 40 hex bytes')
5422
* if not _unhexlify_sha1(c_cur, cur_record.sha1): # <<<<<<<<<<<<<<
5423
* raise ValueError('We failed to unhexlify')
5424
* c_cur = c_next + 1
5426
__pyx_t_6 = (!__pyx_f_6bzrlib_21_btree_serializer_pyx__unhexlify_sha1(__pyx_v_c_cur, __pyx_v_cur_record->sha1));
5429
/* "bzrlib/_btree_serializer_pyx.pyx":750
5430
* raise ValueError('Line did not contain 40 hex bytes')
5431
* if not _unhexlify_sha1(c_cur, cur_record.sha1):
5432
* raise ValueError('We failed to unhexlify') # <<<<<<<<<<<<<<
5433
* c_cur = c_next + 1
5434
* if c_cur[0] != c'\0':
5436
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_38), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5437
__Pyx_GOTREF(__pyx_t_2);
5438
__Pyx_Raise(__pyx_t_2, 0, 0);
5439
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5440
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5445
/* "bzrlib/_btree_serializer_pyx.pyx":751
5446
* if not _unhexlify_sha1(c_cur, cur_record.sha1):
5447
* raise ValueError('We failed to unhexlify')
5448
* c_cur = c_next + 1 # <<<<<<<<<<<<<<
5449
* if c_cur[0] != c'\0':
5450
* raise ValueError('only 1 null, not 2 as expected')
5452
__pyx_v_c_cur = (__pyx_v_c_next + 1);
5454
/* "bzrlib/_btree_serializer_pyx.pyx":752
5455
* raise ValueError('We failed to unhexlify')
5456
* c_cur = c_next + 1
5457
* if c_cur[0] != c'\0': # <<<<<<<<<<<<<<
5458
* raise ValueError('only 1 null, not 2 as expected')
5461
__pyx_t_6 = ((__pyx_v_c_cur[0]) != '\x00');
5464
/* "bzrlib/_btree_serializer_pyx.pyx":753
5465
* c_cur = c_next + 1
5466
* if c_cur[0] != c'\0':
5467
* raise ValueError('only 1 null, not 2 as expected') # <<<<<<<<<<<<<<
5469
* cur_record.block_offset = strtoll(c_cur, &c_next, 10)
5471
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_40), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5472
__Pyx_GOTREF(__pyx_t_2);
5473
__Pyx_Raise(__pyx_t_2, 0, 0);
5474
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5475
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5480
/* "bzrlib/_btree_serializer_pyx.pyx":754
5481
* if c_cur[0] != c'\0':
5482
* raise ValueError('only 1 null, not 2 as expected')
5483
* c_cur = c_cur + 1 # <<<<<<<<<<<<<<
5484
* cur_record.block_offset = strtoll(c_cur, &c_next, 10)
5485
* if c_cur == c_next or c_next[0] != c' ':
5487
__pyx_v_c_cur = (__pyx_v_c_cur + 1);
5489
/* "bzrlib/_btree_serializer_pyx.pyx":755
5490
* raise ValueError('only 1 null, not 2 as expected')
5492
* cur_record.block_offset = strtoll(c_cur, &c_next, 10) # <<<<<<<<<<<<<<
5493
* if c_cur == c_next or c_next[0] != c' ':
5494
* raise ValueError('Failed to parse block offset')
5496
__pyx_v_cur_record->block_offset = strtoll(__pyx_v_c_cur, (&__pyx_v_c_next), 10);
5498
/* "bzrlib/_btree_serializer_pyx.pyx":756
5500
* cur_record.block_offset = strtoll(c_cur, &c_next, 10)
5501
* if c_cur == c_next or c_next[0] != c' ': # <<<<<<<<<<<<<<
5502
* raise ValueError('Failed to parse block offset')
5503
* c_cur = c_next + 1
5505
__pyx_t_6 = (__pyx_v_c_cur == __pyx_v_c_next);
5507
__pyx_t_4 = ((__pyx_v_c_next[0]) != ' ');
5508
__pyx_t_5 = __pyx_t_4;
5510
__pyx_t_5 = __pyx_t_6;
5514
/* "bzrlib/_btree_serializer_pyx.pyx":757
5515
* cur_record.block_offset = strtoll(c_cur, &c_next, 10)
5516
* if c_cur == c_next or c_next[0] != c' ':
5517
* raise ValueError('Failed to parse block offset') # <<<<<<<<<<<<<<
5518
* c_cur = c_next + 1
5519
* cur_record.block_length = strtoul(c_cur, &c_next, 10)
5521
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5522
__Pyx_GOTREF(__pyx_t_2);
5523
__Pyx_Raise(__pyx_t_2, 0, 0);
5524
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5525
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5530
/* "bzrlib/_btree_serializer_pyx.pyx":758
5531
* if c_cur == c_next or c_next[0] != c' ':
5532
* raise ValueError('Failed to parse block offset')
5533
* c_cur = c_next + 1 # <<<<<<<<<<<<<<
5534
* cur_record.block_length = strtoul(c_cur, &c_next, 10)
5535
* if c_cur == c_next or c_next[0] != c' ':
5537
__pyx_v_c_cur = (__pyx_v_c_next + 1);
5539
/* "bzrlib/_btree_serializer_pyx.pyx":759
5540
* raise ValueError('Failed to parse block offset')
5541
* c_cur = c_next + 1
5542
* cur_record.block_length = strtoul(c_cur, &c_next, 10) # <<<<<<<<<<<<<<
5543
* if c_cur == c_next or c_next[0] != c' ':
5544
* raise ValueError('Failed to parse block length')
5546
__pyx_v_cur_record->block_length = strtoul(__pyx_v_c_cur, (&__pyx_v_c_next), 10);
5548
/* "bzrlib/_btree_serializer_pyx.pyx":760
5549
* c_cur = c_next + 1
5550
* cur_record.block_length = strtoul(c_cur, &c_next, 10)
5551
* if c_cur == c_next or c_next[0] != c' ': # <<<<<<<<<<<<<<
5552
* raise ValueError('Failed to parse block length')
5553
* c_cur = c_next + 1
5555
__pyx_t_5 = (__pyx_v_c_cur == __pyx_v_c_next);
5557
__pyx_t_6 = ((__pyx_v_c_next[0]) != ' ');
5558
__pyx_t_4 = __pyx_t_6;
5560
__pyx_t_4 = __pyx_t_5;
5564
/* "bzrlib/_btree_serializer_pyx.pyx":761
5565
* cur_record.block_length = strtoul(c_cur, &c_next, 10)
5566
* if c_cur == c_next or c_next[0] != c' ':
5567
* raise ValueError('Failed to parse block length') # <<<<<<<<<<<<<<
5568
* c_cur = c_next + 1
5569
* cur_record.record_start = strtoul(c_cur, &c_next, 10)
5571
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_44), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5572
__Pyx_GOTREF(__pyx_t_2);
5573
__Pyx_Raise(__pyx_t_2, 0, 0);
5574
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5575
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5580
/* "bzrlib/_btree_serializer_pyx.pyx":762
5581
* if c_cur == c_next or c_next[0] != c' ':
5582
* raise ValueError('Failed to parse block length')
5583
* c_cur = c_next + 1 # <<<<<<<<<<<<<<
5584
* cur_record.record_start = strtoul(c_cur, &c_next, 10)
5585
* if c_cur == c_next or c_next[0] != c' ':
5587
__pyx_v_c_cur = (__pyx_v_c_next + 1);
5589
/* "bzrlib/_btree_serializer_pyx.pyx":763
5590
* raise ValueError('Failed to parse block length')
5591
* c_cur = c_next + 1
5592
* cur_record.record_start = strtoul(c_cur, &c_next, 10) # <<<<<<<<<<<<<<
5593
* if c_cur == c_next or c_next[0] != c' ':
5594
* raise ValueError('Failed to parse block length')
5596
__pyx_v_cur_record->record_start = strtoul(__pyx_v_c_cur, (&__pyx_v_c_next), 10);
5598
/* "bzrlib/_btree_serializer_pyx.pyx":764
5599
* c_cur = c_next + 1
5600
* cur_record.record_start = strtoul(c_cur, &c_next, 10)
5601
* if c_cur == c_next or c_next[0] != c' ': # <<<<<<<<<<<<<<
5602
* raise ValueError('Failed to parse block length')
5603
* c_cur = c_next + 1
5605
__pyx_t_4 = (__pyx_v_c_cur == __pyx_v_c_next);
5607
__pyx_t_5 = ((__pyx_v_c_next[0]) != ' ');
5608
__pyx_t_6 = __pyx_t_5;
5610
__pyx_t_6 = __pyx_t_4;
5614
/* "bzrlib/_btree_serializer_pyx.pyx":765
5615
* cur_record.record_start = strtoul(c_cur, &c_next, 10)
5616
* if c_cur == c_next or c_next[0] != c' ':
5617
* raise ValueError('Failed to parse block length') # <<<<<<<<<<<<<<
5618
* c_cur = c_next + 1
5619
* cur_record.record_end = strtoul(c_cur, &c_next, 10)
5621
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_45), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5622
__Pyx_GOTREF(__pyx_t_2);
5623
__Pyx_Raise(__pyx_t_2, 0, 0);
5624
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5625
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5630
/* "bzrlib/_btree_serializer_pyx.pyx":766
5631
* if c_cur == c_next or c_next[0] != c' ':
5632
* raise ValueError('Failed to parse block length')
5633
* c_cur = c_next + 1 # <<<<<<<<<<<<<<
5634
* cur_record.record_end = strtoul(c_cur, &c_next, 10)
5635
* if c_cur == c_next or c_next[0] != c'\n':
5637
__pyx_v_c_cur = (__pyx_v_c_next + 1);
5639
/* "bzrlib/_btree_serializer_pyx.pyx":767
5640
* raise ValueError('Failed to parse block length')
5641
* c_cur = c_next + 1
5642
* cur_record.record_end = strtoul(c_cur, &c_next, 10) # <<<<<<<<<<<<<<
5643
* if c_cur == c_next or c_next[0] != c'\n':
5644
* raise ValueError('Failed to parse record end')
5646
__pyx_v_cur_record->record_end = strtoul(__pyx_v_c_cur, (&__pyx_v_c_next), 10);
5648
/* "bzrlib/_btree_serializer_pyx.pyx":768
5649
* c_cur = c_next + 1
5650
* cur_record.record_end = strtoul(c_cur, &c_next, 10)
5651
* if c_cur == c_next or c_next[0] != c'\n': # <<<<<<<<<<<<<<
5652
* raise ValueError('Failed to parse record end')
5653
* c_cur = c_next + 1
5655
__pyx_t_6 = (__pyx_v_c_cur == __pyx_v_c_next);
5657
__pyx_t_4 = ((__pyx_v_c_next[0]) != '\n');
5658
__pyx_t_5 = __pyx_t_4;
5660
__pyx_t_5 = __pyx_t_6;
5664
/* "bzrlib/_btree_serializer_pyx.pyx":769
5665
* cur_record.record_end = strtoul(c_cur, &c_next, 10)
5666
* if c_cur == c_next or c_next[0] != c'\n':
5667
* raise ValueError('Failed to parse record end') # <<<<<<<<<<<<<<
5668
* c_cur = c_next + 1
5671
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5672
__Pyx_GOTREF(__pyx_t_2);
5673
__Pyx_Raise(__pyx_t_2, 0, 0);
5674
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5675
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5680
/* "bzrlib/_btree_serializer_pyx.pyx":770
5681
* if c_cur == c_next or c_next[0] != c'\n':
5682
* raise ValueError('Failed to parse record end')
5683
* c_cur = c_next + 1 # <<<<<<<<<<<<<<
5687
__pyx_v_c_cur = (__pyx_v_c_next + 1);
5689
/* "bzrlib/_btree_serializer_pyx.pyx":771
5690
* raise ValueError('Failed to parse record end')
5691
* c_cur = c_next + 1
5692
* return c_cur # <<<<<<<<<<<<<<
5694
* cdef int _offset_for_sha1(self, char *sha1) except -1:
5696
__pyx_r = __pyx_v_c_cur;
5702
__Pyx_XDECREF(__pyx_t_2);
5703
__Pyx_XDECREF(__pyx_t_3);
5704
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode._parse_one_entry");
5707
__Pyx_RefNannyFinishContext();
5711
/* "bzrlib/_btree_serializer_pyx.pyx":773
5714
* cdef int _offset_for_sha1(self, char *sha1) except -1: # <<<<<<<<<<<<<<
5715
* """Find the first interesting 8-bits of this sha1."""
5716
* cdef int this_offset
5719
static int __pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__offset_for_sha1(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_sha1) {
5720
int __pyx_v_this_offset;
5721
unsigned int __pyx_v_as_uint;
5723
__Pyx_RefNannySetupContext("_offset_for_sha1");
5725
/* "bzrlib/_btree_serializer_pyx.pyx":777
5726
* cdef int this_offset
5727
* cdef unsigned int as_uint
5728
* as_uint = _sha1_to_uint(sha1) # <<<<<<<<<<<<<<
5729
* this_offset = (as_uint >> self.common_shift) & 0xFF
5730
* return this_offset
5732
__pyx_v_as_uint = __pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_uint(__pyx_v_sha1);
5734
/* "bzrlib/_btree_serializer_pyx.pyx":778
5735
* cdef unsigned int as_uint
5736
* as_uint = _sha1_to_uint(sha1)
5737
* this_offset = (as_uint >> self.common_shift) & 0xFF # <<<<<<<<<<<<<<
5738
* return this_offset
5741
__pyx_v_this_offset = ((__pyx_v_as_uint >> __pyx_v_self->common_shift) & 0xFF);
5743
/* "bzrlib/_btree_serializer_pyx.pyx":779
5744
* as_uint = _sha1_to_uint(sha1)
5745
* this_offset = (as_uint >> self.common_shift) & 0xFF
5746
* return this_offset # <<<<<<<<<<<<<<
5748
* def _get_offset_for_sha1(self, sha1):
5750
__pyx_r = __pyx_v_this_offset;
5755
__Pyx_RefNannyFinishContext();
5759
/* "bzrlib/_btree_serializer_pyx.pyx":781
5760
* return this_offset
5762
* def _get_offset_for_sha1(self, sha1): # <<<<<<<<<<<<<<
5763
* return self._offset_for_sha1(PyString_AS_STRING(sha1))
5767
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8_get_offset_for_sha1(PyObject *__pyx_v_self, PyObject *__pyx_v_sha1); /*proto*/
5768
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8_get_offset_for_sha1(PyObject *__pyx_v_self, PyObject *__pyx_v_sha1) {
5769
PyObject *__pyx_r = NULL;
5771
PyObject *__pyx_t_2 = NULL;
5772
__Pyx_RefNannySetupContext("_get_offset_for_sha1");
5774
/* "bzrlib/_btree_serializer_pyx.pyx":782
5776
* def _get_offset_for_sha1(self, sha1):
5777
* return self._offset_for_sha1(PyString_AS_STRING(sha1)) # <<<<<<<<<<<<<<
5779
* cdef _compute_common(self):
5781
__Pyx_XDECREF(__pyx_r);
5782
__pyx_t_1 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->__pyx_vtab)->_offset_for_sha1(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), PyString_AS_STRING(__pyx_v_sha1)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5783
__pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5784
__Pyx_GOTREF(__pyx_t_2);
5785
__pyx_r = __pyx_t_2;
5789
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
5792
__Pyx_XDECREF(__pyx_t_2);
5793
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode._get_offset_for_sha1");
5796
__Pyx_XGIVEREF(__pyx_r);
5797
__Pyx_RefNannyFinishContext();
5801
/* "bzrlib/_btree_serializer_pyx.pyx":784
5802
* return self._offset_for_sha1(PyString_AS_STRING(sha1))
5804
* cdef _compute_common(self): # <<<<<<<<<<<<<<
5805
* cdef unsigned int first
5806
* cdef unsigned int this
5809
static PyObject *__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__compute_common(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
5810
unsigned int __pyx_v_first;
5811
unsigned int __pyx_v_this;
5812
unsigned int __pyx_v_common_mask;
5813
unsigned char __pyx_v_common_shift;
5816
int __pyx_v_this_offset;
5817
int __pyx_v_max_offset;
5818
PyObject *__pyx_r = NULL;
5821
PyObject *__pyx_t_3 = NULL;
5822
PyObject *__pyx_t_4 = NULL;
5826
__Pyx_RefNannySetupContext("_compute_common");
5828
/* "bzrlib/_btree_serializer_pyx.pyx":798
5829
* # By XORing the records together, we can determine what bits are set in
5831
* if self.num_records < 2: # <<<<<<<<<<<<<<
5832
* # Everything is in common if you have 0 or 1 leaves
5833
* # So we'll always just shift to the first byte
5835
__pyx_t_1 = (__pyx_v_self->num_records < 2);
5838
/* "bzrlib/_btree_serializer_pyx.pyx":801
5839
* # Everything is in common if you have 0 or 1 leaves
5840
* # So we'll always just shift to the first byte
5841
* self.common_shift = 24 # <<<<<<<<<<<<<<
5843
* common_mask = 0xFFFFFFFF
5845
__pyx_v_self->common_shift = 24;
5850
/* "bzrlib/_btree_serializer_pyx.pyx":803
5851
* self.common_shift = 24
5853
* common_mask = 0xFFFFFFFF # <<<<<<<<<<<<<<
5854
* first = _sha1_to_uint(self.records[0].sha1)
5855
* for i from 0 < i < self.num_records:
5857
__pyx_v_common_mask = 0xFFFFFFFF;
5859
/* "bzrlib/_btree_serializer_pyx.pyx":804
5861
* common_mask = 0xFFFFFFFF
5862
* first = _sha1_to_uint(self.records[0].sha1) # <<<<<<<<<<<<<<
5863
* for i from 0 < i < self.num_records:
5864
* this = _sha1_to_uint(self.records[i].sha1)
5866
__pyx_v_first = __pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_uint((__pyx_v_self->records[0]).sha1);
5868
/* "bzrlib/_btree_serializer_pyx.pyx":805
5869
* common_mask = 0xFFFFFFFF
5870
* first = _sha1_to_uint(self.records[0].sha1)
5871
* for i from 0 < i < self.num_records: # <<<<<<<<<<<<<<
5872
* this = _sha1_to_uint(self.records[i].sha1)
5873
* common_mask = (~(first ^ this)) & common_mask
5875
__pyx_t_2 = __pyx_v_self->num_records;
5876
for (__pyx_v_i = 0+1; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
5878
/* "bzrlib/_btree_serializer_pyx.pyx":806
5879
* first = _sha1_to_uint(self.records[0].sha1)
5880
* for i from 0 < i < self.num_records:
5881
* this = _sha1_to_uint(self.records[i].sha1) # <<<<<<<<<<<<<<
5882
* common_mask = (~(first ^ this)) & common_mask
5885
__pyx_v_this = __pyx_f_6bzrlib_21_btree_serializer_pyx__sha1_to_uint((__pyx_v_self->records[__pyx_v_i]).sha1);
5887
/* "bzrlib/_btree_serializer_pyx.pyx":807
5888
* for i from 0 < i < self.num_records:
5889
* this = _sha1_to_uint(self.records[i].sha1)
5890
* common_mask = (~(first ^ this)) & common_mask # <<<<<<<<<<<<<<
5892
* while common_mask & 0x80000000 and common_shift > 0:
5894
__pyx_v_common_mask = ((~(__pyx_v_first ^ __pyx_v_this)) & __pyx_v_common_mask);
5897
/* "bzrlib/_btree_serializer_pyx.pyx":808
5898
* this = _sha1_to_uint(self.records[i].sha1)
5899
* common_mask = (~(first ^ this)) & common_mask
5900
* common_shift = 24 # <<<<<<<<<<<<<<
5901
* while common_mask & 0x80000000 and common_shift > 0:
5902
* common_mask = common_mask << 1
5904
__pyx_v_common_shift = 24;
5906
/* "bzrlib/_btree_serializer_pyx.pyx":809
5907
* common_mask = (~(first ^ this)) & common_mask
5909
* while common_mask & 0x80000000 and common_shift > 0: # <<<<<<<<<<<<<<
5910
* common_mask = common_mask << 1
5911
* common_shift = common_shift - 1
5914
__pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_common_mask); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5915
__Pyx_GOTREF(__pyx_t_3);
5916
__pyx_t_4 = PyNumber_And(__pyx_t_3, __pyx_int_2147483648); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5917
__Pyx_GOTREF(__pyx_t_4);
5918
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5919
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5920
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5922
__pyx_t_5 = (__pyx_v_common_shift > 0);
5923
__pyx_t_6 = __pyx_t_5;
5925
__pyx_t_6 = __pyx_t_1;
5927
if (!__pyx_t_6) break;
5929
/* "bzrlib/_btree_serializer_pyx.pyx":810
5931
* while common_mask & 0x80000000 and common_shift > 0:
5932
* common_mask = common_mask << 1 # <<<<<<<<<<<<<<
5933
* common_shift = common_shift - 1
5934
* self.common_shift = common_shift
5936
__pyx_v_common_mask = (__pyx_v_common_mask << 1);
5938
/* "bzrlib/_btree_serializer_pyx.pyx":811
5939
* while common_mask & 0x80000000 and common_shift > 0:
5940
* common_mask = common_mask << 1
5941
* common_shift = common_shift - 1 # <<<<<<<<<<<<<<
5942
* self.common_shift = common_shift
5945
__pyx_v_common_shift = (__pyx_v_common_shift - 1);
5948
/* "bzrlib/_btree_serializer_pyx.pyx":812
5949
* common_mask = common_mask << 1
5950
* common_shift = common_shift - 1
5951
* self.common_shift = common_shift # <<<<<<<<<<<<<<
5953
* max_offset = self.num_records
5955
__pyx_v_self->common_shift = __pyx_v_common_shift;
5959
/* "bzrlib/_btree_serializer_pyx.pyx":813
5960
* common_shift = common_shift - 1
5961
* self.common_shift = common_shift
5962
* offset = 0 # <<<<<<<<<<<<<<
5963
* max_offset = self.num_records
5964
* # We cap this loop at 254 records. All the other offsets just get
5968
/* "bzrlib/_btree_serializer_pyx.pyx":814
5969
* self.common_shift = common_shift
5971
* max_offset = self.num_records # <<<<<<<<<<<<<<
5972
* # We cap this loop at 254 records. All the other offsets just get
5973
* # filled with 0xff as the singleton saying 'too many'.
5975
__pyx_v_max_offset = __pyx_v_self->num_records;
5977
/* "bzrlib/_btree_serializer_pyx.pyx":819
5978
* # It means that if we have >255 records we have to bisect the second
5979
* # half of the list, but this is going to be very rare in practice.
5980
* if max_offset > 255: # <<<<<<<<<<<<<<
5982
* for i from 0 <= i < max_offset:
5984
__pyx_t_6 = (__pyx_v_max_offset > 255);
5987
/* "bzrlib/_btree_serializer_pyx.pyx":820
5988
* # half of the list, but this is going to be very rare in practice.
5989
* if max_offset > 255:
5990
* max_offset = 255 # <<<<<<<<<<<<<<
5991
* for i from 0 <= i < max_offset:
5992
* this_offset = self._offset_for_sha1(self.records[i].sha1)
5994
__pyx_v_max_offset = 255;
5999
/* "bzrlib/_btree_serializer_pyx.pyx":821
6000
* if max_offset > 255:
6002
* for i from 0 <= i < max_offset: # <<<<<<<<<<<<<<
6003
* this_offset = self._offset_for_sha1(self.records[i].sha1)
6004
* while offset <= this_offset:
6006
__pyx_t_2 = __pyx_v_max_offset;
6007
for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
6009
/* "bzrlib/_btree_serializer_pyx.pyx":822
6011
* for i from 0 <= i < max_offset:
6012
* this_offset = self._offset_for_sha1(self.records[i].sha1) # <<<<<<<<<<<<<<
6013
* while offset <= this_offset:
6014
* self.offsets[offset] = i
6016
__pyx_t_7 = ((struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_offset_for_sha1(__pyx_v_self, (__pyx_v_self->records[__pyx_v_i]).sha1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6017
__pyx_v_this_offset = __pyx_t_7;
6019
/* "bzrlib/_btree_serializer_pyx.pyx":823
6020
* for i from 0 <= i < max_offset:
6021
* this_offset = self._offset_for_sha1(self.records[i].sha1)
6022
* while offset <= this_offset: # <<<<<<<<<<<<<<
6023
* self.offsets[offset] = i
6024
* offset = offset + 1
6027
__pyx_t_6 = (__pyx_v_offset <= __pyx_v_this_offset);
6028
if (!__pyx_t_6) break;
6030
/* "bzrlib/_btree_serializer_pyx.pyx":824
6031
* this_offset = self._offset_for_sha1(self.records[i].sha1)
6032
* while offset <= this_offset:
6033
* self.offsets[offset] = i # <<<<<<<<<<<<<<
6034
* offset = offset + 1
6035
* while offset < 257:
6037
(__pyx_v_self->offsets[__pyx_v_offset]) = __pyx_v_i;
6039
/* "bzrlib/_btree_serializer_pyx.pyx":825
6040
* while offset <= this_offset:
6041
* self.offsets[offset] = i
6042
* offset = offset + 1 # <<<<<<<<<<<<<<
6043
* while offset < 257:
6044
* self.offsets[offset] = max_offset
6046
__pyx_v_offset = (__pyx_v_offset + 1);
6050
/* "bzrlib/_btree_serializer_pyx.pyx":826
6051
* self.offsets[offset] = i
6052
* offset = offset + 1
6053
* while offset < 257: # <<<<<<<<<<<<<<
6054
* self.offsets[offset] = max_offset
6055
* offset = offset + 1
6058
__pyx_t_6 = (__pyx_v_offset < 257);
6059
if (!__pyx_t_6) break;
6061
/* "bzrlib/_btree_serializer_pyx.pyx":827
6062
* offset = offset + 1
6063
* while offset < 257:
6064
* self.offsets[offset] = max_offset # <<<<<<<<<<<<<<
6065
* offset = offset + 1
6068
(__pyx_v_self->offsets[__pyx_v_offset]) = __pyx_v_max_offset;
6070
/* "bzrlib/_btree_serializer_pyx.pyx":828
6071
* while offset < 257:
6072
* self.offsets[offset] = max_offset
6073
* offset = offset + 1 # <<<<<<<<<<<<<<
6075
* def _get_offsets(self):
6077
__pyx_v_offset = (__pyx_v_offset + 1);
6080
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
6083
__Pyx_XDECREF(__pyx_t_3);
6084
__Pyx_XDECREF(__pyx_t_4);
6085
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode._compute_common");
6088
__Pyx_XGIVEREF(__pyx_r);
6089
__Pyx_RefNannyFinishContext();
6093
/* "bzrlib/_btree_serializer_pyx.pyx":830
6094
* offset = offset + 1
6096
* def _get_offsets(self): # <<<<<<<<<<<<<<
6101
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_9_get_offsets(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
6102
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_9_get_offsets(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
6104
PyObject *__pyx_v_result;
6105
PyObject *__pyx_r = NULL;
6106
PyObject *__pyx_t_1 = NULL;
6108
__Pyx_RefNannySetupContext("_get_offsets");
6109
__pyx_v_result = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
6111
/* "bzrlib/_btree_serializer_pyx.pyx":832
6112
* def _get_offsets(self):
6114
* result = [] # <<<<<<<<<<<<<<
6115
* for i from 0 <= i < 257:
6116
* PyList_Append(result, self.offsets[i])
6118
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6119
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
6120
__Pyx_DECREF(((PyObject *)__pyx_v_result));
6121
__pyx_v_result = __pyx_t_1;
6124
/* "bzrlib/_btree_serializer_pyx.pyx":833
6127
* for i from 0 <= i < 257: # <<<<<<<<<<<<<<
6128
* PyList_Append(result, self.offsets[i])
6131
for (__pyx_v_i = 0; __pyx_v_i < 257; __pyx_v_i++) {
6133
/* "bzrlib/_btree_serializer_pyx.pyx":834
6135
* for i from 0 <= i < 257:
6136
* PyList_Append(result, self.offsets[i]) # <<<<<<<<<<<<<<
6140
__pyx_t_1 = PyInt_FromLong((((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->offsets[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6141
__Pyx_GOTREF(__pyx_t_1);
6142
__pyx_t_2 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6143
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6146
/* "bzrlib/_btree_serializer_pyx.pyx":835
6147
* for i from 0 <= i < 257:
6148
* PyList_Append(result, self.offsets[i])
6149
* return result # <<<<<<<<<<<<<<
6153
__Pyx_XDECREF(__pyx_r);
6154
__Pyx_INCREF(((PyObject *)__pyx_v_result));
6155
__pyx_r = ((PyObject *)__pyx_v_result);
6158
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
6161
__Pyx_XDECREF(__pyx_t_1);
6162
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode._get_offsets");
6165
__Pyx_DECREF(__pyx_v_result);
6166
__Pyx_XGIVEREF(__pyx_r);
6167
__Pyx_RefNannyFinishContext();
6171
/* "bzrlib/_btree_serializer_pyx.pyx":522
6173
* cdef gc_chk_sha1_record *records
6174
* cdef public object last_key # <<<<<<<<<<<<<<
6175
* cdef gc_chk_sha1_record *last_record
6176
* cdef public int num_records
6179
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key___get__(PyObject *__pyx_v_self); /*proto*/
6180
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key___get__(PyObject *__pyx_v_self) {
6181
PyObject *__pyx_r = NULL;
6182
__Pyx_RefNannySetupContext("__get__");
6183
__Pyx_XDECREF(__pyx_r);
6184
__Pyx_INCREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
6185
__pyx_r = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key;
6188
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
6190
__Pyx_XGIVEREF(__pyx_r);
6191
__Pyx_RefNannyFinishContext();
6195
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
6196
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
6198
__Pyx_RefNannySetupContext("__set__");
6199
__Pyx_INCREF(__pyx_v_value);
6200
__Pyx_GIVEREF(__pyx_v_value);
6201
__Pyx_GOTREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
6202
__Pyx_DECREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
6203
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key = __pyx_v_value;
6206
__Pyx_RefNannyFinishContext();
6210
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_2__del__(PyObject *__pyx_v_self); /*proto*/
6211
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_2__del__(PyObject *__pyx_v_self) {
6213
__Pyx_RefNannySetupContext("__del__");
6214
__Pyx_INCREF(Py_None);
6215
__Pyx_GIVEREF(Py_None);
6216
__Pyx_GOTREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
6217
__Pyx_DECREF(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key);
6218
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->last_key = Py_None;
6221
__Pyx_RefNannyFinishContext();
6225
/* "bzrlib/_btree_serializer_pyx.pyx":524
6226
* cdef public object last_key
6227
* cdef gc_chk_sha1_record *last_record
6228
* cdef public int num_records # <<<<<<<<<<<<<<
6229
* # This is the number of bits to shift to get to the interesting byte. A
6230
* # value of 24 means that the very first byte changes across all keys.
6233
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records___get__(PyObject *__pyx_v_self); /*proto*/
6234
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records___get__(PyObject *__pyx_v_self) {
6235
PyObject *__pyx_r = NULL;
6236
PyObject *__pyx_t_1 = NULL;
6237
__Pyx_RefNannySetupContext("__get__");
6238
__Pyx_XDECREF(__pyx_r);
6239
__pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->num_records); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6240
__Pyx_GOTREF(__pyx_t_1);
6241
__pyx_r = __pyx_t_1;
6245
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
6248
__Pyx_XDECREF(__pyx_t_1);
6249
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.num_records.__get__");
6252
__Pyx_XGIVEREF(__pyx_r);
6253
__Pyx_RefNannyFinishContext();
6257
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
6258
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
6261
__Pyx_RefNannySetupContext("__set__");
6262
__pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6263
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->num_records = __pyx_t_1;
6268
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.num_records.__set__");
6271
__Pyx_RefNannyFinishContext();
6275
/* "bzrlib/_btree_serializer_pyx.pyx":530
6276
* # ignore. 0 means that at least the first 3 bytes are identical, though
6277
* # that is going to be very rare
6278
* cdef public unsigned char common_shift # <<<<<<<<<<<<<<
6279
* # This maps an interesting byte to the first record that matches.
6280
* # Equivalent to bisect.bisect_left(self.records, sha1), though only taking
6283
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift___get__(PyObject *__pyx_v_self); /*proto*/
6284
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift___get__(PyObject *__pyx_v_self) {
6285
PyObject *__pyx_r = NULL;
6286
PyObject *__pyx_t_1 = NULL;
6287
__Pyx_RefNannySetupContext("__get__");
6288
__Pyx_XDECREF(__pyx_r);
6289
__pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->common_shift); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6290
__Pyx_GOTREF(__pyx_t_1);
6291
__pyx_r = __pyx_t_1;
6295
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
6298
__Pyx_XDECREF(__pyx_t_1);
6299
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.common_shift.__get__");
6302
__Pyx_XGIVEREF(__pyx_r);
6303
__Pyx_RefNannyFinishContext();
6307
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
6308
static int __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
6310
unsigned char __pyx_t_1;
6311
__Pyx_RefNannySetupContext("__set__");
6312
__pyx_t_1 = __Pyx_PyInt_AsUnsignedChar(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6313
((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self)->common_shift = __pyx_t_1;
6318
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode.common_shift.__set__");
6321
__Pyx_RefNannyFinishContext();
6325
/* "bzrlib/_btree_serializer_pyx.pyx":838
6328
* def _parse_into_chk(bytes, key_length, ref_list_length): # <<<<<<<<<<<<<<
6329
* """Parse into a format optimized for chk records."""
6330
* assert key_length == 1
6333
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_5_parse_into_chk(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6334
static char __pyx_doc_6bzrlib_21_btree_serializer_pyx_5_parse_into_chk[] = "Parse into a format optimized for chk records.";
6335
static PyMethodDef __pyx_mdef_6bzrlib_21_btree_serializer_pyx_5_parse_into_chk = {__Pyx_NAMESTR("_parse_into_chk"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_5_parse_into_chk, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6bzrlib_21_btree_serializer_pyx_5_parse_into_chk)};
6336
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_5_parse_into_chk(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6337
PyObject *__pyx_v_bytes = 0;
6338
PyObject *__pyx_v_key_length = 0;
6339
PyObject *__pyx_v_ref_list_length = 0;
6340
PyObject *__pyx_r = NULL;
6341
PyObject *__pyx_t_1 = NULL;
6343
PyObject *__pyx_t_3 = NULL;
6344
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bytes,&__pyx_n_s__key_length,&__pyx_n_s__ref_list_length,0};
6345
__Pyx_RefNannySetupContext("_parse_into_chk");
6346
__pyx_self = __pyx_self;
6347
if (unlikely(__pyx_kwds)) {
6348
Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
6349
PyObject* values[3] = {0,0,0};
6350
switch (PyTuple_GET_SIZE(__pyx_args)) {
6351
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6352
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6353
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6355
default: goto __pyx_L5_argtuple_error;
6357
switch (PyTuple_GET_SIZE(__pyx_args)) {
6359
values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bytes);
6360
if (likely(values[0])) kw_args--;
6361
else goto __pyx_L5_argtuple_error;
6363
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key_length);
6364
if (likely(values[1])) kw_args--;
6366
__Pyx_RaiseArgtupleInvalid("_parse_into_chk", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
6369
values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref_list_length);
6370
if (likely(values[2])) kw_args--;
6372
__Pyx_RaiseArgtupleInvalid("_parse_into_chk", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
6375
if (unlikely(kw_args > 0)) {
6376
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parse_into_chk") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
6378
__pyx_v_bytes = values[0];
6379
__pyx_v_key_length = values[1];
6380
__pyx_v_ref_list_length = values[2];
6381
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
6382
goto __pyx_L5_argtuple_error;
6384
__pyx_v_bytes = PyTuple_GET_ITEM(__pyx_args, 0);
6385
__pyx_v_key_length = PyTuple_GET_ITEM(__pyx_args, 1);
6386
__pyx_v_ref_list_length = PyTuple_GET_ITEM(__pyx_args, 2);
6388
goto __pyx_L4_argument_unpacking_done;
6389
__pyx_L5_argtuple_error:;
6390
__Pyx_RaiseArgtupleInvalid("_parse_into_chk", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
6392
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._parse_into_chk");
6393
__Pyx_RefNannyFinishContext();
6395
__pyx_L4_argument_unpacking_done:;
6397
/* "bzrlib/_btree_serializer_pyx.pyx":840
6398
* def _parse_into_chk(bytes, key_length, ref_list_length):
6399
* """Parse into a format optimized for chk records."""
6400
* assert key_length == 1 # <<<<<<<<<<<<<<
6401
* assert ref_list_length == 0
6402
* return GCCHKSHA1LeafNode(bytes)
6404
#ifndef CYTHON_WITHOUT_ASSERTIONS
6405
__pyx_t_1 = PyObject_RichCompare(__pyx_v_key_length, __pyx_int_1, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6406
__Pyx_GOTREF(__pyx_t_1);
6407
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6408
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6409
if (unlikely(!__pyx_t_2)) {
6410
PyErr_SetNone(PyExc_AssertionError);
6411
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6415
/* "bzrlib/_btree_serializer_pyx.pyx":841
6416
* """Parse into a format optimized for chk records."""
6417
* assert key_length == 1
6418
* assert ref_list_length == 0 # <<<<<<<<<<<<<<
6419
* return GCCHKSHA1LeafNode(bytes)
6422
#ifndef CYTHON_WITHOUT_ASSERTIONS
6423
__pyx_t_1 = PyObject_RichCompare(__pyx_v_ref_list_length, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6424
__Pyx_GOTREF(__pyx_t_1);
6425
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6426
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6427
if (unlikely(!__pyx_t_2)) {
6428
PyErr_SetNone(PyExc_AssertionError);
6429
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6433
/* "bzrlib/_btree_serializer_pyx.pyx":842
6434
* assert key_length == 1
6435
* assert ref_list_length == 0
6436
* return GCCHKSHA1LeafNode(bytes) # <<<<<<<<<<<<<<
6440
__Pyx_XDECREF(__pyx_r);
6441
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6442
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
6443
__Pyx_INCREF(__pyx_v_bytes);
6444
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_bytes);
6445
__Pyx_GIVEREF(__pyx_v_bytes);
6446
__pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6447
__Pyx_GOTREF(__pyx_t_3);
6448
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
6449
__pyx_r = __pyx_t_3;
6453
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
6456
__Pyx_XDECREF(__pyx_t_1);
6457
__Pyx_XDECREF(__pyx_t_3);
6458
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._parse_into_chk");
6461
__Pyx_XGIVEREF(__pyx_r);
6462
__Pyx_RefNannyFinishContext();
6466
/* "bzrlib/_btree_serializer_pyx.pyx":845
6469
* def _flatten_node(node, reference_lists): # <<<<<<<<<<<<<<
6470
* """Convert a node into the serialized form.
6474
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_6_flatten_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6475
static char __pyx_doc_6bzrlib_21_btree_serializer_pyx_6_flatten_node[] = "Convert a node into the serialized form.\n\n :param node: A tuple representing a node:\n (index, key_tuple, value, references)\n :param reference_lists: Does this index have reference lists?\n :return: (string_key, flattened)\n string_key The serialized key for referencing this node\n flattened A string with the serialized form for the contents\n ";
6476
static PyMethodDef __pyx_mdef_6bzrlib_21_btree_serializer_pyx_6_flatten_node = {__Pyx_NAMESTR("_flatten_node"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_6_flatten_node, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6bzrlib_21_btree_serializer_pyx_6_flatten_node)};
6477
static PyObject *__pyx_pf_6bzrlib_21_btree_serializer_pyx_6_flatten_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6478
PyObject *__pyx_v_node = 0;
6479
PyObject *__pyx_v_reference_lists = 0;
6480
int __pyx_v_have_reference_lists;
6481
Py_ssize_t __pyx_v_flat_len;
6482
Py_ssize_t __pyx_v_key_len;
6483
Py_ssize_t __pyx_v_node_len;
6484
char *__pyx_v_value;
6485
Py_ssize_t __pyx_v_value_len;
6487
Py_ssize_t __pyx_v_refs_len;
6488
Py_ssize_t __pyx_v_next_len;
6489
int __pyx_v_first_ref_list;
6490
int __pyx_v_first_reference;
6492
Py_ssize_t __pyx_v_ref_bit_len;
6493
PyObject *__pyx_v_string_key;
6494
PyObject *__pyx_v_ref_lists;
6495
PyObject *__pyx_v_ref_list;
6496
PyObject *__pyx_v_reference;
6497
PyObject *__pyx_v_ref_bit;
6498
PyObject *__pyx_v_val;
6499
PyObject *__pyx_v_line;
6500
PyObject *__pyx_r = NULL;
6504
PyObject *__pyx_t_4 = NULL;
6505
PyObject *__pyx_t_5 = NULL;
6506
Py_ssize_t __pyx_t_6;
6508
PyObject *__pyx_t_8 = NULL;
6509
Py_ssize_t __pyx_t_9;
6510
PyObject *__pyx_t_10 = NULL;
6511
Py_ssize_t __pyx_t_11;
6512
PyObject *__pyx_t_12 = NULL;
6514
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__node,&__pyx_n_s__reference_lists,0};
6515
__Pyx_RefNannySetupContext("_flatten_node");
6516
__pyx_self = __pyx_self;
6517
if (unlikely(__pyx_kwds)) {
6518
Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
6519
PyObject* values[2] = {0,0};
6520
switch (PyTuple_GET_SIZE(__pyx_args)) {
6521
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6522
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6524
default: goto __pyx_L5_argtuple_error;
6526
switch (PyTuple_GET_SIZE(__pyx_args)) {
6528
values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__node);
6529
if (likely(values[0])) kw_args--;
6530
else goto __pyx_L5_argtuple_error;
6532
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference_lists);
6533
if (likely(values[1])) kw_args--;
6535
__Pyx_RaiseArgtupleInvalid("_flatten_node", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
6538
if (unlikely(kw_args > 0)) {
6539
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_flatten_node") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
6541
__pyx_v_node = values[0];
6542
__pyx_v_reference_lists = values[1];
6543
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
6544
goto __pyx_L5_argtuple_error;
6546
__pyx_v_node = PyTuple_GET_ITEM(__pyx_args, 0);
6547
__pyx_v_reference_lists = PyTuple_GET_ITEM(__pyx_args, 1);
6549
goto __pyx_L4_argument_unpacking_done;
6550
__pyx_L5_argtuple_error:;
6551
__Pyx_RaiseArgtupleInvalid("_flatten_node", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
6553
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._flatten_node");
6554
__Pyx_RefNannyFinishContext();
6556
__pyx_L4_argument_unpacking_done:;
6557
__pyx_v_string_key = Py_None; __Pyx_INCREF(Py_None);
6558
__pyx_v_ref_lists = Py_None; __Pyx_INCREF(Py_None);
6559
__pyx_v_ref_list = Py_None; __Pyx_INCREF(Py_None);
6560
__pyx_v_reference = Py_None; __Pyx_INCREF(Py_None);
6561
__pyx_v_ref_bit = Py_None; __Pyx_INCREF(Py_None);
6562
__pyx_v_val = Py_None; __Pyx_INCREF(Py_None);
6563
__pyx_v_line = Py_None; __Pyx_INCREF(Py_None);
6565
/* "bzrlib/_btree_serializer_pyx.pyx":869
6566
* cdef Py_ssize_t ref_bit_len
6568
* if not PyTuple_CheckExact(node) and not StaticTuple_CheckExact(node): # <<<<<<<<<<<<<<
6569
* raise TypeError('We expected a tuple() or StaticTuple() for node not: %s'
6572
__pyx_t_1 = (!PyTuple_CheckExact(__pyx_v_node));
6574
__pyx_t_2 = (!StaticTuple_CheckExact(__pyx_v_node));
6575
__pyx_t_3 = __pyx_t_2;
6577
__pyx_t_3 = __pyx_t_1;
6581
/* "bzrlib/_btree_serializer_pyx.pyx":871
6582
* if not PyTuple_CheckExact(node) and not StaticTuple_CheckExact(node):
6583
* raise TypeError('We expected a tuple() or StaticTuple() for node not: %s'
6584
* % type(node)) # <<<<<<<<<<<<<<
6585
* node_len = len(node)
6586
* have_reference_lists = reference_lists
6588
__pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_48), ((PyObject *)Py_TYPE(__pyx_v_node))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6589
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
6590
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6591
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
6592
PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
6593
__Pyx_GIVEREF(((PyObject *)__pyx_t_4));
6595
__pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6596
__Pyx_GOTREF(__pyx_t_4);
6597
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
6598
__Pyx_Raise(__pyx_t_4, 0, 0);
6599
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6600
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6605
/* "bzrlib/_btree_serializer_pyx.pyx":872
6606
* raise TypeError('We expected a tuple() or StaticTuple() for node not: %s'
6608
* node_len = len(node) # <<<<<<<<<<<<<<
6609
* have_reference_lists = reference_lists
6610
* if have_reference_lists:
6612
__pyx_t_6 = PyObject_Length(__pyx_v_node); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6613
__pyx_v_node_len = __pyx_t_6;
6615
/* "bzrlib/_btree_serializer_pyx.pyx":873
6617
* node_len = len(node)
6618
* have_reference_lists = reference_lists # <<<<<<<<<<<<<<
6619
* if have_reference_lists:
6622
__pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_v_reference_lists); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6623
__pyx_v_have_reference_lists = __pyx_t_7;
6625
/* "bzrlib/_btree_serializer_pyx.pyx":874
6626
* node_len = len(node)
6627
* have_reference_lists = reference_lists
6628
* if have_reference_lists: # <<<<<<<<<<<<<<
6630
* raise ValueError('With ref_lists, we expected 4 entries not: %s'
6632
if (__pyx_v_have_reference_lists) {
6634
/* "bzrlib/_btree_serializer_pyx.pyx":875
6635
* have_reference_lists = reference_lists
6636
* if have_reference_lists:
6637
* if node_len != 4: # <<<<<<<<<<<<<<
6638
* raise ValueError('With ref_lists, we expected 4 entries not: %s'
6641
__pyx_t_3 = (__pyx_v_node_len != 4);
6644
/* "bzrlib/_btree_serializer_pyx.pyx":877
6646
* raise ValueError('With ref_lists, we expected 4 entries not: %s'
6647
* % len(node)) # <<<<<<<<<<<<<<
6648
* elif node_len < 3:
6649
* raise ValueError('Without ref_lists, we need at least 3 entries not: %s'
6651
__pyx_t_6 = PyObject_Length(__pyx_v_node); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6652
__pyx_t_4 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6653
__Pyx_GOTREF(__pyx_t_4);
6654
__pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6655
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
6656
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6657
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6658
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
6659
PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
6660
__Pyx_GIVEREF(((PyObject *)__pyx_t_5));
6662
__pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6663
__Pyx_GOTREF(__pyx_t_5);
6664
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
6665
__Pyx_Raise(__pyx_t_5, 0, 0);
6666
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6667
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6674
/* "bzrlib/_btree_serializer_pyx.pyx":878
6675
* raise ValueError('With ref_lists, we expected 4 entries not: %s'
6677
* elif node_len < 3: # <<<<<<<<<<<<<<
6678
* raise ValueError('Without ref_lists, we need at least 3 entries not: %s'
6681
__pyx_t_3 = (__pyx_v_node_len < 3);
6684
/* "bzrlib/_btree_serializer_pyx.pyx":880
6685
* elif node_len < 3:
6686
* raise ValueError('Without ref_lists, we need at least 3 entries not: %s'
6687
* % len(node)) # <<<<<<<<<<<<<<
6688
* # TODO: We can probably do better than string.join(), namely
6689
* # when key has only 1 item, we can just grab that string
6691
__pyx_t_6 = PyObject_Length(__pyx_v_node); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6692
__pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6693
__Pyx_GOTREF(__pyx_t_5);
6694
__pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_50), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6695
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
6696
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6697
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6698
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
6699
PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
6700
__Pyx_GIVEREF(((PyObject *)__pyx_t_4));
6702
__pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6703
__Pyx_GOTREF(__pyx_t_4);
6704
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
6705
__Pyx_Raise(__pyx_t_4, 0, 0);
6706
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6707
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6712
/* "bzrlib/_btree_serializer_pyx.pyx":891
6713
* # We *could* do more work on our own, and grab the actual items
6714
* # lists. For now, just ask people to use a better compiler. :)
6715
* string_key = '\0'.join(node[1]) # <<<<<<<<<<<<<<
6717
* # TODO: instead of using string joins, precompute the final string length,
6719
__pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_51), __pyx_n_s__join); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6720
__Pyx_GOTREF(__pyx_t_4);
6721
__pyx_t_5 = __Pyx_GetItemInt(__pyx_v_node, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6722
__Pyx_GOTREF(__pyx_t_5);
6723
__pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6724
__Pyx_GOTREF(((PyObject *)__pyx_t_8));
6725
PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
6726
__Pyx_GIVEREF(__pyx_t_5);
6728
__pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6729
__Pyx_GOTREF(__pyx_t_5);
6730
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6731
__Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
6732
__Pyx_DECREF(__pyx_v_string_key);
6733
__pyx_v_string_key = __pyx_t_5;
6736
/* "bzrlib/_btree_serializer_pyx.pyx":905
6737
* # ref := BYTES (NULL BYTES)*
6739
* refs_len = 0 # <<<<<<<<<<<<<<
6740
* if have_reference_lists:
6741
* # Figure out how many bytes it will take to store the references
6743
__pyx_v_refs_len = 0;
6745
/* "bzrlib/_btree_serializer_pyx.pyx":906
6748
* if have_reference_lists: # <<<<<<<<<<<<<<
6749
* # Figure out how many bytes it will take to store the references
6750
* ref_lists = node[3]
6752
if (__pyx_v_have_reference_lists) {
6754
/* "bzrlib/_btree_serializer_pyx.pyx":908
6755
* if have_reference_lists:
6756
* # Figure out how many bytes it will take to store the references
6757
* ref_lists = node[3] # <<<<<<<<<<<<<<
6758
* next_len = len(ref_lists) # TODO: use a Py function
6761
__pyx_t_5 = __Pyx_GetItemInt(__pyx_v_node, 3, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6762
__Pyx_GOTREF(__pyx_t_5);
6763
__Pyx_DECREF(__pyx_v_ref_lists);
6764
__pyx_v_ref_lists = __pyx_t_5;
6767
/* "bzrlib/_btree_serializer_pyx.pyx":909
6768
* # Figure out how many bytes it will take to store the references
6769
* ref_lists = node[3]
6770
* next_len = len(ref_lists) # TODO: use a Py function # <<<<<<<<<<<<<<
6772
* # If there are no nodes, we don't need to do any work
6774
__pyx_t_6 = PyObject_Length(__pyx_v_ref_lists); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6775
__pyx_v_next_len = __pyx_t_6;
6777
/* "bzrlib/_btree_serializer_pyx.pyx":910
6778
* ref_lists = node[3]
6779
* next_len = len(ref_lists) # TODO: use a Py function
6780
* if next_len > 0: # <<<<<<<<<<<<<<
6781
* # If there are no nodes, we don't need to do any work
6782
* # Otherwise we will need (len - 1) '\t' characters to separate
6784
__pyx_t_3 = (__pyx_v_next_len > 0);
6787
/* "bzrlib/_btree_serializer_pyx.pyx":914
6788
* # Otherwise we will need (len - 1) '\t' characters to separate
6789
* # the reference lists
6790
* refs_len = refs_len + (next_len - 1) # <<<<<<<<<<<<<<
6791
* for ref_list in ref_lists:
6792
* next_len = len(ref_list)
6794
__pyx_v_refs_len = (__pyx_v_refs_len + (__pyx_v_next_len - 1));
6796
/* "bzrlib/_btree_serializer_pyx.pyx":915
6797
* # the reference lists
6798
* refs_len = refs_len + (next_len - 1)
6799
* for ref_list in ref_lists: # <<<<<<<<<<<<<<
6800
* next_len = len(ref_list)
6803
if (PyList_CheckExact(__pyx_v_ref_lists) || PyTuple_CheckExact(__pyx_v_ref_lists)) {
6804
__pyx_t_6 = 0; __pyx_t_5 = __pyx_v_ref_lists; __Pyx_INCREF(__pyx_t_5);
6806
__pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_ref_lists); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6807
__Pyx_GOTREF(__pyx_t_5);
6810
if (likely(PyList_CheckExact(__pyx_t_5))) {
6811
if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
6812
__pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++;
6813
} else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
6814
if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
6815
__pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++;
6817
__pyx_t_8 = PyIter_Next(__pyx_t_5);
6819
if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6822
__Pyx_GOTREF(__pyx_t_8);
6824
__Pyx_DECREF(__pyx_v_ref_list);
6825
__pyx_v_ref_list = __pyx_t_8;
6828
/* "bzrlib/_btree_serializer_pyx.pyx":916
6829
* refs_len = refs_len + (next_len - 1)
6830
* for ref_list in ref_lists:
6831
* next_len = len(ref_list) # <<<<<<<<<<<<<<
6833
* # We will need (len - 1) '\r' characters to separate the
6835
__pyx_t_9 = PyObject_Length(__pyx_v_ref_list); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6836
__pyx_v_next_len = __pyx_t_9;
6838
/* "bzrlib/_btree_serializer_pyx.pyx":917
6839
* for ref_list in ref_lists:
6840
* next_len = len(ref_list)
6841
* if next_len > 0: # <<<<<<<<<<<<<<
6842
* # We will need (len - 1) '\r' characters to separate the
6845
__pyx_t_3 = (__pyx_v_next_len > 0);
6848
/* "bzrlib/_btree_serializer_pyx.pyx":920
6849
* # We will need (len - 1) '\r' characters to separate the
6851
* refs_len = refs_len + (next_len - 1) # <<<<<<<<<<<<<<
6852
* for reference in ref_list:
6853
* if (not PyTuple_CheckExact(reference)
6855
__pyx_v_refs_len = (__pyx_v_refs_len + (__pyx_v_next_len - 1));
6857
/* "bzrlib/_btree_serializer_pyx.pyx":921
6859
* refs_len = refs_len + (next_len - 1)
6860
* for reference in ref_list: # <<<<<<<<<<<<<<
6861
* if (not PyTuple_CheckExact(reference)
6862
* and not StaticTuple_CheckExact(reference)):
6864
if (PyList_CheckExact(__pyx_v_ref_list) || PyTuple_CheckExact(__pyx_v_ref_list)) {
6865
__pyx_t_9 = 0; __pyx_t_8 = __pyx_v_ref_list; __Pyx_INCREF(__pyx_t_8);
6867
__pyx_t_9 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_ref_list); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6868
__Pyx_GOTREF(__pyx_t_8);
6871
if (likely(PyList_CheckExact(__pyx_t_8))) {
6872
if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_8)) break;
6873
__pyx_t_4 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++;
6874
} else if (likely(PyTuple_CheckExact(__pyx_t_8))) {
6875
if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
6876
__pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++;
6878
__pyx_t_4 = PyIter_Next(__pyx_t_8);
6880
if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6883
__Pyx_GOTREF(__pyx_t_4);
6885
__Pyx_DECREF(__pyx_v_reference);
6886
__pyx_v_reference = __pyx_t_4;
6889
/* "bzrlib/_btree_serializer_pyx.pyx":922
6890
* refs_len = refs_len + (next_len - 1)
6891
* for reference in ref_list:
6892
* if (not PyTuple_CheckExact(reference) # <<<<<<<<<<<<<<
6893
* and not StaticTuple_CheckExact(reference)):
6896
__pyx_t_3 = (!PyTuple_CheckExact(__pyx_v_reference));
6899
/* "bzrlib/_btree_serializer_pyx.pyx":923
6900
* for reference in ref_list:
6901
* if (not PyTuple_CheckExact(reference)
6902
* and not StaticTuple_CheckExact(reference)): # <<<<<<<<<<<<<<
6904
* 'We expect references to be tuples not: %s'
6906
__pyx_t_1 = (!StaticTuple_CheckExact(__pyx_v_reference));
6907
__pyx_t_2 = __pyx_t_1;
6909
__pyx_t_2 = __pyx_t_3;
6913
/* "bzrlib/_btree_serializer_pyx.pyx":926
6915
* 'We expect references to be tuples not: %s'
6916
* % type(reference)) # <<<<<<<<<<<<<<
6917
* next_len = len(reference)
6920
__pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_52), ((PyObject *)Py_TYPE(__pyx_v_reference))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6921
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
6922
__pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6923
__Pyx_GOTREF(((PyObject *)__pyx_t_10));
6924
PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_4));
6925
__Pyx_GIVEREF(((PyObject *)__pyx_t_4));
6927
__pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6928
__Pyx_GOTREF(__pyx_t_4);
6929
__Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
6930
__Pyx_Raise(__pyx_t_4, 0, 0);
6931
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6932
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6937
/* "bzrlib/_btree_serializer_pyx.pyx":927
6938
* 'We expect references to be tuples not: %s'
6939
* % type(reference))
6940
* next_len = len(reference) # <<<<<<<<<<<<<<
6942
* # We will need (len - 1) '\x00' characters to
6944
__pyx_t_11 = PyObject_Length(__pyx_v_reference); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6945
__pyx_v_next_len = __pyx_t_11;
6947
/* "bzrlib/_btree_serializer_pyx.pyx":928
6948
* % type(reference))
6949
* next_len = len(reference)
6950
* if next_len > 0: # <<<<<<<<<<<<<<
6951
* # We will need (len - 1) '\x00' characters to
6952
* # separate the reference key
6954
__pyx_t_2 = (__pyx_v_next_len > 0);
6957
/* "bzrlib/_btree_serializer_pyx.pyx":931
6958
* # We will need (len - 1) '\x00' characters to
6959
* # separate the reference key
6960
* refs_len = refs_len + (next_len - 1) # <<<<<<<<<<<<<<
6961
* for ref_bit in reference:
6962
* if not PyString_CheckExact(ref_bit):
6964
__pyx_v_refs_len = (__pyx_v_refs_len + (__pyx_v_next_len - 1));
6966
/* "bzrlib/_btree_serializer_pyx.pyx":932
6967
* # separate the reference key
6968
* refs_len = refs_len + (next_len - 1)
6969
* for ref_bit in reference: # <<<<<<<<<<<<<<
6970
* if not PyString_CheckExact(ref_bit):
6971
* raise TypeError('We expect reference bits'
6973
if (PyList_CheckExact(__pyx_v_reference) || PyTuple_CheckExact(__pyx_v_reference)) {
6974
__pyx_t_11 = 0; __pyx_t_4 = __pyx_v_reference; __Pyx_INCREF(__pyx_t_4);
6976
__pyx_t_11 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_reference); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6977
__Pyx_GOTREF(__pyx_t_4);
6980
if (likely(PyList_CheckExact(__pyx_t_4))) {
6981
if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_4)) break;
6982
__pyx_t_10 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_10); __pyx_t_11++;
6983
} else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
6984
if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
6985
__pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_10); __pyx_t_11++;
6987
__pyx_t_10 = PyIter_Next(__pyx_t_4);
6989
if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6992
__Pyx_GOTREF(__pyx_t_10);
6994
__Pyx_DECREF(__pyx_v_ref_bit);
6995
__pyx_v_ref_bit = __pyx_t_10;
6998
/* "bzrlib/_btree_serializer_pyx.pyx":933
6999
* refs_len = refs_len + (next_len - 1)
7000
* for ref_bit in reference:
7001
* if not PyString_CheckExact(ref_bit): # <<<<<<<<<<<<<<
7002
* raise TypeError('We expect reference bits'
7003
* ' to be strings not: %s'
7005
__pyx_t_2 = (!PyString_CheckExact(__pyx_v_ref_bit));
7008
/* "bzrlib/_btree_serializer_pyx.pyx":936
7009
* raise TypeError('We expect reference bits'
7010
* ' to be strings not: %s'
7011
* % type(<object>ref_bit)) # <<<<<<<<<<<<<<
7012
* refs_len = refs_len + PyString_GET_SIZE(ref_bit)
7015
__pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), ((PyObject *)Py_TYPE(__pyx_v_ref_bit))); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7016
__Pyx_GOTREF(((PyObject *)__pyx_t_10));
7017
__pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7018
__Pyx_GOTREF(((PyObject *)__pyx_t_12));
7019
PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_t_10));
7020
__Pyx_GIVEREF(((PyObject *)__pyx_t_10));
7022
__pyx_t_10 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7023
__Pyx_GOTREF(__pyx_t_10);
7024
__Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
7025
__Pyx_Raise(__pyx_t_10, 0, 0);
7026
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
7027
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7032
/* "bzrlib/_btree_serializer_pyx.pyx":937
7033
* ' to be strings not: %s'
7034
* % type(<object>ref_bit))
7035
* refs_len = refs_len + PyString_GET_SIZE(ref_bit) # <<<<<<<<<<<<<<
7037
* # So we have the (key NULL refs NULL value LF)
7039
__pyx_v_refs_len = (__pyx_v_refs_len + PyString_GET_SIZE(__pyx_v_ref_bit));
7041
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7046
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7051
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7059
/* "bzrlib/_btree_serializer_pyx.pyx":940
7061
* # So we have the (key NULL refs NULL value LF)
7062
* key_len = PyString_Size(string_key) # <<<<<<<<<<<<<<
7064
* if not PyString_CheckExact(val):
7066
__pyx_v_key_len = PyString_Size(__pyx_v_string_key);
7068
/* "bzrlib/_btree_serializer_pyx.pyx":941
7069
* # So we have the (key NULL refs NULL value LF)
7070
* key_len = PyString_Size(string_key)
7071
* val = node[2] # <<<<<<<<<<<<<<
7072
* if not PyString_CheckExact(val):
7073
* raise TypeError('Expected a plain str for value not: %s'
7075
__pyx_t_5 = __Pyx_GetItemInt(__pyx_v_node, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7076
__Pyx_GOTREF(__pyx_t_5);
7077
__Pyx_DECREF(__pyx_v_val);
7078
__pyx_v_val = __pyx_t_5;
7081
/* "bzrlib/_btree_serializer_pyx.pyx":942
7082
* key_len = PyString_Size(string_key)
7084
* if not PyString_CheckExact(val): # <<<<<<<<<<<<<<
7085
* raise TypeError('Expected a plain str for value not: %s'
7088
__pyx_t_2 = (!PyString_CheckExact(__pyx_v_val));
7091
/* "bzrlib/_btree_serializer_pyx.pyx":944
7092
* if not PyString_CheckExact(val):
7093
* raise TypeError('Expected a plain str for value not: %s'
7094
* % type(val)) # <<<<<<<<<<<<<<
7095
* value = PyString_AS_STRING(val)
7096
* value_len = PyString_GET_SIZE(val)
7098
__pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_54), ((PyObject *)Py_TYPE(__pyx_v_val))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7099
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
7100
__pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7101
__Pyx_GOTREF(((PyObject *)__pyx_t_8));
7102
PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_5));
7103
__Pyx_GIVEREF(((PyObject *)__pyx_t_5));
7105
__pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7106
__Pyx_GOTREF(__pyx_t_5);
7107
__Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
7108
__Pyx_Raise(__pyx_t_5, 0, 0);
7109
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7110
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7115
/* "bzrlib/_btree_serializer_pyx.pyx":945
7116
* raise TypeError('Expected a plain str for value not: %s'
7118
* value = PyString_AS_STRING(val) # <<<<<<<<<<<<<<
7119
* value_len = PyString_GET_SIZE(val)
7120
* flat_len = (key_len + 1 + refs_len + 1 + value_len + 1)
7122
__pyx_v_value = PyString_AS_STRING(__pyx_v_val);
7124
/* "bzrlib/_btree_serializer_pyx.pyx":946
7126
* value = PyString_AS_STRING(val)
7127
* value_len = PyString_GET_SIZE(val) # <<<<<<<<<<<<<<
7128
* flat_len = (key_len + 1 + refs_len + 1 + value_len + 1)
7129
* line = PyString_FromStringAndSize(NULL, flat_len)
7131
__pyx_v_value_len = PyString_GET_SIZE(__pyx_v_val);
7133
/* "bzrlib/_btree_serializer_pyx.pyx":947
7134
* value = PyString_AS_STRING(val)
7135
* value_len = PyString_GET_SIZE(val)
7136
* flat_len = (key_len + 1 + refs_len + 1 + value_len + 1) # <<<<<<<<<<<<<<
7137
* line = PyString_FromStringAndSize(NULL, flat_len)
7138
* # Get a pointer to the new buffer
7140
__pyx_v_flat_len = (((((__pyx_v_key_len + 1) + __pyx_v_refs_len) + 1) + __pyx_v_value_len) + 1);
7142
/* "bzrlib/_btree_serializer_pyx.pyx":948
7143
* value_len = PyString_GET_SIZE(val)
7144
* flat_len = (key_len + 1 + refs_len + 1 + value_len + 1)
7145
* line = PyString_FromStringAndSize(NULL, flat_len) # <<<<<<<<<<<<<<
7146
* # Get a pointer to the new buffer
7147
* out = PyString_AsString(line)
7149
__pyx_t_5 = PyString_FromStringAndSize(NULL, __pyx_v_flat_len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7150
__Pyx_GOTREF(__pyx_t_5);
7151
__Pyx_DECREF(__pyx_v_line);
7152
__pyx_v_line = __pyx_t_5;
7155
/* "bzrlib/_btree_serializer_pyx.pyx":950
7156
* line = PyString_FromStringAndSize(NULL, flat_len)
7157
* # Get a pointer to the new buffer
7158
* out = PyString_AsString(line) # <<<<<<<<<<<<<<
7159
* memcpy(out, PyString_AsString(string_key), key_len)
7160
* out = out + key_len
7162
__pyx_t_13 = PyString_AsString(__pyx_v_line); if (unlikely(__pyx_t_13 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7163
__pyx_v_out = __pyx_t_13;
7165
/* "bzrlib/_btree_serializer_pyx.pyx":951
7166
* # Get a pointer to the new buffer
7167
* out = PyString_AsString(line)
7168
* memcpy(out, PyString_AsString(string_key), key_len) # <<<<<<<<<<<<<<
7169
* out = out + key_len
7172
__pyx_t_13 = PyString_AsString(__pyx_v_string_key); if (unlikely(__pyx_t_13 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7173
memcpy(__pyx_v_out, __pyx_t_13, __pyx_v_key_len);
7175
/* "bzrlib/_btree_serializer_pyx.pyx":952
7176
* out = PyString_AsString(line)
7177
* memcpy(out, PyString_AsString(string_key), key_len)
7178
* out = out + key_len # <<<<<<<<<<<<<<
7182
__pyx_v_out = (__pyx_v_out + __pyx_v_key_len);
7184
/* "bzrlib/_btree_serializer_pyx.pyx":953
7185
* memcpy(out, PyString_AsString(string_key), key_len)
7186
* out = out + key_len
7187
* out[0] = c'\0' # <<<<<<<<<<<<<<
7191
(__pyx_v_out[0]) = '\x00';
7193
/* "bzrlib/_btree_serializer_pyx.pyx":954
7194
* out = out + key_len
7196
* out = out + 1 # <<<<<<<<<<<<<<
7198
* first_ref_list = 1
7200
__pyx_v_out = (__pyx_v_out + 1);
7202
/* "bzrlib/_btree_serializer_pyx.pyx":955
7205
* if refs_len > 0: # <<<<<<<<<<<<<<
7206
* first_ref_list = 1
7207
* for ref_list in ref_lists:
7209
__pyx_t_2 = (__pyx_v_refs_len > 0);
7212
/* "bzrlib/_btree_serializer_pyx.pyx":956
7215
* first_ref_list = 1 # <<<<<<<<<<<<<<
7216
* for ref_list in ref_lists:
7217
* if first_ref_list == 0:
7219
__pyx_v_first_ref_list = 1;
7221
/* "bzrlib/_btree_serializer_pyx.pyx":957
7223
* first_ref_list = 1
7224
* for ref_list in ref_lists: # <<<<<<<<<<<<<<
7225
* if first_ref_list == 0:
7228
if (PyList_CheckExact(__pyx_v_ref_lists) || PyTuple_CheckExact(__pyx_v_ref_lists)) {
7229
__pyx_t_6 = 0; __pyx_t_5 = __pyx_v_ref_lists; __Pyx_INCREF(__pyx_t_5);
7231
__pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_ref_lists); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7232
__Pyx_GOTREF(__pyx_t_5);
7235
if (likely(PyList_CheckExact(__pyx_t_5))) {
7236
if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
7237
__pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++;
7238
} else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
7239
if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
7240
__pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++;
7242
__pyx_t_8 = PyIter_Next(__pyx_t_5);
7244
if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7247
__Pyx_GOTREF(__pyx_t_8);
7249
__Pyx_DECREF(__pyx_v_ref_list);
7250
__pyx_v_ref_list = __pyx_t_8;
7253
/* "bzrlib/_btree_serializer_pyx.pyx":958
7254
* first_ref_list = 1
7255
* for ref_list in ref_lists:
7256
* if first_ref_list == 0: # <<<<<<<<<<<<<<
7260
__pyx_t_2 = (__pyx_v_first_ref_list == 0);
7263
/* "bzrlib/_btree_serializer_pyx.pyx":959
7264
* for ref_list in ref_lists:
7265
* if first_ref_list == 0:
7266
* out[0] = c'\t' # <<<<<<<<<<<<<<
7268
* first_ref_list = 0
7270
(__pyx_v_out[0]) = '\t';
7272
/* "bzrlib/_btree_serializer_pyx.pyx":960
7273
* if first_ref_list == 0:
7275
* out = out + 1 # <<<<<<<<<<<<<<
7276
* first_ref_list = 0
7277
* first_reference = 1
7279
__pyx_v_out = (__pyx_v_out + 1);
7284
/* "bzrlib/_btree_serializer_pyx.pyx":961
7287
* first_ref_list = 0 # <<<<<<<<<<<<<<
7288
* first_reference = 1
7289
* for reference in ref_list:
7291
__pyx_v_first_ref_list = 0;
7293
/* "bzrlib/_btree_serializer_pyx.pyx":962
7295
* first_ref_list = 0
7296
* first_reference = 1 # <<<<<<<<<<<<<<
7297
* for reference in ref_list:
7298
* if first_reference == 0:
7300
__pyx_v_first_reference = 1;
7302
/* "bzrlib/_btree_serializer_pyx.pyx":963
7303
* first_ref_list = 0
7304
* first_reference = 1
7305
* for reference in ref_list: # <<<<<<<<<<<<<<
7306
* if first_reference == 0:
7309
if (PyList_CheckExact(__pyx_v_ref_list) || PyTuple_CheckExact(__pyx_v_ref_list)) {
7310
__pyx_t_9 = 0; __pyx_t_8 = __pyx_v_ref_list; __Pyx_INCREF(__pyx_t_8);
7312
__pyx_t_9 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_ref_list); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7313
__Pyx_GOTREF(__pyx_t_8);
7316
if (likely(PyList_CheckExact(__pyx_t_8))) {
7317
if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_8)) break;
7318
__pyx_t_4 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++;
7319
} else if (likely(PyTuple_CheckExact(__pyx_t_8))) {
7320
if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
7321
__pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++;
7323
__pyx_t_4 = PyIter_Next(__pyx_t_8);
7325
if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7328
__Pyx_GOTREF(__pyx_t_4);
7330
__Pyx_DECREF(__pyx_v_reference);
7331
__pyx_v_reference = __pyx_t_4;
7334
/* "bzrlib/_btree_serializer_pyx.pyx":964
7335
* first_reference = 1
7336
* for reference in ref_list:
7337
* if first_reference == 0: # <<<<<<<<<<<<<<
7341
__pyx_t_2 = (__pyx_v_first_reference == 0);
7344
/* "bzrlib/_btree_serializer_pyx.pyx":965
7345
* for reference in ref_list:
7346
* if first_reference == 0:
7347
* out[0] = c'\r' # <<<<<<<<<<<<<<
7349
* first_reference = 0
7351
(__pyx_v_out[0]) = '\r';
7353
/* "bzrlib/_btree_serializer_pyx.pyx":966
7354
* if first_reference == 0:
7356
* out = out + 1 # <<<<<<<<<<<<<<
7357
* first_reference = 0
7358
* next_len = len(reference)
7360
__pyx_v_out = (__pyx_v_out + 1);
7365
/* "bzrlib/_btree_serializer_pyx.pyx":967
7368
* first_reference = 0 # <<<<<<<<<<<<<<
7369
* next_len = len(reference)
7370
* for i from 0 <= i < next_len:
7372
__pyx_v_first_reference = 0;
7374
/* "bzrlib/_btree_serializer_pyx.pyx":968
7376
* first_reference = 0
7377
* next_len = len(reference) # <<<<<<<<<<<<<<
7378
* for i from 0 <= i < next_len:
7381
__pyx_t_11 = PyObject_Length(__pyx_v_reference); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7382
__pyx_v_next_len = __pyx_t_11;
7384
/* "bzrlib/_btree_serializer_pyx.pyx":969
7385
* first_reference = 0
7386
* next_len = len(reference)
7387
* for i from 0 <= i < next_len: # <<<<<<<<<<<<<<
7391
__pyx_t_11 = __pyx_v_next_len;
7392
for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_11; __pyx_v_i++) {
7394
/* "bzrlib/_btree_serializer_pyx.pyx":970
7395
* next_len = len(reference)
7396
* for i from 0 <= i < next_len:
7397
* if i != 0: # <<<<<<<<<<<<<<
7401
__pyx_t_2 = (__pyx_v_i != 0);
7404
/* "bzrlib/_btree_serializer_pyx.pyx":971
7405
* for i from 0 <= i < next_len:
7407
* out[0] = c'\x00' # <<<<<<<<<<<<<<
7409
* ref_bit = reference[i]
7411
(__pyx_v_out[0]) = '\x00';
7413
/* "bzrlib/_btree_serializer_pyx.pyx":972
7416
* out = out + 1 # <<<<<<<<<<<<<<
7417
* ref_bit = reference[i]
7418
* ref_bit_len = PyString_GET_SIZE(ref_bit)
7420
__pyx_v_out = (__pyx_v_out + 1);
7425
/* "bzrlib/_btree_serializer_pyx.pyx":973
7428
* ref_bit = reference[i] # <<<<<<<<<<<<<<
7429
* ref_bit_len = PyString_GET_SIZE(ref_bit)
7430
* memcpy(out, PyString_AS_STRING(ref_bit), ref_bit_len)
7432
__pyx_t_4 = __Pyx_GetItemInt(__pyx_v_reference, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7433
__Pyx_GOTREF(__pyx_t_4);
7434
__Pyx_DECREF(__pyx_v_ref_bit);
7435
__pyx_v_ref_bit = __pyx_t_4;
7438
/* "bzrlib/_btree_serializer_pyx.pyx":974
7440
* ref_bit = reference[i]
7441
* ref_bit_len = PyString_GET_SIZE(ref_bit) # <<<<<<<<<<<<<<
7442
* memcpy(out, PyString_AS_STRING(ref_bit), ref_bit_len)
7443
* out = out + ref_bit_len
7445
__pyx_v_ref_bit_len = PyString_GET_SIZE(__pyx_v_ref_bit);
7447
/* "bzrlib/_btree_serializer_pyx.pyx":975
7448
* ref_bit = reference[i]
7449
* ref_bit_len = PyString_GET_SIZE(ref_bit)
7450
* memcpy(out, PyString_AS_STRING(ref_bit), ref_bit_len) # <<<<<<<<<<<<<<
7451
* out = out + ref_bit_len
7454
memcpy(__pyx_v_out, PyString_AS_STRING(__pyx_v_ref_bit), __pyx_v_ref_bit_len);
7456
/* "bzrlib/_btree_serializer_pyx.pyx":976
7457
* ref_bit_len = PyString_GET_SIZE(ref_bit)
7458
* memcpy(out, PyString_AS_STRING(ref_bit), ref_bit_len)
7459
* out = out + ref_bit_len # <<<<<<<<<<<<<<
7463
__pyx_v_out = (__pyx_v_out + __pyx_v_ref_bit_len);
7466
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7468
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7473
/* "bzrlib/_btree_serializer_pyx.pyx":977
7474
* memcpy(out, PyString_AS_STRING(ref_bit), ref_bit_len)
7475
* out = out + ref_bit_len
7476
* out[0] = c'\0' # <<<<<<<<<<<<<<
7478
* memcpy(out, value, value_len)
7480
(__pyx_v_out[0]) = '\x00';
7482
/* "bzrlib/_btree_serializer_pyx.pyx":978
7483
* out = out + ref_bit_len
7485
* out = out + 1 # <<<<<<<<<<<<<<
7486
* memcpy(out, value, value_len)
7487
* out = out + value_len
7489
__pyx_v_out = (__pyx_v_out + 1);
7491
/* "bzrlib/_btree_serializer_pyx.pyx":979
7494
* memcpy(out, value, value_len) # <<<<<<<<<<<<<<
7495
* out = out + value_len
7498
memcpy(__pyx_v_out, __pyx_v_value, __pyx_v_value_len);
7500
/* "bzrlib/_btree_serializer_pyx.pyx":980
7502
* memcpy(out, value, value_len)
7503
* out = out + value_len # <<<<<<<<<<<<<<
7505
* return string_key, line
7507
__pyx_v_out = (__pyx_v_out + __pyx_v_value_len);
7509
/* "bzrlib/_btree_serializer_pyx.pyx":981
7510
* memcpy(out, value, value_len)
7511
* out = out + value_len
7512
* out[0] = c'\n' # <<<<<<<<<<<<<<
7513
* return string_key, line
7515
(__pyx_v_out[0]) = '\n';
7517
/* "bzrlib/_btree_serializer_pyx.pyx":982
7518
* out = out + value_len
7520
* return string_key, line # <<<<<<<<<<<<<<
7522
__Pyx_XDECREF(__pyx_r);
7523
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7524
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
7525
__Pyx_INCREF(__pyx_v_string_key);
7526
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_string_key);
7527
__Pyx_GIVEREF(__pyx_v_string_key);
7528
__Pyx_INCREF(__pyx_v_line);
7529
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_line);
7530
__Pyx_GIVEREF(__pyx_v_line);
7531
__pyx_r = ((PyObject *)__pyx_t_5);
7535
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
7538
__Pyx_XDECREF(__pyx_t_4);
7539
__Pyx_XDECREF(__pyx_t_5);
7540
__Pyx_XDECREF(__pyx_t_8);
7541
__Pyx_XDECREF(__pyx_t_10);
7542
__Pyx_XDECREF(__pyx_t_12);
7543
__Pyx_AddTraceback("bzrlib._btree_serializer_pyx._flatten_node");
7546
__Pyx_DECREF(__pyx_v_string_key);
7547
__Pyx_DECREF(__pyx_v_ref_lists);
7548
__Pyx_DECREF(__pyx_v_ref_list);
7549
__Pyx_DECREF(__pyx_v_reference);
7550
__Pyx_DECREF(__pyx_v_ref_bit);
7551
__Pyx_DECREF(__pyx_v_val);
7552
__Pyx_DECREF(__pyx_v_line);
7553
__Pyx_XGIVEREF(__pyx_r);
7554
__Pyx_RefNannyFinishContext();
7557
static struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser __pyx_vtable_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser;
7559
static PyObject *__pyx_tp_new_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser(PyTypeObject *t, PyObject *a, PyObject *k) {
7560
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *p;
7561
PyObject *o = (*t->tp_alloc)(t, 0);
7563
p = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)o);
7564
p->__pyx_vtab = __pyx_vtabptr_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser;
7565
p->bytes = Py_None; Py_INCREF(Py_None);
7566
p->keys = Py_None; Py_INCREF(Py_None);
7570
static void __pyx_tp_dealloc_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser(PyObject *o) {
7571
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *p = (struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)o;
7572
Py_XDECREF(p->bytes);
7573
Py_XDECREF(p->keys);
7574
(*Py_TYPE(o)->tp_free)(o);
7577
static int __pyx_tp_traverse_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser(PyObject *o, visitproc v, void *a) {
7579
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *p = (struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)o;
7581
e = (*v)(p->bytes, a); if (e) return e;
7584
e = (*v)(p->keys, a); if (e) return e;
7589
static int __pyx_tp_clear_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser(PyObject *o) {
7590
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *p = (struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *)o;
7592
tmp = ((PyObject*)p->bytes);
7593
p->bytes = Py_None; Py_INCREF(Py_None);
7595
tmp = ((PyObject*)p->keys);
7596
p->keys = Py_None; Py_INCREF(Py_None);
7601
static PyMethodDef __pyx_methods_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser[] = {
7602
{__Pyx_NAMESTR("parse"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser_1parse, METH_NOARGS, __Pyx_DOCSTR(0)},
7606
static PyNumberMethods __pyx_tp_as_number_BTreeLeafParser = {
7610
#if PY_MAJOR_VERSION < 3
7626
#if PY_MAJOR_VERSION < 3
7630
#if PY_MAJOR_VERSION < 3
7636
#if PY_MAJOR_VERSION < 3
7639
#if PY_MAJOR_VERSION < 3
7642
0, /*nb_inplace_add*/
7643
0, /*nb_inplace_subtract*/
7644
0, /*nb_inplace_multiply*/
7645
#if PY_MAJOR_VERSION < 3
7646
0, /*nb_inplace_divide*/
7648
0, /*nb_inplace_remainder*/
7649
0, /*nb_inplace_power*/
7650
0, /*nb_inplace_lshift*/
7651
0, /*nb_inplace_rshift*/
7652
0, /*nb_inplace_and*/
7653
0, /*nb_inplace_xor*/
7654
0, /*nb_inplace_or*/
7655
0, /*nb_floor_divide*/
7656
0, /*nb_true_divide*/
7657
0, /*nb_inplace_floor_divide*/
7658
0, /*nb_inplace_true_divide*/
7659
#if PY_VERSION_HEX >= 0x02050000
7664
static PySequenceMethods __pyx_tp_as_sequence_BTreeLeafParser = {
7673
0, /*sq_inplace_concat*/
7674
0, /*sq_inplace_repeat*/
7677
static PyMappingMethods __pyx_tp_as_mapping_BTreeLeafParser = {
7680
0, /*mp_ass_subscript*/
7683
static PyBufferProcs __pyx_tp_as_buffer_BTreeLeafParser = {
7684
#if PY_MAJOR_VERSION < 3
7685
0, /*bf_getreadbuffer*/
7687
#if PY_MAJOR_VERSION < 3
7688
0, /*bf_getwritebuffer*/
7690
#if PY_MAJOR_VERSION < 3
7691
0, /*bf_getsegcount*/
7693
#if PY_MAJOR_VERSION < 3
7694
0, /*bf_getcharbuffer*/
7696
#if PY_VERSION_HEX >= 0x02060000
7699
#if PY_VERSION_HEX >= 0x02060000
7700
0, /*bf_releasebuffer*/
7704
static PyTypeObject __pyx_type_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser = {
7705
PyVarObject_HEAD_INIT(0, 0)
7706
__Pyx_NAMESTR("bzrlib._btree_serializer_pyx.BTreeLeafParser"), /*tp_name*/
7707
sizeof(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser), /*tp_basicsize*/
7709
__pyx_tp_dealloc_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser, /*tp_dealloc*/
7713
#if PY_MAJOR_VERSION < 3
7719
&__pyx_tp_as_number_BTreeLeafParser, /*tp_as_number*/
7720
&__pyx_tp_as_sequence_BTreeLeafParser, /*tp_as_sequence*/
7721
&__pyx_tp_as_mapping_BTreeLeafParser, /*tp_as_mapping*/
7727
&__pyx_tp_as_buffer_BTreeLeafParser, /*tp_as_buffer*/
7728
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
7729
__Pyx_DOCSTR("Parse the leaf nodes of a BTree index.\n\n :ivar bytes: The PyString object containing the uncompressed text for the\n node.\n :ivar key_length: An integer describing how many pieces the keys have for\n this index.\n :ivar ref_list_length: An integer describing how many references this index\n contains.\n :ivar keys: A PyList of keys found in this node.\n\n :ivar _cur_str: A pointer to the start of the next line to parse\n :ivar _end_str: A pointer to the end of bytes\n :ivar _start: Pointer to the location within the current line while\n parsing.\n :ivar _header_found: True when we have parsed the header for this node\n "), /*tp_doc*/
7730
__pyx_tp_traverse_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser, /*tp_traverse*/
7731
__pyx_tp_clear_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser, /*tp_clear*/
7732
0, /*tp_richcompare*/
7733
0, /*tp_weaklistoffset*/
7736
__pyx_methods_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser, /*tp_methods*/
7743
0, /*tp_dictoffset*/
7744
__pyx_pf_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser___init__, /*tp_init*/
7746
__pyx_tp_new_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser, /*tp_new*/
7752
0, /*tp_subclasses*/
7755
#if PY_VERSION_HEX >= 0x02060000
7756
0, /*tp_version_tag*/
7759
static struct __pyx_vtabstruct_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode __pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
7761
static PyObject *__pyx_tp_new_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyTypeObject *t, PyObject *a, PyObject *k) {
7762
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *p;
7763
PyObject *o = (*t->tp_alloc)(t, 0);
7765
p = ((struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)o);
7766
p->__pyx_vtab = __pyx_vtabptr_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
7767
p->last_key = Py_None; Py_INCREF(Py_None);
7771
static void __pyx_tp_dealloc_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject *o) {
7772
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *p = (struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)o;
7774
PyObject *etype, *eval, *etb;
7775
PyErr_Fetch(&etype, &eval, &etb);
7777
__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_1__dealloc__(o);
7778
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
7780
PyErr_Restore(etype, eval, etb);
7782
Py_XDECREF(p->last_key);
7783
(*Py_TYPE(o)->tp_free)(o);
7786
static int __pyx_tp_traverse_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject *o, visitproc v, void *a) {
7788
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *p = (struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)o;
7790
e = (*v)(p->last_key, a); if (e) return e;
7795
static int __pyx_tp_clear_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject *o) {
7796
struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *p = (struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)o;
7798
tmp = ((PyObject*)p->last_key);
7799
p->last_key = Py_None; Py_INCREF(Py_None);
7803
static PyObject *__pyx_sq_item_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject *o, Py_ssize_t i) {
7805
PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
7806
r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
7811
static PyObject *__pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_min_key(PyObject *o, void *x) {
7812
return __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key___get__(o);
7815
static PyObject *__pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_max_key(PyObject *o, void *x) {
7816
return __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key___get__(o);
7819
static PyObject *__pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key(PyObject *o, void *x) {
7820
return __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key___get__(o);
7823
static int __pyx_setprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key(PyObject *o, PyObject *v, void *x) {
7825
return __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_1__set__(o, v);
7828
return __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_2__del__(o);
7832
static PyObject *__pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records(PyObject *o, void *x) {
7833
return __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records___get__(o);
7836
static int __pyx_setprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records(PyObject *o, PyObject *v, void *x) {
7838
return __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_1__set__(o, v);
7841
PyErr_SetString(PyExc_NotImplementedError, "__del__");
7846
static PyObject *__pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift(PyObject *o, void *x) {
7847
return __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift___get__(o);
7850
static int __pyx_setprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift(PyObject *o, PyObject *v, void *x) {
7852
return __pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_1__set__(o, v);
7855
PyErr_SetString(PyExc_NotImplementedError, "__del__");
7860
static PyMethodDef __pyx_methods_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode[] = {
7861
{__Pyx_NAMESTR("__sizeof__"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode___sizeof__, METH_NOARGS, __Pyx_DOCSTR(0)},
7862
{__Pyx_NAMESTR("all_keys"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_6all_keys, METH_NOARGS, __Pyx_DOCSTR(0)},
7863
{__Pyx_NAMESTR("all_items"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7all_items, METH_NOARGS, __Pyx_DOCSTR(0)},
7864
{__Pyx_NAMESTR("_get_offset_for_sha1"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8_get_offset_for_sha1, METH_O, __Pyx_DOCSTR(0)},
7865
{__Pyx_NAMESTR("_get_offsets"), (PyCFunction)__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_9_get_offsets, METH_NOARGS, __Pyx_DOCSTR(0)},
7869
static struct PyGetSetDef __pyx_getsets_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode[] = {
7870
{(char *)"min_key", __pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_min_key, 0, 0, 0},
7871
{(char *)"max_key", __pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_max_key, 0, 0, 0},
7872
{(char *)"last_key", __pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key, __pyx_setprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key, 0, 0},
7873
{(char *)"num_records", __pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records, __pyx_setprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records, 0, 0},
7874
{(char *)"common_shift", __pyx_getprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift, __pyx_setprop_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift, 0, 0},
7878
static PyNumberMethods __pyx_tp_as_number_GCCHKSHA1LeafNode = {
7882
#if PY_MAJOR_VERSION < 3
7898
#if PY_MAJOR_VERSION < 3
7902
#if PY_MAJOR_VERSION < 3
7908
#if PY_MAJOR_VERSION < 3
7911
#if PY_MAJOR_VERSION < 3
7914
0, /*nb_inplace_add*/
7915
0, /*nb_inplace_subtract*/
7916
0, /*nb_inplace_multiply*/
7917
#if PY_MAJOR_VERSION < 3
7918
0, /*nb_inplace_divide*/
7920
0, /*nb_inplace_remainder*/
7921
0, /*nb_inplace_power*/
7922
0, /*nb_inplace_lshift*/
7923
0, /*nb_inplace_rshift*/
7924
0, /*nb_inplace_and*/
7925
0, /*nb_inplace_xor*/
7926
0, /*nb_inplace_or*/
7927
0, /*nb_floor_divide*/
7928
0, /*nb_true_divide*/
7929
0, /*nb_inplace_floor_divide*/
7930
0, /*nb_inplace_true_divide*/
7931
#if PY_VERSION_HEX >= 0x02050000
7936
static PySequenceMethods __pyx_tp_as_sequence_GCCHKSHA1LeafNode = {
7937
__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_5__len__, /*sq_length*/
7940
__pyx_sq_item_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*sq_item*/
7944
__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_3__contains__, /*sq_contains*/
7945
0, /*sq_inplace_concat*/
7946
0, /*sq_inplace_repeat*/
7949
static PyMappingMethods __pyx_tp_as_mapping_GCCHKSHA1LeafNode = {
7950
__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_5__len__, /*mp_length*/
7951
__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_4__getitem__, /*mp_subscript*/
7952
0, /*mp_ass_subscript*/
7955
static PyBufferProcs __pyx_tp_as_buffer_GCCHKSHA1LeafNode = {
7956
#if PY_MAJOR_VERSION < 3
7957
0, /*bf_getreadbuffer*/
7959
#if PY_MAJOR_VERSION < 3
7960
0, /*bf_getwritebuffer*/
7962
#if PY_MAJOR_VERSION < 3
7963
0, /*bf_getsegcount*/
7965
#if PY_MAJOR_VERSION < 3
7966
0, /*bf_getcharbuffer*/
7968
#if PY_VERSION_HEX >= 0x02060000
7971
#if PY_VERSION_HEX >= 0x02060000
7972
0, /*bf_releasebuffer*/
7976
static PyTypeObject __pyx_type_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode = {
7977
PyVarObject_HEAD_INIT(0, 0)
7978
__Pyx_NAMESTR("bzrlib._btree_serializer_pyx.GCCHKSHA1LeafNode"), /*tp_name*/
7979
sizeof(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode), /*tp_basicsize*/
7981
__pyx_tp_dealloc_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_dealloc*/
7985
#if PY_MAJOR_VERSION < 3
7991
&__pyx_tp_as_number_GCCHKSHA1LeafNode, /*tp_as_number*/
7992
&__pyx_tp_as_sequence_GCCHKSHA1LeafNode, /*tp_as_sequence*/
7993
&__pyx_tp_as_mapping_GCCHKSHA1LeafNode, /*tp_as_mapping*/
7999
&__pyx_tp_as_buffer_GCCHKSHA1LeafNode, /*tp_as_buffer*/
8000
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
8001
__Pyx_DOCSTR("Track all the entries for a given leaf node."), /*tp_doc*/
8002
__pyx_tp_traverse_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_traverse*/
8003
__pyx_tp_clear_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_clear*/
8004
0, /*tp_richcompare*/
8005
0, /*tp_weaklistoffset*/
8008
__pyx_methods_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_methods*/
8010
__pyx_getsets_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_getset*/
8015
0, /*tp_dictoffset*/
8016
__pyx_pf_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_2__init__, /*tp_init*/
8018
__pyx_tp_new_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_new*/
8024
0, /*tp_subclasses*/
8027
#if PY_VERSION_HEX >= 0x02060000
8028
0, /*tp_version_tag*/
8032
static PyMethodDef __pyx_methods[] = {
8036
#if PY_MAJOR_VERSION >= 3
8037
static struct PyModuleDef __pyx_moduledef = {
8038
PyModuleDef_HEAD_INIT,
8039
__Pyx_NAMESTR("_btree_serializer_pyx"),
8040
__Pyx_DOCSTR(__pyx_k_55), /* m_doc */
8042
__pyx_methods /* m_methods */,
8043
NULL, /* m_reload */
8044
NULL, /* m_traverse */
8050
static __Pyx_StringTabEntry __pyx_string_tab[] = {
8051
{&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
8052
{&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
8053
{&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
8054
{&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
8055
{&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
8056
{&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
8057
{&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
8058
{&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
8059
{&__pyx_n_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 1},
8060
{&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
8061
{&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
8062
{&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
8063
{&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0},
8064
{&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
8065
{&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0},
8066
{&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0},
8067
{&__pyx_kp_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 0},
8068
{&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
8069
{&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0},
8070
{&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0},
8071
{&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
8072
{&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0},
8073
{&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
8074
{&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0},
8075
{&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0},
8076
{&__pyx_kp_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 0},
8077
{&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
8078
{&__pyx_kp_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 0},
8079
{&__pyx_n_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 1},
8080
{&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
8081
{&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
8082
{&__pyx_n_s__AssertionError, __pyx_k__AssertionError, sizeof(__pyx_k__AssertionError), 0, 0, 1, 1},
8083
{&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
8084
{&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
8085
{&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
8086
{&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
8087
{&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
8088
{&__pyx_n_s___compute_common, __pyx_k___compute_common, sizeof(__pyx_k___compute_common), 0, 0, 1, 1},
8089
{&__pyx_n_s___count_records, __pyx_k___count_records, sizeof(__pyx_k___count_records), 0, 0, 1, 1},
8090
{&__pyx_n_s___cur_str, __pyx_k___cur_str, sizeof(__pyx_k___cur_str), 0, 0, 1, 1},
8091
{&__pyx_n_s___end_str, __pyx_k___end_str, sizeof(__pyx_k___end_str), 0, 0, 1, 1},
8092
{&__pyx_n_s___flatten_node, __pyx_k___flatten_node, sizeof(__pyx_k___flatten_node), 0, 0, 1, 1},
8093
{&__pyx_n_s___header_found, __pyx_k___header_found, sizeof(__pyx_k___header_found), 0, 0, 1, 1},
8094
{&__pyx_n_s___lookup_record, __pyx_k___lookup_record, sizeof(__pyx_k___lookup_record), 0, 0, 1, 1},
8095
{&__pyx_n_s___offset_for_sha1, __pyx_k___offset_for_sha1, sizeof(__pyx_k___offset_for_sha1), 0, 0, 1, 1},
8096
{&__pyx_n_s___parse_bytes, __pyx_k___parse_bytes, sizeof(__pyx_k___parse_bytes), 0, 0, 1, 1},
8097
{&__pyx_n_s___parse_into_chk, __pyx_k___parse_into_chk, sizeof(__pyx_k___parse_into_chk), 0, 0, 1, 1},
8098
{&__pyx_n_s___parse_leaf_lines, __pyx_k___parse_leaf_lines, sizeof(__pyx_k___parse_leaf_lines), 0, 0, 1, 1},
8099
{&__pyx_n_s___parse_one_entry, __pyx_k___parse_one_entry, sizeof(__pyx_k___parse_one_entry), 0, 0, 1, 1},
8100
{&__pyx_n_s___py_hexlify, __pyx_k___py_hexlify, sizeof(__pyx_k___py_hexlify), 0, 0, 1, 1},
8101
{&__pyx_n_s___py_key_to_sha1, __pyx_k___py_key_to_sha1, sizeof(__pyx_k___py_key_to_sha1), 0, 0, 1, 1},
8102
{&__pyx_n_s___py_sha1_to_key, __pyx_k___py_sha1_to_key, sizeof(__pyx_k___py_sha1_to_key), 0, 0, 1, 1},
8103
{&__pyx_n_s___py_unhexlify, __pyx_k___py_unhexlify, sizeof(__pyx_k___py_unhexlify), 0, 0, 1, 1},
8104
{&__pyx_n_s___record_to_item, __pyx_k___record_to_item, sizeof(__pyx_k___record_to_item), 0, 0, 1, 1},
8105
{&__pyx_n_s___start, __pyx_k___start, sizeof(__pyx_k___start), 0, 0, 1, 1},
8106
{&__pyx_n_s__block_length, __pyx_k__block_length, sizeof(__pyx_k__block_length), 0, 0, 1, 1},
8107
{&__pyx_n_s__block_offset, __pyx_k__block_offset, sizeof(__pyx_k__block_offset), 0, 0, 1, 1},
8108
{&__pyx_n_s__bytes, __pyx_k__bytes, sizeof(__pyx_k__bytes), 0, 0, 1, 1},
8109
{&__pyx_n_s__common_shift, __pyx_k__common_shift, sizeof(__pyx_k__common_shift), 0, 0, 1, 1},
8110
{&__pyx_n_s__extract_key, __pyx_k__extract_key, sizeof(__pyx_k__extract_key), 0, 0, 1, 1},
8111
{&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
8112
{&__pyx_n_s__key_length, __pyx_k__key_length, sizeof(__pyx_k__key_length), 0, 0, 1, 1},
8113
{&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
8114
{&__pyx_n_s__last_key, __pyx_k__last_key, sizeof(__pyx_k__last_key), 0, 0, 1, 1},
8115
{&__pyx_n_s__last_record, __pyx_k__last_record, sizeof(__pyx_k__last_record), 0, 0, 1, 1},
8116
{&__pyx_n_s__node, __pyx_k__node, sizeof(__pyx_k__node), 0, 0, 1, 1},
8117
{&__pyx_n_s__num_records, __pyx_k__num_records, sizeof(__pyx_k__num_records), 0, 0, 1, 1},
8118
{&__pyx_n_s__offsets, __pyx_k__offsets, sizeof(__pyx_k__offsets), 0, 0, 1, 1},
8119
{&__pyx_n_s__parse, __pyx_k__parse, sizeof(__pyx_k__parse), 0, 0, 1, 1},
8120
{&__pyx_n_s__process_line, __pyx_k__process_line, sizeof(__pyx_k__process_line), 0, 0, 1, 1},
8121
{&__pyx_n_s__record_end, __pyx_k__record_end, sizeof(__pyx_k__record_end), 0, 0, 1, 1},
8122
{&__pyx_n_s__record_start, __pyx_k__record_start, sizeof(__pyx_k__record_start), 0, 0, 1, 1},
8123
{&__pyx_n_s__records, __pyx_k__records, sizeof(__pyx_k__records), 0, 0, 1, 1},
8124
{&__pyx_n_s__ref_list_length, __pyx_k__ref_list_length, sizeof(__pyx_k__ref_list_length), 0, 0, 1, 1},
8125
{&__pyx_n_s__reference_lists, __pyx_k__reference_lists, sizeof(__pyx_k__reference_lists), 0, 0, 1, 1},
8126
{&__pyx_n_s__sha1, __pyx_k__sha1, sizeof(__pyx_k__sha1), 0, 0, 1, 1},
8127
{&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
8128
{0, 0, 0, 0, 0, 0, 0}
8130
static int __Pyx_InitCachedBuiltins(void) {
8131
__pyx_builtin_AssertionError = __Pyx_GetName(__pyx_b, __pyx_n_s__AssertionError); if (!__pyx_builtin_AssertionError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8132
__pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8133
__pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8134
__pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8140
static int __Pyx_InitCachedConstants(void) {
8141
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");
8143
/* "bzrlib/_btree_serializer_pyx.pyx":229
8144
* if last < self._start:
8145
* # Unexpected error condition - fail
8146
* raise AssertionError("last < self._start") # <<<<<<<<<<<<<<
8147
* if 0 == self._header_found:
8148
* # The first line in a leaf node is the header "type=leaf\n"
8150
__pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8151
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_5));
8152
__Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
8153
PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_4));
8154
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
8155
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));
8157
/* "bzrlib/_btree_serializer_pyx.pyx":244
8158
* if temp_ptr == NULL:
8160
* raise AssertionError("Failed to find the value area") # <<<<<<<<<<<<<<
8162
* # Because of how conversions were done, we ended up with *lots* of
8164
__pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8165
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_9));
8166
__Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
8167
PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_s_8));
8168
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
8169
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9));
8171
/* "bzrlib/_btree_serializer_pyx.pyx":271
8172
* loop_counter = loop_counter + 1
8173
* if last < self._start:
8174
* raise AssertionError("last < self._start") # <<<<<<<<<<<<<<
8175
* # find the next reference list end point:
8176
* temp_ptr = <char*>memchr(self._start, c'\t', last - self._start)
8178
__pyx_k_tuple_11 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8179
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_11));
8180
__Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
8181
PyTuple_SET_ITEM(__pyx_k_tuple_11, 0, ((PyObject *)__pyx_kp_s_4));
8182
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
8183
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11));
8185
/* "bzrlib/_btree_serializer_pyx.pyx":278
8186
* if loop_counter != self.ref_list_length:
8188
* raise AssertionError( # <<<<<<<<<<<<<<
8189
* "invalid key, loop_counter != self.ref_list_length")
8192
__pyx_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8193
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_13));
8194
__Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
8195
PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_kp_s_12));
8196
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
8197
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13));
8199
/* "bzrlib/_btree_serializer_pyx.pyx":307
8200
* if last != self._start:
8201
* # unexpected reference data present
8202
* raise AssertionError("unexpected reference data present") # <<<<<<<<<<<<<<
8203
* node_value = StaticTuple(value, StaticTuple())
8204
* PyList_Append(self.keys, StaticTuple(key, node_value))
8206
__pyx_k_tuple_15 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8207
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_15));
8208
__Pyx_INCREF(((PyObject *)__pyx_kp_s_14));
8209
PyTuple_SET_ITEM(__pyx_k_tuple_15, 0, ((PyObject *)__pyx_kp_s_14));
8210
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_14));
8211
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15));
8213
/* "bzrlib/_btree_serializer_pyx.pyx":315
8214
* cdef Py_ssize_t byte_count
8215
* if not PyString_CheckExact(self.bytes):
8216
* raise AssertionError('self.bytes is not a string.') # <<<<<<<<<<<<<<
8217
* byte_count = PyString_Size(self.bytes)
8218
* self._cur_str = PyString_AsString(self.bytes)
8220
__pyx_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8221
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_17));
8222
__Pyx_INCREF(((PyObject *)__pyx_kp_s_16));
8223
PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_kp_s_16));
8224
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16));
8225
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17));
8227
/* "bzrlib/_btree_serializer_pyx.pyx":389
8228
* """For the test infrastructure, just thunks to _unhexlify_sha1"""
8229
* if len(as_hex) != 40 or not PyString_CheckExact(as_hex):
8230
* raise ValueError('not a 40-byte hex digest') # <<<<<<<<<<<<<<
8231
* as_bin = PyString_FromStringAndSize(NULL, 20)
8232
* if _unhexlify_sha1(PyString_AS_STRING(as_hex), PyString_AS_STRING(as_bin)):
8234
__pyx_k_tuple_19 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8235
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_19));
8236
__Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
8237
PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_kp_s_18));
8238
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
8239
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19));
8241
/* "bzrlib/_btree_serializer_pyx.pyx":412
8242
* """For test infrastructure, thunk to _hexlify_sha1"""
8243
* if len(as_bin) != 20 or not PyString_CheckExact(as_bin):
8244
* raise ValueError('not a 20-byte binary digest') # <<<<<<<<<<<<<<
8245
* as_hex = PyString_FromStringAndSize(NULL, 40)
8246
* _hexlify_sha1(PyString_AS_STRING(as_bin), PyString_AS_STRING(as_hex))
8248
__pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8249
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_21));
8250
__Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
8251
PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_kp_s_20));
8252
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
8253
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21));
8255
/* "bzrlib/_btree_serializer_pyx.pyx":485
8256
* """Test thunk to check the sha1 mapping."""
8257
* if not PyString_CheckExact(sha1_bin) or PyString_GET_SIZE(sha1_bin) != 20:
8258
* raise ValueError('sha1_bin must be a str of exactly 20 bytes') # <<<<<<<<<<<<<<
8259
* return _sha1_to_key(PyString_AS_STRING(sha1_bin))
8262
__pyx_k_tuple_23 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8263
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_23));
8264
__Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
8265
PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_kp_s_22));
8266
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
8267
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));
8269
/* "bzrlib/_btree_serializer_pyx.pyx":708
8271
* if not PyString_CheckExact(bytes):
8272
* raise TypeError('We only support parsing plain 8-bit strings.') # <<<<<<<<<<<<<<
8273
* # Pass 1, count how many records there will be
8274
* n_bytes = PyString_GET_SIZE(bytes)
8276
__pyx_k_tuple_29 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8277
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_29));
8278
__Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
8279
PyTuple_SET_ITEM(__pyx_k_tuple_29, 0, ((PyObject *)__pyx_kp_s_28));
8280
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
8281
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29));
8283
/* "bzrlib/_btree_serializer_pyx.pyx":731
8285
* or cur_record != self.records + self.num_records):
8286
* raise ValueError('Something went wrong while parsing.') # <<<<<<<<<<<<<<
8287
* # Pass 3: build the offset map
8288
* self._compute_common()
8290
__pyx_k_tuple_33 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8291
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_33));
8292
__Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
8293
PyTuple_SET_ITEM(__pyx_k_tuple_33, 0, ((PyObject *)__pyx_kp_s_32));
8294
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
8295
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33));
8297
/* "bzrlib/_btree_serializer_pyx.pyx":748
8298
* c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
8299
* if c_next == NULL or (c_next - c_cur != 40):
8300
* raise ValueError('Line did not contain 40 hex bytes') # <<<<<<<<<<<<<<
8301
* if not _unhexlify_sha1(c_cur, cur_record.sha1):
8302
* raise ValueError('We failed to unhexlify')
8304
__pyx_k_tuple_36 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8305
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_36));
8306
__Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
8307
PyTuple_SET_ITEM(__pyx_k_tuple_36, 0, ((PyObject *)__pyx_kp_s_35));
8308
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
8309
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36));
8311
/* "bzrlib/_btree_serializer_pyx.pyx":750
8312
* raise ValueError('Line did not contain 40 hex bytes')
8313
* if not _unhexlify_sha1(c_cur, cur_record.sha1):
8314
* raise ValueError('We failed to unhexlify') # <<<<<<<<<<<<<<
8315
* c_cur = c_next + 1
8316
* if c_cur[0] != c'\0':
8318
__pyx_k_tuple_38 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8319
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_38));
8320
__Pyx_INCREF(((PyObject *)__pyx_kp_s_37));
8321
PyTuple_SET_ITEM(__pyx_k_tuple_38, 0, ((PyObject *)__pyx_kp_s_37));
8322
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_37));
8323
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_38));
8325
/* "bzrlib/_btree_serializer_pyx.pyx":753
8326
* c_cur = c_next + 1
8327
* if c_cur[0] != c'\0':
8328
* raise ValueError('only 1 null, not 2 as expected') # <<<<<<<<<<<<<<
8330
* cur_record.block_offset = strtoll(c_cur, &c_next, 10)
8332
__pyx_k_tuple_40 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8333
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_40));
8334
__Pyx_INCREF(((PyObject *)__pyx_kp_s_39));
8335
PyTuple_SET_ITEM(__pyx_k_tuple_40, 0, ((PyObject *)__pyx_kp_s_39));
8336
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_39));
8337
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40));
8339
/* "bzrlib/_btree_serializer_pyx.pyx":757
8340
* cur_record.block_offset = strtoll(c_cur, &c_next, 10)
8341
* if c_cur == c_next or c_next[0] != c' ':
8342
* raise ValueError('Failed to parse block offset') # <<<<<<<<<<<<<<
8343
* c_cur = c_next + 1
8344
* cur_record.block_length = strtoul(c_cur, &c_next, 10)
8346
__pyx_k_tuple_42 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8347
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_42));
8348
__Pyx_INCREF(((PyObject *)__pyx_kp_s_41));
8349
PyTuple_SET_ITEM(__pyx_k_tuple_42, 0, ((PyObject *)__pyx_kp_s_41));
8350
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_41));
8351
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42));
8353
/* "bzrlib/_btree_serializer_pyx.pyx":761
8354
* cur_record.block_length = strtoul(c_cur, &c_next, 10)
8355
* if c_cur == c_next or c_next[0] != c' ':
8356
* raise ValueError('Failed to parse block length') # <<<<<<<<<<<<<<
8357
* c_cur = c_next + 1
8358
* cur_record.record_start = strtoul(c_cur, &c_next, 10)
8360
__pyx_k_tuple_44 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8361
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_44));
8362
__Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
8363
PyTuple_SET_ITEM(__pyx_k_tuple_44, 0, ((PyObject *)__pyx_kp_s_43));
8364
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
8365
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44));
8367
/* "bzrlib/_btree_serializer_pyx.pyx":765
8368
* cur_record.record_start = strtoul(c_cur, &c_next, 10)
8369
* if c_cur == c_next or c_next[0] != c' ':
8370
* raise ValueError('Failed to parse block length') # <<<<<<<<<<<<<<
8371
* c_cur = c_next + 1
8372
* cur_record.record_end = strtoul(c_cur, &c_next, 10)
8374
__pyx_k_tuple_45 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8375
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_45));
8376
__Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
8377
PyTuple_SET_ITEM(__pyx_k_tuple_45, 0, ((PyObject *)__pyx_kp_s_43));
8378
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
8379
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45));
8381
/* "bzrlib/_btree_serializer_pyx.pyx":769
8382
* cur_record.record_end = strtoul(c_cur, &c_next, 10)
8383
* if c_cur == c_next or c_next[0] != c'\n':
8384
* raise ValueError('Failed to parse record end') # <<<<<<<<<<<<<<
8385
* c_cur = c_next + 1
8388
__pyx_k_tuple_47 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8389
__Pyx_GOTREF(((PyObject *)__pyx_k_tuple_47));
8390
__Pyx_INCREF(((PyObject *)__pyx_kp_s_46));
8391
PyTuple_SET_ITEM(__pyx_k_tuple_47, 0, ((PyObject *)__pyx_kp_s_46));
8392
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_46));
8393
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));
8394
__Pyx_RefNannyFinishContext();
8397
__Pyx_RefNannyFinishContext();
8401
static int __Pyx_InitGlobals(void) {
8402
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
8403
__pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
8404
__pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
8405
__pyx_int_2147483648 = PyInt_FromString((char *)"2147483648", 0, 0); if (unlikely(!__pyx_int_2147483648)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
8406
__pyx_int_4294967295 = PyInt_FromString((char *)"4294967295", 0, 0); if (unlikely(!__pyx_int_4294967295)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
8412
#if PY_MAJOR_VERSION < 3
8413
PyMODINIT_FUNC init_btree_serializer_pyx(void); /*proto*/
8414
PyMODINIT_FUNC init_btree_serializer_pyx(void)
8416
PyMODINIT_FUNC PyInit__btree_serializer_pyx(void); /*proto*/
8417
PyMODINIT_FUNC PyInit__btree_serializer_pyx(void)
8420
PyObject *__pyx_t_1 = NULL;
8423
void* __pyx_refnanny = NULL;
8424
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
8425
if (!__Pyx_RefNanny) {
8427
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
8428
if (!__Pyx_RefNanny)
8429
Py_FatalError("failed to import 'refnanny' module");
8431
__pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit__btree_serializer_pyx(void)", __LINE__, __FILE__);
8433
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8434
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8435
#ifdef __pyx_binding_PyCFunctionType_USED
8436
if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8438
/*--- Library function declarations ---*/
8439
/*--- Threads initialization code ---*/
8440
#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
8441
#ifdef WITH_THREAD /* Python build with threading support? */
8442
PyEval_InitThreads();
8445
/*--- Module creation code ---*/
8446
#if PY_MAJOR_VERSION < 3
8447
__pyx_m = Py_InitModule4(__Pyx_NAMESTR("_btree_serializer_pyx"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_55), 0, PYTHON_API_VERSION);
8449
__pyx_m = PyModule_Create(&__pyx_moduledef);
8451
if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
8452
#if PY_MAJOR_VERSION < 3
8455
__pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
8456
if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
8457
if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
8458
/*--- Initialize various global constants etc. ---*/
8459
if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8460
if (__pyx_module_is_main_bzrlib___btree_serializer_pyx) {
8461
if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
8463
/*--- Builtin init code ---*/
8464
if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8465
/*--- Constants init code ---*/
8466
if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8467
/*--- Global init code ---*/
8468
/*--- Function export code ---*/
8469
/*--- Type init code ---*/
8470
__pyx_vtabptr_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser = &__pyx_vtable_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser;
8471
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser.extract_key = (PyObject *(*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *, char *))__pyx_f_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser_extract_key;
8472
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser.process_line = (int (*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser *))__pyx_f_6bzrlib_21_btree_serializer_pyx_15BTreeLeafParser_process_line;
8473
if (PyType_Ready(&__pyx_type_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8474
if (__Pyx_SetVtable(__pyx_type_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser.tp_dict, __pyx_vtabptr_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8475
if (__Pyx_SetAttrString(__pyx_m, "BTreeLeafParser", (PyObject *)&__pyx_type_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8476
__pyx_ptype_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser = &__pyx_type_6bzrlib_21_btree_serializer_pyx_BTreeLeafParser;
8477
__pyx_vtabptr_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode = &__pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
8478
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode._record_to_value_and_refs = (StaticTuple *(*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *))__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_value_and_refs;
8479
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode._record_to_item = (StaticTuple *(*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *))__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_item;
8480
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode._lookup_record = (__pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *(*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *))__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__lookup_record;
8481
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode._count_records = (int (*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *, char *))__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__count_records;
8482
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode._parse_bytes = (PyObject *(*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, PyObject *))__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_bytes;
8483
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode._parse_one_entry = (char *(*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *, char *, __pyx_t_6bzrlib_21_btree_serializer_pyx_gc_chk_sha1_record *))__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_one_entry;
8484
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode._offset_for_sha1 = (int (*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *))__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__offset_for_sha1;
8485
__pyx_vtable_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode._compute_common = (PyObject *(*)(struct __pyx_obj_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode *))__pyx_f_6bzrlib_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__compute_common;
8486
if (PyType_Ready(&__pyx_type_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8487
if (__Pyx_SetVtable(__pyx_type_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode.tp_dict, __pyx_vtabptr_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8488
if (__Pyx_SetAttrString(__pyx_m, "GCCHKSHA1LeafNode", (PyObject *)&__pyx_type_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8489
__pyx_ptype_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode = &__pyx_type_6bzrlib_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
8490
/*--- Type import code ---*/
8491
__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = __Pyx_ImportType("bzrlib._static_tuple_c", "StaticTuple", sizeof(StaticTuple), 0); if (unlikely(!__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8492
/*--- Function import code ---*/
8493
/*--- Execution code ---*/
8495
/* "bzrlib/_btree_serializer_pyx.pyx":77
8496
* # have to worry about exception checking.
8497
* ## extern cdef class StaticTuple
8498
* import sys # <<<<<<<<<<<<<<
8502
__pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8503
__Pyx_GOTREF(__pyx_t_1);
8504
if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8505
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8507
/* "bzrlib/_btree_serializer_pyx.pyx":120
8509
* # This sets up the StaticTuple C_API functionality
8510
* import_static_tuple_c() # <<<<<<<<<<<<<<
8514
__pyx_t_2 = import_static_tuple_c(); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8516
/* "bzrlib/_btree_serializer_pyx.pyx":325
8519
* def _parse_leaf_lines(bytes, key_length, ref_list_length): # <<<<<<<<<<<<<<
8520
* parser = BTreeLeafParser(bytes, key_length, ref_list_length)
8521
* return parser.parse()
8523
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_21_btree_serializer_pyx__parse_leaf_lines, NULL, __pyx_n_s_56); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8524
__Pyx_GOTREF(__pyx_t_1);
8525
if (PyObject_SetAttr(__pyx_m, __pyx_n_s___parse_leaf_lines, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8526
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8528
/* "bzrlib/_btree_serializer_pyx.pyx":347
8529
* cdef int _unhexbuf[256]
8530
* cdef char *_hexbuf
8531
* _hexbuf = '0123456789abcdef' # <<<<<<<<<<<<<<
8533
* cdef _populate_unhexbuf():
8535
__pyx_v_6bzrlib_21_btree_serializer_pyx__hexbuf = __pyx_k__0123456789abcdef;
8537
/* "bzrlib/_btree_serializer_pyx.pyx":359
8538
* for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16
8539
* _unhexbuf[(i - 10 + c'A')] = i
8540
* _populate_unhexbuf() # <<<<<<<<<<<<<<
8544
__pyx_t_1 = __pyx_f_6bzrlib_21_btree_serializer_pyx__populate_unhexbuf(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8545
__Pyx_GOTREF(__pyx_t_1);
8546
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8548
/* "bzrlib/_btree_serializer_pyx.pyx":386
8551
* def _py_unhexlify(as_hex): # <<<<<<<<<<<<<<
8552
* """For the test infrastructure, just thunks to _unhexlify_sha1"""
8553
* if len(as_hex) != 40 or not PyString_CheckExact(as_hex):
8555
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_21_btree_serializer_pyx_1_py_unhexlify, NULL, __pyx_n_s_56); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8556
__Pyx_GOTREF(__pyx_t_1);
8557
if (PyObject_SetAttr(__pyx_m, __pyx_n_s___py_unhexlify, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8558
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8560
/* "bzrlib/_btree_serializer_pyx.pyx":409
8563
* def _py_hexlify(as_bin): # <<<<<<<<<<<<<<
8564
* """For test infrastructure, thunk to _hexlify_sha1"""
8565
* if len(as_bin) != 20 or not PyString_CheckExact(as_bin):
8567
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_21_btree_serializer_pyx_2_py_hexlify, NULL, __pyx_n_s_56); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8568
__Pyx_GOTREF(__pyx_t_1);
8569
if (PyObject_SetAttr(__pyx_m, __pyx_n_s___py_hexlify, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8570
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8572
/* "bzrlib/_btree_serializer_pyx.pyx":446
8575
* def _py_key_to_sha1(key): # <<<<<<<<<<<<<<
8576
* """Map a key to a simple sha1 string.
8579
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_21_btree_serializer_pyx_3_py_key_to_sha1, NULL, __pyx_n_s_56); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8580
__Pyx_GOTREF(__pyx_t_1);
8581
if (PyObject_SetAttr(__pyx_m, __pyx_n_s___py_key_to_sha1, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8582
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8584
/* "bzrlib/_btree_serializer_pyx.pyx":482
8587
* def _py_sha1_to_key(sha1_bin): # <<<<<<<<<<<<<<
8588
* """Test thunk to check the sha1 mapping."""
8589
* if not PyString_CheckExact(sha1_bin) or PyString_GET_SIZE(sha1_bin) != 20:
8591
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_21_btree_serializer_pyx_4_py_sha1_to_key, NULL, __pyx_n_s_56); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8592
__Pyx_GOTREF(__pyx_t_1);
8593
if (PyObject_SetAttr(__pyx_m, __pyx_n_s___py_sha1_to_key, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8594
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8596
/* "bzrlib/_btree_serializer_pyx.pyx":838
8599
* def _parse_into_chk(bytes, key_length, ref_list_length): # <<<<<<<<<<<<<<
8600
* """Parse into a format optimized for chk records."""
8601
* assert key_length == 1
8603
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_21_btree_serializer_pyx_5_parse_into_chk, NULL, __pyx_n_s_56); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8604
__Pyx_GOTREF(__pyx_t_1);
8605
if (PyObject_SetAttr(__pyx_m, __pyx_n_s___parse_into_chk, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8606
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8608
/* "bzrlib/_btree_serializer_pyx.pyx":845
8611
* def _flatten_node(node, reference_lists): # <<<<<<<<<<<<<<
8612
* """Convert a node into the serialized form.
8615
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_21_btree_serializer_pyx_6_flatten_node, NULL, __pyx_n_s_56); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8616
__Pyx_GOTREF(__pyx_t_1);
8617
if (PyObject_SetAttr(__pyx_m, __pyx_n_s___flatten_node, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8618
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8620
/* "bzrlib/_btree_serializer_pyx.pyx":1
8621
* # Copyright (C) 2008, 2009, 2010 Canonical Ltd # <<<<<<<<<<<<<<
8623
* # This program is free software; you can redistribute it and/or modify
8625
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8626
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
8627
if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8628
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
8631
__Pyx_XDECREF(__pyx_t_1);
8633
__Pyx_AddTraceback("init bzrlib._btree_serializer_pyx");
8634
Py_DECREF(__pyx_m); __pyx_m = 0;
8635
} else if (!PyErr_Occurred()) {
8636
PyErr_SetString(PyExc_ImportError, "init bzrlib._btree_serializer_pyx");
8639
__Pyx_RefNannyFinishContext();
8640
#if PY_MAJOR_VERSION < 3
8647
/* Runtime support code */
8649
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
8651
result = PyObject_GetAttr(dict, name);
8653
PyErr_SetObject(PyExc_NameError, name);
8657
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
8658
PyObject *tmp_type, *tmp_value, *tmp_tb;
8659
PyThreadState *tstate = PyThreadState_GET();
8661
tmp_type = tstate->curexc_type;
8662
tmp_value = tstate->curexc_value;
8663
tmp_tb = tstate->curexc_traceback;
8664
tstate->curexc_type = type;
8665
tstate->curexc_value = value;
8666
tstate->curexc_traceback = tb;
8667
Py_XDECREF(tmp_type);
8668
Py_XDECREF(tmp_value);
8672
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
8673
PyThreadState *tstate = PyThreadState_GET();
8674
*type = tstate->curexc_type;
8675
*value = tstate->curexc_value;
8676
*tb = tstate->curexc_traceback;
8678
tstate->curexc_type = 0;
8679
tstate->curexc_value = 0;
8680
tstate->curexc_traceback = 0;
8684
#if PY_MAJOR_VERSION < 3
8685
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
8689
/* First, check the traceback argument, replacing None with NULL. */
8690
if (tb == Py_None) {
8694
else if (tb != NULL && !PyTraceBack_Check(tb)) {
8695
PyErr_SetString(PyExc_TypeError,
8696
"raise: arg 3 must be a traceback or None");
8699
/* Next, replace a missing value with None */
8700
if (value == NULL) {
8704
#if PY_VERSION_HEX < 0x02050000
8705
if (!PyClass_Check(type))
8707
if (!PyType_Check(type))
8710
/* Raising an instance. The value should be a dummy. */
8711
if (value != Py_None) {
8712
PyErr_SetString(PyExc_TypeError,
8713
"instance exception may not have a separate value");
8716
/* Normalize to raise <class>, <instance> */
8719
#if PY_VERSION_HEX < 0x02050000
8720
if (PyInstance_Check(type)) {
8721
type = (PyObject*) ((PyInstanceObject*)type)->in_class;
8726
PyErr_SetString(PyExc_TypeError,
8727
"raise: exception must be an old-style class or instance");
8731
type = (PyObject*) Py_TYPE(type);
8733
if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
8734
PyErr_SetString(PyExc_TypeError,
8735
"raise: exception class must be a subclass of BaseException");
8741
__Pyx_ErrRestore(type, value, tb);
8750
#else /* Python 3+ */
8752
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
8753
if (tb == Py_None) {
8755
} else if (tb && !PyTraceBack_Check(tb)) {
8756
PyErr_SetString(PyExc_TypeError,
8757
"raise: arg 3 must be a traceback or None");
8760
if (value == Py_None)
8763
if (PyExceptionInstance_Check(type)) {
8765
PyErr_SetString(PyExc_TypeError,
8766
"instance exception may not have a separate value");
8770
type = (PyObject*) Py_TYPE(value);
8771
} else if (!PyExceptionClass_Check(type)) {
8772
PyErr_SetString(PyExc_TypeError,
8773
"raise: exception class must be a subclass of BaseException");
8777
PyErr_SetObject(type, value);
8780
PyThreadState *tstate = PyThreadState_GET();
8781
PyObject* tmp_tb = tstate->curexc_traceback;
8784
tstate->curexc_traceback = tb;
8794
static void __Pyx_RaiseArgtupleInvalid(
8795
const char* func_name,
8799
Py_ssize_t num_found)
8801
Py_ssize_t num_expected;
8802
const char *number, *more_or_less;
8804
if (num_found < num_min) {
8805
num_expected = num_min;
8806
more_or_less = "at least";
8808
num_expected = num_max;
8809
more_or_less = "at most";
8812
more_or_less = "exactly";
8814
number = (num_expected == 1) ? "" : "s";
8815
PyErr_Format(PyExc_TypeError,
8816
#if PY_VERSION_HEX < 0x02050000
8817
"%s() takes %s %d positional argument%s (%d given)",
8819
"%s() takes %s %zd positional argument%s (%zd given)",
8821
func_name, more_or_less, num_expected, number, num_found);
8824
static void __Pyx_RaiseDoubleKeywordsError(
8825
const char* func_name,
8828
PyErr_Format(PyExc_TypeError,
8829
#if PY_MAJOR_VERSION >= 3
8830
"%s() got multiple values for keyword argument '%U'", func_name, kw_name);
8832
"%s() got multiple values for keyword argument '%s'", func_name,
8833
PyString_AS_STRING(kw_name));
8837
static int __Pyx_ParseOptionalKeywords(
8839
PyObject **argnames[],
8842
Py_ssize_t num_pos_args,
8843
const char* function_name)
8845
PyObject *key = 0, *value = 0;
8848
PyObject*** first_kw_arg = argnames + num_pos_args;
8850
while (PyDict_Next(kwds, &pos, &key, &value)) {
8851
name = first_kw_arg;
8852
while (*name && (**name != key)) name++;
8854
values[name-argnames] = value;
8856
#if PY_MAJOR_VERSION < 3
8857
if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
8859
if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
8861
goto invalid_keyword_type;
8863
for (name = first_kw_arg; *name; name++) {
8864
#if PY_MAJOR_VERSION >= 3
8865
if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
8866
PyUnicode_Compare(**name, key) == 0) break;
8868
if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
8869
_PyString_Eq(**name, key)) break;
8873
values[name-argnames] = value;
8875
/* unexpected keyword found */
8876
for (name=argnames; name != first_kw_arg; name++) {
8877
if (**name == key) goto arg_passed_twice;
8878
#if PY_MAJOR_VERSION >= 3
8879
if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
8880
PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
8882
if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
8883
_PyString_Eq(**name, key)) goto arg_passed_twice;
8887
if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
8889
goto invalid_keyword;
8897
__Pyx_RaiseDoubleKeywordsError(function_name, **name);
8899
invalid_keyword_type:
8900
PyErr_Format(PyExc_TypeError,
8901
"%s() keywords must be strings", function_name);
8904
PyErr_Format(PyExc_TypeError,
8905
#if PY_MAJOR_VERSION < 3
8906
"%s() got an unexpected keyword argument '%s'",
8907
function_name, PyString_AsString(key));
8909
"%s() got an unexpected keyword argument '%U'",
8910
function_name, key);
8916
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
8917
if (unlikely(!type)) {
8918
PyErr_Format(PyExc_SystemError, "Missing type object");
8921
if (likely(PyObject_TypeCheck(obj, type)))
8923
PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
8924
Py_TYPE(obj)->tp_name, type->tp_name);
8928
static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
8931
q -= ((r != 0) & ((r ^ b) < 0));
8936
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
8937
PyObject *py_import = 0;
8938
PyObject *empty_list = 0;
8939
PyObject *module = 0;
8940
PyObject *global_dict = 0;
8941
PyObject *empty_dict = 0;
8943
py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
8949
empty_list = PyList_New(0);
8954
global_dict = PyModule_GetDict(__pyx_m);
8957
empty_dict = PyDict_New();
8960
module = PyObject_CallFunctionObjArgs(py_import,
8961
name, global_dict, empty_dict, list, NULL);
8963
Py_XDECREF(empty_list);
8964
Py_XDECREF(py_import);
8965
Py_XDECREF(empty_dict);
8969
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
8970
const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
8971
const int is_unsigned = neg_one > const_zero;
8972
if (sizeof(unsigned char) < sizeof(long)) {
8973
long val = __Pyx_PyInt_AsLong(x);
8974
if (unlikely(val != (long)(unsigned char)val)) {
8975
if (!unlikely(val == -1 && PyErr_Occurred())) {
8976
PyErr_SetString(PyExc_OverflowError,
8977
(is_unsigned && unlikely(val < 0)) ?
8978
"can't convert negative value to unsigned char" :
8979
"value too large to convert to unsigned char");
8981
return (unsigned char)-1;
8983
return (unsigned char)val;
8985
return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
8988
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
8989
const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
8990
const int is_unsigned = neg_one > const_zero;
8991
if (sizeof(unsigned short) < sizeof(long)) {
8992
long val = __Pyx_PyInt_AsLong(x);
8993
if (unlikely(val != (long)(unsigned short)val)) {
8994
if (!unlikely(val == -1 && PyErr_Occurred())) {
8995
PyErr_SetString(PyExc_OverflowError,
8996
(is_unsigned && unlikely(val < 0)) ?
8997
"can't convert negative value to unsigned short" :
8998
"value too large to convert to unsigned short");
9000
return (unsigned short)-1;
9002
return (unsigned short)val;
9004
return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
9007
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
9008
const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
9009
const int is_unsigned = neg_one > const_zero;
9010
if (sizeof(unsigned int) < sizeof(long)) {
9011
long val = __Pyx_PyInt_AsLong(x);
9012
if (unlikely(val != (long)(unsigned int)val)) {
9013
if (!unlikely(val == -1 && PyErr_Occurred())) {
9014
PyErr_SetString(PyExc_OverflowError,
9015
(is_unsigned && unlikely(val < 0)) ?
9016
"can't convert negative value to unsigned int" :
9017
"value too large to convert to unsigned int");
9019
return (unsigned int)-1;
9021
return (unsigned int)val;
9023
return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
9026
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
9027
const char neg_one = (char)-1, const_zero = 0;
9028
const int is_unsigned = neg_one > const_zero;
9029
if (sizeof(char) < sizeof(long)) {
9030
long val = __Pyx_PyInt_AsLong(x);
9031
if (unlikely(val != (long)(char)val)) {
9032
if (!unlikely(val == -1 && PyErr_Occurred())) {
9033
PyErr_SetString(PyExc_OverflowError,
9034
(is_unsigned && unlikely(val < 0)) ?
9035
"can't convert negative value to char" :
9036
"value too large to convert to char");
9042
return (char)__Pyx_PyInt_AsLong(x);
9045
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
9046
const short neg_one = (short)-1, const_zero = 0;
9047
const int is_unsigned = neg_one > const_zero;
9048
if (sizeof(short) < sizeof(long)) {
9049
long val = __Pyx_PyInt_AsLong(x);
9050
if (unlikely(val != (long)(short)val)) {
9051
if (!unlikely(val == -1 && PyErr_Occurred())) {
9052
PyErr_SetString(PyExc_OverflowError,
9053
(is_unsigned && unlikely(val < 0)) ?
9054
"can't convert negative value to short" :
9055
"value too large to convert to short");
9061
return (short)__Pyx_PyInt_AsLong(x);
9064
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
9065
const int neg_one = (int)-1, const_zero = 0;
9066
const int is_unsigned = neg_one > const_zero;
9067
if (sizeof(int) < sizeof(long)) {
9068
long val = __Pyx_PyInt_AsLong(x);
9069
if (unlikely(val != (long)(int)val)) {
9070
if (!unlikely(val == -1 && PyErr_Occurred())) {
9071
PyErr_SetString(PyExc_OverflowError,
9072
(is_unsigned && unlikely(val < 0)) ?
9073
"can't convert negative value to int" :
9074
"value too large to convert to int");
9080
return (int)__Pyx_PyInt_AsLong(x);
9083
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
9084
const signed char neg_one = (signed char)-1, const_zero = 0;
9085
const int is_unsigned = neg_one > const_zero;
9086
if (sizeof(signed char) < sizeof(long)) {
9087
long val = __Pyx_PyInt_AsLong(x);
9088
if (unlikely(val != (long)(signed char)val)) {
9089
if (!unlikely(val == -1 && PyErr_Occurred())) {
9090
PyErr_SetString(PyExc_OverflowError,
9091
(is_unsigned && unlikely(val < 0)) ?
9092
"can't convert negative value to signed char" :
9093
"value too large to convert to signed char");
9095
return (signed char)-1;
9097
return (signed char)val;
9099
return (signed char)__Pyx_PyInt_AsSignedLong(x);
9102
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
9103
const signed short neg_one = (signed short)-1, const_zero = 0;
9104
const int is_unsigned = neg_one > const_zero;
9105
if (sizeof(signed short) < sizeof(long)) {
9106
long val = __Pyx_PyInt_AsLong(x);
9107
if (unlikely(val != (long)(signed short)val)) {
9108
if (!unlikely(val == -1 && PyErr_Occurred())) {
9109
PyErr_SetString(PyExc_OverflowError,
9110
(is_unsigned && unlikely(val < 0)) ?
9111
"can't convert negative value to signed short" :
9112
"value too large to convert to signed short");
9114
return (signed short)-1;
9116
return (signed short)val;
9118
return (signed short)__Pyx_PyInt_AsSignedLong(x);
9121
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
9122
const signed int neg_one = (signed int)-1, const_zero = 0;
9123
const int is_unsigned = neg_one > const_zero;
9124
if (sizeof(signed int) < sizeof(long)) {
9125
long val = __Pyx_PyInt_AsLong(x);
9126
if (unlikely(val != (long)(signed int)val)) {
9127
if (!unlikely(val == -1 && PyErr_Occurred())) {
9128
PyErr_SetString(PyExc_OverflowError,
9129
(is_unsigned && unlikely(val < 0)) ?
9130
"can't convert negative value to signed int" :
9131
"value too large to convert to signed int");
9133
return (signed int)-1;
9135
return (signed int)val;
9137
return (signed int)__Pyx_PyInt_AsSignedLong(x);
9140
static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
9141
const int neg_one = (int)-1, const_zero = 0;
9142
const int is_unsigned = neg_one > const_zero;
9143
if (sizeof(int) < sizeof(long)) {
9144
long val = __Pyx_PyInt_AsLong(x);
9145
if (unlikely(val != (long)(int)val)) {
9146
if (!unlikely(val == -1 && PyErr_Occurred())) {
9147
PyErr_SetString(PyExc_OverflowError,
9148
(is_unsigned && unlikely(val < 0)) ?
9149
"can't convert negative value to int" :
9150
"value too large to convert to int");
9156
return (int)__Pyx_PyInt_AsLong(x);
9159
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
9160
const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
9161
const int is_unsigned = neg_one > const_zero;
9162
#if PY_VERSION_HEX < 0x03000000
9163
if (likely(PyInt_Check(x))) {
9164
long val = PyInt_AS_LONG(x);
9165
if (is_unsigned && unlikely(val < 0)) {
9166
PyErr_SetString(PyExc_OverflowError,
9167
"can't convert negative value to unsigned long");
9168
return (unsigned long)-1;
9170
return (unsigned long)val;
9173
if (likely(PyLong_Check(x))) {
9175
if (unlikely(Py_SIZE(x) < 0)) {
9176
PyErr_SetString(PyExc_OverflowError,
9177
"can't convert negative value to unsigned long");
9178
return (unsigned long)-1;
9180
return PyLong_AsUnsignedLong(x);
9182
return PyLong_AsLong(x);
9186
PyObject *tmp = __Pyx_PyNumber_Int(x);
9187
if (!tmp) return (unsigned long)-1;
9188
val = __Pyx_PyInt_AsUnsignedLong(tmp);
9194
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
9195
const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
9196
const int is_unsigned = neg_one > const_zero;
9197
#if PY_VERSION_HEX < 0x03000000
9198
if (likely(PyInt_Check(x))) {
9199
long val = PyInt_AS_LONG(x);
9200
if (is_unsigned && unlikely(val < 0)) {
9201
PyErr_SetString(PyExc_OverflowError,
9202
"can't convert negative value to unsigned PY_LONG_LONG");
9203
return (unsigned PY_LONG_LONG)-1;
9205
return (unsigned PY_LONG_LONG)val;
9208
if (likely(PyLong_Check(x))) {
9210
if (unlikely(Py_SIZE(x) < 0)) {
9211
PyErr_SetString(PyExc_OverflowError,
9212
"can't convert negative value to unsigned PY_LONG_LONG");
9213
return (unsigned PY_LONG_LONG)-1;
9215
return PyLong_AsUnsignedLongLong(x);
9217
return PyLong_AsLongLong(x);
9220
unsigned PY_LONG_LONG val;
9221
PyObject *tmp = __Pyx_PyNumber_Int(x);
9222
if (!tmp) return (unsigned PY_LONG_LONG)-1;
9223
val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
9229
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
9230
const long neg_one = (long)-1, const_zero = 0;
9231
const int is_unsigned = neg_one > const_zero;
9232
#if PY_VERSION_HEX < 0x03000000
9233
if (likely(PyInt_Check(x))) {
9234
long val = PyInt_AS_LONG(x);
9235
if (is_unsigned && unlikely(val < 0)) {
9236
PyErr_SetString(PyExc_OverflowError,
9237
"can't convert negative value to long");
9243
if (likely(PyLong_Check(x))) {
9245
if (unlikely(Py_SIZE(x) < 0)) {
9246
PyErr_SetString(PyExc_OverflowError,
9247
"can't convert negative value to long");
9250
return PyLong_AsUnsignedLong(x);
9252
return PyLong_AsLong(x);
9256
PyObject *tmp = __Pyx_PyNumber_Int(x);
9257
if (!tmp) return (long)-1;
9258
val = __Pyx_PyInt_AsLong(tmp);
9264
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
9265
const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
9266
const int is_unsigned = neg_one > const_zero;
9267
#if PY_VERSION_HEX < 0x03000000
9268
if (likely(PyInt_Check(x))) {
9269
long val = PyInt_AS_LONG(x);
9270
if (is_unsigned && unlikely(val < 0)) {
9271
PyErr_SetString(PyExc_OverflowError,
9272
"can't convert negative value to PY_LONG_LONG");
9273
return (PY_LONG_LONG)-1;
9275
return (PY_LONG_LONG)val;
9278
if (likely(PyLong_Check(x))) {
9280
if (unlikely(Py_SIZE(x) < 0)) {
9281
PyErr_SetString(PyExc_OverflowError,
9282
"can't convert negative value to PY_LONG_LONG");
9283
return (PY_LONG_LONG)-1;
9285
return PyLong_AsUnsignedLongLong(x);
9287
return PyLong_AsLongLong(x);
9291
PyObject *tmp = __Pyx_PyNumber_Int(x);
9292
if (!tmp) return (PY_LONG_LONG)-1;
9293
val = __Pyx_PyInt_AsLongLong(tmp);
9299
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
9300
const signed long neg_one = (signed long)-1, const_zero = 0;
9301
const int is_unsigned = neg_one > const_zero;
9302
#if PY_VERSION_HEX < 0x03000000
9303
if (likely(PyInt_Check(x))) {
9304
long val = PyInt_AS_LONG(x);
9305
if (is_unsigned && unlikely(val < 0)) {
9306
PyErr_SetString(PyExc_OverflowError,
9307
"can't convert negative value to signed long");
9308
return (signed long)-1;
9310
return (signed long)val;
9313
if (likely(PyLong_Check(x))) {
9315
if (unlikely(Py_SIZE(x) < 0)) {
9316
PyErr_SetString(PyExc_OverflowError,
9317
"can't convert negative value to signed long");
9318
return (signed long)-1;
9320
return PyLong_AsUnsignedLong(x);
9322
return PyLong_AsLong(x);
9326
PyObject *tmp = __Pyx_PyNumber_Int(x);
9327
if (!tmp) return (signed long)-1;
9328
val = __Pyx_PyInt_AsSignedLong(tmp);
9334
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
9335
const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
9336
const int is_unsigned = neg_one > const_zero;
9337
#if PY_VERSION_HEX < 0x03000000
9338
if (likely(PyInt_Check(x))) {
9339
long val = PyInt_AS_LONG(x);
9340
if (is_unsigned && unlikely(val < 0)) {
9341
PyErr_SetString(PyExc_OverflowError,
9342
"can't convert negative value to signed PY_LONG_LONG");
9343
return (signed PY_LONG_LONG)-1;
9345
return (signed PY_LONG_LONG)val;
9348
if (likely(PyLong_Check(x))) {
9350
if (unlikely(Py_SIZE(x) < 0)) {
9351
PyErr_SetString(PyExc_OverflowError,
9352
"can't convert negative value to signed PY_LONG_LONG");
9353
return (signed PY_LONG_LONG)-1;
9355
return PyLong_AsUnsignedLongLong(x);
9357
return PyLong_AsLongLong(x);
9360
signed PY_LONG_LONG val;
9361
PyObject *tmp = __Pyx_PyNumber_Int(x);
9362
if (!tmp) return (signed PY_LONG_LONG)-1;
9363
val = __Pyx_PyInt_AsSignedLongLong(tmp);
9369
static void __Pyx_WriteUnraisable(const char *name) {
9370
PyObject *old_exc, *old_val, *old_tb;
9372
__Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
9373
#if PY_MAJOR_VERSION < 3
9374
ctx = PyString_FromString(name);
9376
ctx = PyUnicode_FromString(name);
9378
__Pyx_ErrRestore(old_exc, old_val, old_tb);
9380
PyErr_WriteUnraisable(Py_None);
9382
PyErr_WriteUnraisable(ctx);
9387
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
9388
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
9389
PyObject *ob = PyCapsule_New(vtable, 0, 0);
9391
PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
9395
if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
9404
#ifndef __PYX_HAVE_RT_ImportType
9405
#define __PYX_HAVE_RT_ImportType
9406
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
9407
long size, int strict)
9409
PyObject *py_module = 0;
9410
PyObject *result = 0;
9411
PyObject *py_name = 0;
9414
py_module = __Pyx_ImportModule(module_name);
9417
#if PY_MAJOR_VERSION < 3
9418
py_name = PyString_FromString(class_name);
9420
py_name = PyUnicode_FromString(class_name);
9424
result = PyObject_GetAttr(py_module, py_name);
9427
Py_DECREF(py_module);
9431
if (!PyType_Check(result)) {
9432
PyErr_Format(PyExc_TypeError,
9433
"%s.%s is not a type object",
9434
module_name, class_name);
9437
if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
9438
PyOS_snprintf(warning, sizeof(warning),
9439
"%s.%s size changed, may indicate binary incompatibility",
9440
module_name, class_name);
9441
#if PY_VERSION_HEX < 0x02050000
9442
PyErr_Warn(NULL, warning);
9444
PyErr_WarnEx(NULL, warning, 0);
9447
else if (((PyTypeObject *)result)->tp_basicsize != size) {
9448
PyErr_Format(PyExc_ValueError,
9449
"%s.%s has the wrong size, try recompiling",
9450
module_name, class_name);
9453
return (PyTypeObject *)result;
9455
Py_XDECREF(py_module);
9461
#ifndef __PYX_HAVE_RT_ImportModule
9462
#define __PYX_HAVE_RT_ImportModule
9463
static PyObject *__Pyx_ImportModule(const char *name) {
9464
PyObject *py_name = 0;
9465
PyObject *py_module = 0;
9467
#if PY_MAJOR_VERSION < 3
9468
py_name = PyString_FromString(name);
9470
py_name = PyUnicode_FromString(name);
9474
py_module = PyImport_Import(py_name);
9478
Py_XDECREF(py_name);
9483
#include "compile.h"
9484
#include "frameobject.h"
9485
#include "traceback.h"
9487
static void __Pyx_AddTraceback(const char *funcname) {
9488
PyObject *py_srcfile = 0;
9489
PyObject *py_funcname = 0;
9490
PyObject *py_globals = 0;
9491
PyCodeObject *py_code = 0;
9492
PyFrameObject *py_frame = 0;
9494
#if PY_MAJOR_VERSION < 3
9495
py_srcfile = PyString_FromString(__pyx_filename);
9497
py_srcfile = PyUnicode_FromString(__pyx_filename);
9499
if (!py_srcfile) goto bad;
9500
if (__pyx_clineno) {
9501
#if PY_MAJOR_VERSION < 3
9502
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
9504
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
9508
#if PY_MAJOR_VERSION < 3
9509
py_funcname = PyString_FromString(funcname);
9511
py_funcname = PyUnicode_FromString(funcname);
9514
if (!py_funcname) goto bad;
9515
py_globals = PyModule_GetDict(__pyx_m);
9516
if (!py_globals) goto bad;
9517
py_code = PyCode_New(
9518
0, /*int argcount,*/
9519
#if PY_MAJOR_VERSION >= 3
9520
0, /*int kwonlyargcount,*/
9523
0, /*int stacksize,*/
9525
__pyx_empty_bytes, /*PyObject *code,*/
9526
__pyx_empty_tuple, /*PyObject *consts,*/
9527
__pyx_empty_tuple, /*PyObject *names,*/
9528
__pyx_empty_tuple, /*PyObject *varnames,*/
9529
__pyx_empty_tuple, /*PyObject *freevars,*/
9530
__pyx_empty_tuple, /*PyObject *cellvars,*/
9531
py_srcfile, /*PyObject *filename,*/
9532
py_funcname, /*PyObject *name,*/
9533
__pyx_lineno, /*int firstlineno,*/
9534
__pyx_empty_bytes /*PyObject *lnotab*/
9536
if (!py_code) goto bad;
9537
py_frame = PyFrame_New(
9538
PyThreadState_GET(), /*PyThreadState *tstate,*/
9539
py_code, /*PyCodeObject *code,*/
9540
py_globals, /*PyObject *globals,*/
9541
0 /*PyObject *locals*/
9543
if (!py_frame) goto bad;
9544
py_frame->f_lineno = __pyx_lineno;
9545
PyTraceBack_Here(py_frame);
9547
Py_XDECREF(py_srcfile);
9548
Py_XDECREF(py_funcname);
9549
Py_XDECREF(py_code);
9550
Py_XDECREF(py_frame);
9553
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
9555
#if PY_MAJOR_VERSION < 3
9556
if (t->is_unicode) {
9557
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
9558
} else if (t->intern) {
9559
*t->p = PyString_InternFromString(t->s);
9561
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
9563
#else /* Python 3+ has unicode identifiers */
9564
if (t->is_unicode | t->is_str) {
9566
*t->p = PyUnicode_InternFromString(t->s);
9567
} else if (t->encoding) {
9568
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
9570
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
9573
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
9583
/* Type Conversion Functions */
9585
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
9586
int is_true = x == Py_True;
9587
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
9588
else return PyObject_IsTrue(x);
9591
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
9593
const char *name = NULL;
9594
PyObject *res = NULL;
9595
#if PY_VERSION_HEX < 0x03000000
9596
if (PyInt_Check(x) || PyLong_Check(x))
9598
if (PyLong_Check(x))
9600
return Py_INCREF(x), x;
9601
m = Py_TYPE(x)->tp_as_number;
9602
#if PY_VERSION_HEX < 0x03000000
9603
if (m && m->nb_int) {
9605
res = PyNumber_Int(x);
9607
else if (m && m->nb_long) {
9609
res = PyNumber_Long(x);
9612
if (m && m->nb_int) {
9614
res = PyNumber_Long(x);
9618
#if PY_VERSION_HEX < 0x03000000
9619
if (!PyInt_Check(res) && !PyLong_Check(res)) {
9621
if (!PyLong_Check(res)) {
9623
PyErr_Format(PyExc_TypeError,
9624
"__%s__ returned non-%s (type %.200s)",
9625
name, name, Py_TYPE(res)->tp_name);
9630
else if (!PyErr_Occurred()) {
9631
PyErr_SetString(PyExc_TypeError,
9632
"an integer is required");
9637
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
9639
PyObject* x = PyNumber_Index(b);
9641
ival = PyInt_AsSsize_t(x);
9646
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
9647
#if PY_VERSION_HEX < 0x02050000
9648
if (ival <= LONG_MAX)
9649
return PyInt_FromLong((long)ival);
9651
unsigned char *bytes = (unsigned char *) &ival;
9652
int one = 1; int little = (int)*(unsigned char*)&one;
9653
return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
9656
return PyInt_FromSize_t(ival);
9660
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
9661
unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
9662
if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
9664
} else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
9665
PyErr_SetString(PyExc_OverflowError,
9666
"value too large to convert to size_t");
9673
#endif /* Py_PYTHON_H */