1 /* Generated by Cython 0.29.21 */
2
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #ifndef Py_PYTHON_H
6 #error Python headers needed to compile C extensions, please install development version of Python.
7 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
8 #error Cython requires Python 2.6+ or Python 3.3+.
9 #else
10 #define CYTHON_ABI "0_29_21"
11 #define CYTHON_HEX_VERSION 0x001D15F0
12 #define CYTHON_FUTURE_DIVISION 1
13 #include <stddef.h>
14 #ifndef offsetof
15 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
16 #endif
17 #if !defined(WIN32) && !defined(MS_WINDOWS)
18 #ifndef __stdcall
19 #define __stdcall
20 #endif
21 #ifndef __cdecl
22 #define __cdecl
23 #endif
24 #ifndef __fastcall
25 #define __fastcall
26 #endif
27 #endif
28 #ifndef DL_IMPORT
29 #define DL_IMPORT(t) t
30 #endif
31 #ifndef DL_EXPORT
32 #define DL_EXPORT(t) t
33 #endif
34 #define __PYX_COMMA ,
35 #ifndef HAVE_LONG_LONG
36 #if PY_VERSION_HEX >= 0x02070000
37 #define HAVE_LONG_LONG
38 #endif
39 #endif
40 #ifndef PY_LONG_LONG
41 #define PY_LONG_LONG LONG_LONG
42 #endif
43 #ifndef Py_HUGE_VAL
44 #define Py_HUGE_VAL HUGE_VAL
45 #endif
46 #ifdef PYPY_VERSION
47 #define CYTHON_COMPILING_IN_PYPY 1
48 #define CYTHON_COMPILING_IN_PYSTON 0
49 #define CYTHON_COMPILING_IN_CPYTHON 0
50 #undef CYTHON_USE_TYPE_SLOTS
51 #define CYTHON_USE_TYPE_SLOTS 0
52 #undef CYTHON_USE_PYTYPE_LOOKUP
53 #define CYTHON_USE_PYTYPE_LOOKUP 0
54 #if PY_VERSION_HEX < 0x03050000
55 #undef CYTHON_USE_ASYNC_SLOTS
56 #define CYTHON_USE_ASYNC_SLOTS 0
57 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
58 #define CYTHON_USE_ASYNC_SLOTS 1
59 #endif
60 #undef CYTHON_USE_PYLIST_INTERNALS
61 #define CYTHON_USE_PYLIST_INTERNALS 0
62 #undef CYTHON_USE_UNICODE_INTERNALS
63 #define CYTHON_USE_UNICODE_INTERNALS 0
64 #undef CYTHON_USE_UNICODE_WRITER
65 #define CYTHON_USE_UNICODE_WRITER 0
66 #undef CYTHON_USE_PYLONG_INTERNALS
67 #define CYTHON_USE_PYLONG_INTERNALS 0
68 #undef CYTHON_AVOID_BORROWED_REFS
69 #define CYTHON_AVOID_BORROWED_REFS 1
70 #undef CYTHON_ASSUME_SAFE_MACROS
71 #define CYTHON_ASSUME_SAFE_MACROS 0
72 #undef CYTHON_UNPACK_METHODS
73 #define CYTHON_UNPACK_METHODS 0
74 #undef CYTHON_FAST_THREAD_STATE
75 #define CYTHON_FAST_THREAD_STATE 0
76 #undef CYTHON_FAST_PYCALL
77 #define CYTHON_FAST_PYCALL 0
78 #undef CYTHON_PEP489_MULTI_PHASE_INIT
79 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
80 #undef CYTHON_USE_TP_FINALIZE
81 #define CYTHON_USE_TP_FINALIZE 0
82 #undef CYTHON_USE_DICT_VERSIONS
83 #define CYTHON_USE_DICT_VERSIONS 0
84 #undef CYTHON_USE_EXC_INFO_STACK
85 #define CYTHON_USE_EXC_INFO_STACK 0
86 #elif defined(PYSTON_VERSION)
87 #define CYTHON_COMPILING_IN_PYPY 0
88 #define CYTHON_COMPILING_IN_PYSTON 1
89 #define CYTHON_COMPILING_IN_CPYTHON 0
90 #ifndef CYTHON_USE_TYPE_SLOTS
91 #define CYTHON_USE_TYPE_SLOTS 1
92 #endif
93 #undef CYTHON_USE_PYTYPE_LOOKUP
94 #define CYTHON_USE_PYTYPE_LOOKUP 0
95 #undef CYTHON_USE_ASYNC_SLOTS
96 #define CYTHON_USE_ASYNC_SLOTS 0
97 #undef CYTHON_USE_PYLIST_INTERNALS
98 #define CYTHON_USE_PYLIST_INTERNALS 0
99 #ifndef CYTHON_USE_UNICODE_INTERNALS
100 #define CYTHON_USE_UNICODE_INTERNALS 1
101 #endif
102 #undef CYTHON_USE_UNICODE_WRITER
103 #define CYTHON_USE_UNICODE_WRITER 0
104 #undef CYTHON_USE_PYLONG_INTERNALS
105 #define CYTHON_USE_PYLONG_INTERNALS 0
106 #ifndef CYTHON_AVOID_BORROWED_REFS
107 #define CYTHON_AVOID_BORROWED_REFS 0
108 #endif
109 #ifndef CYTHON_ASSUME_SAFE_MACROS
110 #define CYTHON_ASSUME_SAFE_MACROS 1
111 #endif
112 #ifndef CYTHON_UNPACK_METHODS
113 #define CYTHON_UNPACK_METHODS 1
114 #endif
115 #undef CYTHON_FAST_THREAD_STATE
116 #define CYTHON_FAST_THREAD_STATE 0
117 #undef CYTHON_FAST_PYCALL
118 #define CYTHON_FAST_PYCALL 0
119 #undef CYTHON_PEP489_MULTI_PHASE_INIT
120 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
121 #undef CYTHON_USE_TP_FINALIZE
122 #define CYTHON_USE_TP_FINALIZE 0
123 #undef CYTHON_USE_DICT_VERSIONS
124 #define CYTHON_USE_DICT_VERSIONS 0
125 #undef CYTHON_USE_EXC_INFO_STACK
126 #define CYTHON_USE_EXC_INFO_STACK 0
127 #else
128 #define CYTHON_COMPILING_IN_PYPY 0
129 #define CYTHON_COMPILING_IN_PYSTON 0
130 #define CYTHON_COMPILING_IN_CPYTHON 1
131 #ifndef CYTHON_USE_TYPE_SLOTS
132 #define CYTHON_USE_TYPE_SLOTS 1
133 #endif
134 #if PY_VERSION_HEX < 0x02070000
135 #undef CYTHON_USE_PYTYPE_LOOKUP
136 #define CYTHON_USE_PYTYPE_LOOKUP 0
137 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
138 #define CYTHON_USE_PYTYPE_LOOKUP 1
139 #endif
140 #if PY_MAJOR_VERSION < 3
141 #undef CYTHON_USE_ASYNC_SLOTS
142 #define CYTHON_USE_ASYNC_SLOTS 0
143 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
144 #define CYTHON_USE_ASYNC_SLOTS 1
145 #endif
146 #if PY_VERSION_HEX < 0x02070000
147 #undef CYTHON_USE_PYLONG_INTERNALS
148 #define CYTHON_USE_PYLONG_INTERNALS 0
149 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
150 #define CYTHON_USE_PYLONG_INTERNALS 1
151 #endif
152 #ifndef CYTHON_USE_PYLIST_INTERNALS
153 #define CYTHON_USE_PYLIST_INTERNALS 1
154 #endif
155 #ifndef CYTHON_USE_UNICODE_INTERNALS
156 #define CYTHON_USE_UNICODE_INTERNALS 1
157 #endif
158 #if PY_VERSION_HEX < 0x030300F0
159 #undef CYTHON_USE_UNICODE_WRITER
160 #define CYTHON_USE_UNICODE_WRITER 0
161 #elif !defined(CYTHON_USE_UNICODE_WRITER)
162 #define CYTHON_USE_UNICODE_WRITER 1
163 #endif
164 #ifndef CYTHON_AVOID_BORROWED_REFS
165 #define CYTHON_AVOID_BORROWED_REFS 0
166 #endif
167 #ifndef CYTHON_ASSUME_SAFE_MACROS
168 #define CYTHON_ASSUME_SAFE_MACROS 1
169 #endif
170 #ifndef CYTHON_UNPACK_METHODS
171 #define CYTHON_UNPACK_METHODS 1
172 #endif
173 #ifndef CYTHON_FAST_THREAD_STATE
174 #define CYTHON_FAST_THREAD_STATE 1
175 #endif
176 #ifndef CYTHON_FAST_PYCALL
177 #define CYTHON_FAST_PYCALL 1
178 #endif
179 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
180 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
181 #endif
182 #ifndef CYTHON_USE_TP_FINALIZE
183 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
184 #endif
185 #ifndef CYTHON_USE_DICT_VERSIONS
186 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
187 #endif
188 #ifndef CYTHON_USE_EXC_INFO_STACK
189 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
190 #endif
191 #endif
192 #if !defined(CYTHON_FAST_PYCCALL)
193 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
194 #endif
195 #if CYTHON_USE_PYLONG_INTERNALS
196 #include "longintrepr.h"
197 #undef SHIFT
198 #undef BASE
199 #undef MASK
200 #ifdef SIZEOF_VOID_P
201 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
202 #endif
203 #endif
204 #ifndef __has_attribute
205 #define __has_attribute(x) 0
206 #endif
207 #ifndef __has_cpp_attribute
208 #define __has_cpp_attribute(x) 0
209 #endif
210 #ifndef CYTHON_RESTRICT
211 #if defined(__GNUC__)
212 #define CYTHON_RESTRICT __restrict__
213 #elif defined(_MSC_VER) && _MSC_VER >= 1400
214 #define CYTHON_RESTRICT __restrict
215 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
216 #define CYTHON_RESTRICT restrict
217 #else
218 #define CYTHON_RESTRICT
219 #endif
220 #endif
221 #ifndef CYTHON_UNUSED
222 # if defined(__GNUC__)
223 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
224 # define CYTHON_UNUSED __attribute__ ((__unused__))
225 # else
226 # define CYTHON_UNUSED
227 # endif
228 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
229 # define CYTHON_UNUSED __attribute__ ((__unused__))
230 # else
231 # define CYTHON_UNUSED
232 # endif
233 #endif
234 #ifndef CYTHON_MAYBE_UNUSED_VAR
235 # if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)236 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
237 # else
238 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
239 # endif
240 #endif
241 #ifndef CYTHON_NCP_UNUSED
242 # if CYTHON_COMPILING_IN_CPYTHON
243 # define CYTHON_NCP_UNUSED
244 # else
245 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
246 # endif
247 #endif
248 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
249 #ifdef _MSC_VER
250 #ifndef _MSC_STDINT_H_
251 #if _MSC_VER < 1300
252 typedef unsigned char uint8_t;
253 typedef unsigned int uint32_t;
254 #else
255 typedef unsigned __int8 uint8_t;
256 typedef unsigned __int32 uint32_t;
257 #endif
258 #endif
259 #else
260 #include <stdint.h>
261 #endif
262 #ifndef CYTHON_FALLTHROUGH
263 #if defined(__cplusplus) && __cplusplus >= 201103L
264 #if __has_cpp_attribute(fallthrough)
265 #define CYTHON_FALLTHROUGH [[fallthrough]]
266 #elif __has_cpp_attribute(clang::fallthrough)
267 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
268 #elif __has_cpp_attribute(gnu::fallthrough)
269 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
270 #endif
271 #endif
272 #ifndef CYTHON_FALLTHROUGH
273 #if __has_attribute(fallthrough)
274 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
275 #else
276 #define CYTHON_FALLTHROUGH
277 #endif
278 #endif
279 #if defined(__clang__ ) && defined(__apple_build_version__)
280 #if __apple_build_version__ < 7000000
281 #undef CYTHON_FALLTHROUGH
282 #define CYTHON_FALLTHROUGH
283 #endif
284 #endif
285 #endif
286
287 #ifndef CYTHON_INLINE
288 #if defined(__clang__)
289 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
290 #elif defined(__GNUC__)
291 #define CYTHON_INLINE __inline__
292 #elif defined(_MSC_VER)
293 #define CYTHON_INLINE __inline
294 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
295 #define CYTHON_INLINE inline
296 #else
297 #define CYTHON_INLINE
298 #endif
299 #endif
300
301 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
302 #define Py_OptimizeFlag 0
303 #endif
304 #define __PYX_BUILD_PY_SSIZE_T "n"
305 #define CYTHON_FORMAT_SSIZE_T "z"
306 #if PY_MAJOR_VERSION < 3
307 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
308 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
309 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
310 #define __Pyx_DefaultClassType PyClass_Type
311 #else
312 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
313 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
314 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
315 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
316 #else
317 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
318 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
319 #endif
320 #define __Pyx_DefaultClassType PyType_Type
321 #endif
322 #ifndef Py_TPFLAGS_CHECKTYPES
323 #define Py_TPFLAGS_CHECKTYPES 0
324 #endif
325 #ifndef Py_TPFLAGS_HAVE_INDEX
326 #define Py_TPFLAGS_HAVE_INDEX 0
327 #endif
328 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
329 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
330 #endif
331 #ifndef Py_TPFLAGS_HAVE_FINALIZE
332 #define Py_TPFLAGS_HAVE_FINALIZE 0
333 #endif
334 #ifndef METH_STACKLESS
335 #define METH_STACKLESS 0
336 #endif
337 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
338 #ifndef METH_FASTCALL
339 #define METH_FASTCALL 0x80
340 #endif
341 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
342 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
343 Py_ssize_t nargs, PyObject *kwnames);
344 #else
345 #define __Pyx_PyCFunctionFast _PyCFunctionFast
346 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
347 #endif
348 #if CYTHON_FAST_PYCCALL
349 #define __Pyx_PyFastCFunction_Check(func)\
350 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
351 #else
352 #define __Pyx_PyFastCFunction_Check(func) 0
353 #endif
354 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
355 #define PyObject_Malloc(s) PyMem_Malloc(s)
356 #define PyObject_Free(p) PyMem_Free(p)
357 #define PyObject_Realloc(p) PyMem_Realloc(p)
358 #endif
359 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
360 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
361 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
362 #define PyMem_RawFree(p) PyMem_Free(p)
363 #endif
364 #if CYTHON_COMPILING_IN_PYSTON
365 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
366 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
367 #else
368 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
369 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
370 #endif
371 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
372 #define __Pyx_PyThreadState_Current PyThreadState_GET()
373 #elif PY_VERSION_HEX >= 0x03060000
374 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
375 #elif PY_VERSION_HEX >= 0x03000000
376 #define __Pyx_PyThreadState_Current PyThreadState_GET()
377 #else
378 #define __Pyx_PyThreadState_Current _PyThreadState_Current
379 #endif
380 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
381 #include "pythread.h"
382 #define Py_tss_NEEDS_INIT 0
383 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)384 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
385 *key = PyThread_create_key();
386 return 0;
387 }
PyThread_tss_alloc(void)388 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
389 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
390 *key = Py_tss_NEEDS_INIT;
391 return key;
392 }
PyThread_tss_free(Py_tss_t * key)393 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
394 PyObject_Free(key);
395 }
PyThread_tss_is_created(Py_tss_t * key)396 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
397 return *key != Py_tss_NEEDS_INIT;
398 }
PyThread_tss_delete(Py_tss_t * key)399 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
400 PyThread_delete_key(*key);
401 *key = Py_tss_NEEDS_INIT;
402 }
PyThread_tss_set(Py_tss_t * key,void * value)403 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
404 return PyThread_set_key_value(*key, value);
405 }
PyThread_tss_get(Py_tss_t * key)406 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
407 return PyThread_get_key_value(*key);
408 }
409 #endif
410 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
411 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
412 #else
413 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
414 #endif
415 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
416 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
417 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
418 #else
419 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
420 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
421 #endif
422 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
423 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
424 #else
425 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
426 #endif
427 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
428 #define CYTHON_PEP393_ENABLED 1
429 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
430 0 : _PyUnicode_Ready((PyObject *)(op)))
431 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
432 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
433 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
434 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
435 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
436 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
437 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
438 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
439 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
440 #else
441 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
442 #endif
443 #else
444 #define CYTHON_PEP393_ENABLED 0
445 #define PyUnicode_1BYTE_KIND 1
446 #define PyUnicode_2BYTE_KIND 2
447 #define PyUnicode_4BYTE_KIND 4
448 #define __Pyx_PyUnicode_READY(op) (0)
449 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
450 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
451 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
452 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
453 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
454 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
455 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
456 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
457 #endif
458 #if CYTHON_COMPILING_IN_PYPY
459 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
460 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
461 #else
462 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
463 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
464 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
465 #endif
466 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
467 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
468 #endif
469 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
470 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
471 #endif
472 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
473 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
474 #endif
475 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
476 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
477 #if PY_MAJOR_VERSION >= 3
478 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
479 #else
480 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
481 #endif
482 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
483 #define PyObject_ASCII(o) PyObject_Repr(o)
484 #endif
485 #if PY_MAJOR_VERSION >= 3
486 #define PyBaseString_Type PyUnicode_Type
487 #define PyStringObject PyUnicodeObject
488 #define PyString_Type PyUnicode_Type
489 #define PyString_Check PyUnicode_Check
490 #define PyString_CheckExact PyUnicode_CheckExact
491 #ifndef PyObject_Unicode
492 #define PyObject_Unicode PyObject_Str
493 #endif
494 #endif
495 #if PY_MAJOR_VERSION >= 3
496 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
497 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
498 #else
499 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
500 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
501 #endif
502 #ifndef PySet_CheckExact
503 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
504 #endif
505 #if PY_VERSION_HEX >= 0x030900A4
506 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
507 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
508 #else
509 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
510 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
511 #endif
512 #if CYTHON_ASSUME_SAFE_MACROS
513 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
514 #else
515 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
516 #endif
517 #if PY_MAJOR_VERSION >= 3
518 #define PyIntObject PyLongObject
519 #define PyInt_Type PyLong_Type
520 #define PyInt_Check(op) PyLong_Check(op)
521 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
522 #define PyInt_FromString PyLong_FromString
523 #define PyInt_FromUnicode PyLong_FromUnicode
524 #define PyInt_FromLong PyLong_FromLong
525 #define PyInt_FromSize_t PyLong_FromSize_t
526 #define PyInt_FromSsize_t PyLong_FromSsize_t
527 #define PyInt_AsLong PyLong_AsLong
528 #define PyInt_AS_LONG PyLong_AS_LONG
529 #define PyInt_AsSsize_t PyLong_AsSsize_t
530 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
531 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
532 #define PyNumber_Int PyNumber_Long
533 #endif
534 #if PY_MAJOR_VERSION >= 3
535 #define PyBoolObject PyLongObject
536 #endif
537 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
538 #ifndef PyUnicode_InternFromString
539 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
540 #endif
541 #endif
542 #if PY_VERSION_HEX < 0x030200A4
543 typedef long Py_hash_t;
544 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
545 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
546 #else
547 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
548 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
549 #endif
550 #if PY_MAJOR_VERSION >= 3
551 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
552 #else
553 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
554 #endif
555 #if CYTHON_USE_ASYNC_SLOTS
556 #if PY_VERSION_HEX >= 0x030500B1
557 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
558 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
559 #else
560 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
561 #endif
562 #else
563 #define __Pyx_PyType_AsAsync(obj) NULL
564 #endif
565 #ifndef __Pyx_PyAsyncMethodsStruct
566 typedef struct {
567 unaryfunc am_await;
568 unaryfunc am_aiter;
569 unaryfunc am_anext;
570 } __Pyx_PyAsyncMethodsStruct;
571 #endif
572
573 #if defined(WIN32) || defined(MS_WINDOWS)
574 #define _USE_MATH_DEFINES
575 #endif
576 #include <math.h>
577 #ifdef NAN
578 #define __PYX_NAN() ((float) NAN)
579 #else
__PYX_NAN()580 static CYTHON_INLINE float __PYX_NAN() {
581 float value;
582 memset(&value, 0xFF, sizeof(value));
583 return value;
584 }
585 #endif
586 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
587 #define __Pyx_truncl trunc
588 #else
589 #define __Pyx_truncl truncl
590 #endif
591
592 #define __PYX_MARK_ERR_POS(f_index, lineno) \
593 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
594 #define __PYX_ERR(f_index, lineno, Ln_error) \
595 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
596
597 #ifndef __PYX_EXTERN_C
598 #ifdef __cplusplus
599 #define __PYX_EXTERN_C extern "C"
600 #else
601 #define __PYX_EXTERN_C extern
602 #endif
603 #endif
604
605 #define __PYX_HAVE__breezy__bzr___btree_serializer_pyx
606 #define __PYX_HAVE_API__breezy__bzr___btree_serializer_pyx
607 /* Early includes */
608 #include "python-compat.h"
609 #include <string.h>
610 #include <stdlib.h>
611 #include <stdio.h>
612 #include "_static_tuple_c.h"
613 #ifdef _OPENMP
614 #include <omp.h>
615 #endif /* _OPENMP */
616
617 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
618 #define CYTHON_WITHOUT_ASSERTIONS
619 #endif
620
621 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
622 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
623
624 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
625 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
626 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
627 #define __PYX_DEFAULT_STRING_ENCODING ""
628 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
629 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
630 #define __Pyx_uchar_cast(c) ((unsigned char)c)
631 #define __Pyx_long_cast(x) ((long)x)
632 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
633 (sizeof(type) < sizeof(Py_ssize_t)) ||\
634 (sizeof(type) > sizeof(Py_ssize_t) &&\
635 likely(v < (type)PY_SSIZE_T_MAX ||\
636 v == (type)PY_SSIZE_T_MAX) &&\
637 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
638 v == (type)PY_SSIZE_T_MIN))) ||\
639 (sizeof(type) == sizeof(Py_ssize_t) &&\
640 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
641 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)642 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
643 return (size_t) i < (size_t) limit;
644 }
645 #if defined (__cplusplus) && __cplusplus >= 201103L
646 #include <cstdlib>
647 #define __Pyx_sst_abs(value) std::abs(value)
648 #elif SIZEOF_INT >= SIZEOF_SIZE_T
649 #define __Pyx_sst_abs(value) abs(value)
650 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
651 #define __Pyx_sst_abs(value) labs(value)
652 #elif defined (_MSC_VER)
653 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
654 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
655 #define __Pyx_sst_abs(value) llabs(value)
656 #elif defined (__GNUC__)
657 #define __Pyx_sst_abs(value) __builtin_llabs(value)
658 #else
659 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
660 #endif
661 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
662 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
663 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
664 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
665 #define __Pyx_PyBytes_FromString PyBytes_FromString
666 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
667 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
668 #if PY_MAJOR_VERSION < 3
669 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
670 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
671 #else
672 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
673 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
674 #endif
675 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
676 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
677 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
678 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
679 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
680 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
681 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
682 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
683 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
684 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
685 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
686 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
687 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
688 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
689 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
690 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)691 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
692 const Py_UNICODE *u_end = u;
693 while (*u_end++) ;
694 return (size_t)(u_end - u - 1);
695 }
696 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
697 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
698 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
699 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
700 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
701 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
702 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
703 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
704 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
705 #define __Pyx_PySequence_Tuple(obj)\
706 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
707 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
708 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
709 #if CYTHON_ASSUME_SAFE_MACROS
710 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
711 #else
712 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
713 #endif
714 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
715 #if PY_MAJOR_VERSION >= 3
716 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
717 #else
718 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
719 #endif
720 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
721 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
722 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)723 static int __Pyx_init_sys_getdefaultencoding_params(void) {
724 PyObject* sys;
725 PyObject* default_encoding = NULL;
726 PyObject* ascii_chars_u = NULL;
727 PyObject* ascii_chars_b = NULL;
728 const char* default_encoding_c;
729 sys = PyImport_ImportModule("sys");
730 if (!sys) goto bad;
731 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
732 Py_DECREF(sys);
733 if (!default_encoding) goto bad;
734 default_encoding_c = PyBytes_AsString(default_encoding);
735 if (!default_encoding_c) goto bad;
736 if (strcmp(default_encoding_c, "ascii") == 0) {
737 __Pyx_sys_getdefaultencoding_not_ascii = 0;
738 } else {
739 char ascii_chars[128];
740 int c;
741 for (c = 0; c < 128; c++) {
742 ascii_chars[c] = c;
743 }
744 __Pyx_sys_getdefaultencoding_not_ascii = 1;
745 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
746 if (!ascii_chars_u) goto bad;
747 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
748 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
749 PyErr_Format(
750 PyExc_ValueError,
751 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
752 default_encoding_c);
753 goto bad;
754 }
755 Py_DECREF(ascii_chars_u);
756 Py_DECREF(ascii_chars_b);
757 }
758 Py_DECREF(default_encoding);
759 return 0;
760 bad:
761 Py_XDECREF(default_encoding);
762 Py_XDECREF(ascii_chars_u);
763 Py_XDECREF(ascii_chars_b);
764 return -1;
765 }
766 #endif
767 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
768 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
769 #else
770 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
771 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
772 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)773 static int __Pyx_init_sys_getdefaultencoding_params(void) {
774 PyObject* sys;
775 PyObject* default_encoding = NULL;
776 char* default_encoding_c;
777 sys = PyImport_ImportModule("sys");
778 if (!sys) goto bad;
779 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
780 Py_DECREF(sys);
781 if (!default_encoding) goto bad;
782 default_encoding_c = PyBytes_AsString(default_encoding);
783 if (!default_encoding_c) goto bad;
784 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
785 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
786 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
787 Py_DECREF(default_encoding);
788 return 0;
789 bad:
790 Py_XDECREF(default_encoding);
791 return -1;
792 }
793 #endif
794 #endif
795
796
797 /* Test for GCC > 2.95 */
798 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
799 #define likely(x) __builtin_expect(!!(x), 1)
800 #define unlikely(x) __builtin_expect(!!(x), 0)
801 #else /* !__GNUC__ or GCC < 2.95 */
802 #define likely(x) (x)
803 #define unlikely(x) (x)
804 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)805 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
806
807 static PyObject *__pyx_m = NULL;
808 static PyObject *__pyx_d;
809 static PyObject *__pyx_b;
810 static PyObject *__pyx_cython_runtime = NULL;
811 static PyObject *__pyx_empty_tuple;
812 static PyObject *__pyx_empty_bytes;
813 static PyObject *__pyx_empty_unicode;
814 static int __pyx_lineno;
815 static int __pyx_clineno = 0;
816 static const char * __pyx_cfilenm= __FILE__;
817 static const char *__pyx_filename;
818
819
820 static const char *__pyx_f[] = {
821 "breezy/bzr/_btree_serializer_pyx.pyx",
822 "stringsource",
823 "breezy/bzr/_str_helpers.pxd",
824 "type.pxd",
825 "breezy/_static_tuple_c.pxd",
826 };
827
828 /*--- Type declarations ---*/
829 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser;
830 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
831 struct __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record;
832 typedef struct __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record;
833
834 /* "breezy/bzr/_btree_serializer_pyx.pyx":304
835 * # One slightly ugly option would be to cache block offsets in a global.
836 * # However, that leads to thread-safety issues, etc.
837 * ctypedef struct gc_chk_sha1_record: # <<<<<<<<<<<<<<
838 * unsigned long long block_offset
839 * unsigned int block_length
840 */
841 struct __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record {
842 unsigned PY_LONG_LONG block_offset;
843 unsigned int block_length;
844 unsigned int record_start;
845 unsigned int record_end;
846 char sha1[20];
847 };
848
849 /* "breezy/bzr/_btree_serializer_pyx.pyx":90
850 *
851 *
852 * cdef class BTreeLeafParser: # <<<<<<<<<<<<<<
853 * """Parse the leaf nodes of a BTree index.
854 *
855 */
856 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser {
857 PyObject_HEAD
858 struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_vtab;
859 PyObject *data;
860 int key_length;
861 int ref_list_length;
862 PyObject *keys;
863 char *_cur_str;
864 char *_end_str;
865 char *_start;
866 int _header_found;
867 };
868
869
870 /* "breezy/bzr/_btree_serializer_pyx.pyx":484
871 *
872 *
873 * cdef class GCCHKSHA1LeafNode: # <<<<<<<<<<<<<<
874 * """Track all the entries for a given leaf node."""
875 *
876 */
877 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode {
878 PyObject_HEAD
879 struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_vtab;
880 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *records;
881 PyObject *last_key;
882 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *last_record;
883 int num_records;
884 unsigned char common_shift;
885 unsigned char offsets[0x101];
886 };
887
888
889
890 /* "breezy/bzr/_btree_serializer_pyx.pyx":90
891 *
892 *
893 * cdef class BTreeLeafParser: # <<<<<<<<<<<<<<
894 * """Parse the leaf nodes of a BTree index.
895 *
896 */
897
898 struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser {
899 PyObject *(*extract_key)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *, char *);
900 int (*process_line)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *);
901 };
902 static struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_vtabptr_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser;
903
904
905 /* "breezy/bzr/_btree_serializer_pyx.pyx":484
906 *
907 *
908 * cdef class GCCHKSHA1LeafNode: # <<<<<<<<<<<<<<
909 * """Track all the entries for a given leaf node."""
910 *
911 */
912
913 struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode {
914 StaticTuple *(*_record_to_value_and_refs)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *);
915 StaticTuple *(*_record_to_item)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *);
916 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *(*_lookup_record)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *);
917 int (*_count_records)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *, char *);
918 PyObject *(*_parse_bytes)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, PyObject *);
919 char *(*_parse_one_entry)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *, char *, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *);
920 int (*_offset_for_sha1)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *);
921 PyObject *(*_compute_common)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *);
922 };
923 static struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_vtabptr_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
924
925 /* --- Runtime support code (head) --- */
926 /* Refnanny.proto */
927 #ifndef CYTHON_REFNANNY
928 #define CYTHON_REFNANNY 0
929 #endif
930 #if CYTHON_REFNANNY
931 typedef struct {
932 void (*INCREF)(void*, PyObject*, int);
933 void (*DECREF)(void*, PyObject*, int);
934 void (*GOTREF)(void*, PyObject*, int);
935 void (*GIVEREF)(void*, PyObject*, int);
936 void* (*SetupContext)(const char*, int, const char*);
937 void (*FinishContext)(void**);
938 } __Pyx_RefNannyAPIStruct;
939 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
940 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
941 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
942 #ifdef WITH_THREAD
943 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
944 if (acquire_gil) {\
945 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
946 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
947 PyGILState_Release(__pyx_gilstate_save);\
948 } else {\
949 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
950 }
951 #else
952 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
953 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
954 #endif
955 #define __Pyx_RefNannyFinishContext()\
956 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
957 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
958 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
959 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
960 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
961 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
962 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
963 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
964 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
965 #else
966 #define __Pyx_RefNannyDeclarations
967 #define __Pyx_RefNannySetupContext(name, acquire_gil)
968 #define __Pyx_RefNannyFinishContext()
969 #define __Pyx_INCREF(r) Py_INCREF(r)
970 #define __Pyx_DECREF(r) Py_DECREF(r)
971 #define __Pyx_GOTREF(r)
972 #define __Pyx_GIVEREF(r)
973 #define __Pyx_XINCREF(r) Py_XINCREF(r)
974 #define __Pyx_XDECREF(r) Py_XDECREF(r)
975 #define __Pyx_XGOTREF(r)
976 #define __Pyx_XGIVEREF(r)
977 #endif
978 #define __Pyx_XDECREF_SET(r, v) do {\
979 PyObject *tmp = (PyObject *) r;\
980 r = v; __Pyx_XDECREF(tmp);\
981 } while (0)
982 #define __Pyx_DECREF_SET(r, v) do {\
983 PyObject *tmp = (PyObject *) r;\
984 r = v; __Pyx_DECREF(tmp);\
985 } while (0)
986 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
987 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
988
989 /* PyObjectGetAttrStr.proto */
990 #if CYTHON_USE_TYPE_SLOTS
991 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
992 #else
993 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
994 #endif
995
996 /* GetBuiltinName.proto */
997 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
998
999 /* RaiseArgTupleInvalid.proto */
1000 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1001 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1002
1003 /* RaiseDoubleKeywords.proto */
1004 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1005
1006 /* ParseKeywords.proto */
1007 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1008 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1009 const char* function_name);
1010
1011 /* PyCFunctionFastCall.proto */
1012 #if CYTHON_FAST_PYCCALL
1013 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1014 #else
1015 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1016 #endif
1017
1018 /* PyFunctionFastCall.proto */
1019 #if CYTHON_FAST_PYCALL
1020 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1021 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1022 #if 1 || PY_VERSION_HEX < 0x030600B1
1023 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1024 #else
1025 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1026 #endif
1027 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1028 (sizeof(char [1 - 2*!(cond)]) - 1)
1029 #ifndef Py_MEMBER_SIZE
1030 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1031 #endif
1032 static size_t __pyx_pyframe_localsplus_offset = 0;
1033 #include "frameobject.h"
1034 #define __Pxy_PyFrame_Initialize_Offsets()\
1035 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1036 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1037 #define __Pyx_PyFrame_GetLocalsplus(frame)\
1038 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1039 #endif
1040
1041 /* PyObjectCall.proto */
1042 #if CYTHON_COMPILING_IN_CPYTHON
1043 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1044 #else
1045 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1046 #endif
1047
1048 /* PyObjectCallMethO.proto */
1049 #if CYTHON_COMPILING_IN_CPYTHON
1050 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1051 #endif
1052
1053 /* PyObjectCallOneArg.proto */
1054 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1055
1056 /* PyThreadStateGet.proto */
1057 #if CYTHON_FAST_THREAD_STATE
1058 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1059 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1060 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1061 #else
1062 #define __Pyx_PyThreadState_declare
1063 #define __Pyx_PyThreadState_assign
1064 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1065 #endif
1066
1067 /* PyErrFetchRestore.proto */
1068 #if CYTHON_FAST_THREAD_STATE
1069 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1070 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1071 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1072 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1073 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1074 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1075 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1076 #if CYTHON_COMPILING_IN_CPYTHON
1077 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1078 #else
1079 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1080 #endif
1081 #else
1082 #define __Pyx_PyErr_Clear() PyErr_Clear()
1083 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1084 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1085 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1086 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1087 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1088 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1089 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1090 #endif
1091
1092 /* RaiseException.proto */
1093 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1094
1095 /* PyObjectCallNoArg.proto */
1096 #if CYTHON_COMPILING_IN_CPYTHON
1097 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1098 #else
1099 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1100 #endif
1101
1102 /* PyErrExceptionMatches.proto */
1103 #if CYTHON_FAST_THREAD_STATE
1104 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1105 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1106 #else
1107 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1108 #endif
1109
1110 /* GetAttr.proto */
1111 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1112
1113 /* GetAttr3.proto */
1114 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
1115
1116 /* PyDictVersioning.proto */
1117 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1118 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1119 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1120 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1121 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1122 (cache_var) = (value);
1123 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1124 static PY_UINT64_T __pyx_dict_version = 0;\
1125 static PyObject *__pyx_dict_cached_value = NULL;\
1126 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1127 (VAR) = __pyx_dict_cached_value;\
1128 } else {\
1129 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1130 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1131 }\
1132 }
1133 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1134 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1135 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1136 #else
1137 #define __PYX_GET_DICT_VERSION(dict) (0)
1138 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1139 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1140 #endif
1141
1142 /* GetModuleGlobalName.proto */
1143 #if CYTHON_USE_DICT_VERSIONS
1144 #define __Pyx_GetModuleGlobalName(var, name) {\
1145 static PY_UINT64_T __pyx_dict_version = 0;\
1146 static PyObject *__pyx_dict_cached_value = NULL;\
1147 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1148 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1149 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1150 }
1151 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1152 PY_UINT64_T __pyx_dict_version;\
1153 PyObject *__pyx_dict_cached_value;\
1154 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1155 }
1156 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1157 #else
1158 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1159 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1160 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1161 #endif
1162
1163 /* ExtTypeTest.proto */
1164 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1165
1166 /* WriteUnraisableException.proto */
1167 static void __Pyx_WriteUnraisable(const char *name, int clineno,
1168 int lineno, const char *filename,
1169 int full_traceback, int nogil);
1170
1171 /* None.proto */
1172 static CYTHON_INLINE long __Pyx_div_long(long, long);
1173
1174 /* PyObjectFormatAndDecref.proto */
1175 static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
1176 static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);
1177
1178 /* IncludeStringH.proto */
1179 #include <string.h>
1180
1181 /* JoinPyUnicode.proto */
1182 static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
1183 Py_UCS4 max_char);
1184
1185 /* SliceObject.proto */
1186 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
1187 PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
1188 PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
1189 int has_cstart, int has_cstop, int wraparound);
1190
1191 /* PyIntCompare.proto */
1192 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1193
1194 /* StringJoin.proto */
1195 #if PY_MAJOR_VERSION < 3
1196 #define __Pyx_PyString_Join __Pyx_PyBytes_Join
1197 #define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
1198 #else
1199 #define __Pyx_PyString_Join PyUnicode_Join
1200 #define __Pyx_PyBaseString_Join PyUnicode_Join
1201 #endif
1202 #if CYTHON_COMPILING_IN_CPYTHON
1203 #if PY_MAJOR_VERSION < 3
1204 #define __Pyx_PyBytes_Join _PyString_Join
1205 #else
1206 #define __Pyx_PyBytes_Join _PyBytes_Join
1207 #endif
1208 #else
1209 static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
1210 #endif
1211
1212 /* GetItemInt.proto */
1213 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1214 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1215 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1216 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1217 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1218 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1219 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1220 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1221 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1222 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1223 int wraparound, int boundscheck);
1224 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1225 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1226 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1227 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1228 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1229 int wraparound, int boundscheck);
1230 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1231 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1232 int is_list, int wraparound, int boundscheck);
1233
1234 /* None.proto */
1235 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
1236
1237 /* Import.proto */
1238 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1239
1240 /* ImportFrom.proto */
1241 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1242
1243 /* PyObjectCall2Args.proto */
1244 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1245
1246 /* HasAttr.proto */
1247 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
1248
1249 /* PyObject_GenericGetAttrNoDict.proto */
1250 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1251 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1252 #else
1253 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1254 #endif
1255
1256 /* PyObject_GenericGetAttr.proto */
1257 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1258 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1259 #else
1260 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1261 #endif
1262
1263 /* SetVTable.proto */
1264 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
1265
1266 /* PyObjectGetAttrStrNoError.proto */
1267 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1268
1269 /* SetupReduce.proto */
1270 static int __Pyx_setup_reduce(PyObject* type_obj);
1271
1272 /* TypeImport.proto */
1273 #ifndef __PYX_HAVE_RT_ImportType_proto
1274 #define __PYX_HAVE_RT_ImportType_proto
1275 enum __Pyx_ImportType_CheckSize {
1276 __Pyx_ImportType_CheckSize_Error = 0,
1277 __Pyx_ImportType_CheckSize_Warn = 1,
1278 __Pyx_ImportType_CheckSize_Ignore = 2
1279 };
1280 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1281 #endif
1282
1283 /* CLineInTraceback.proto */
1284 #ifdef CYTHON_CLINE_IN_TRACEBACK
1285 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1286 #else
1287 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1288 #endif
1289
1290 /* CodeObjectCache.proto */
1291 typedef struct {
1292 PyCodeObject* code_object;
1293 int code_line;
1294 } __Pyx_CodeObjectCacheEntry;
1295 struct __Pyx_CodeObjectCache {
1296 int count;
1297 int max_count;
1298 __Pyx_CodeObjectCacheEntry* entries;
1299 };
1300 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1301 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1302 static PyCodeObject *__pyx_find_code_object(int code_line);
1303 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1304
1305 /* AddTraceback.proto */
1306 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1307 int py_line, const char *filename);
1308
1309 /* CIntToPy.proto */
1310 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1311
1312 /* CIntToPy.proto */
1313 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value);
1314
1315 /* CIntToPy.proto */
1316 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
1317
1318 /* CIntToPy.proto */
1319 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_char(unsigned char value);
1320
1321 /* CIntToPy.proto */
1322 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1323
1324 /* CIntFromPy.proto */
1325 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1326
1327 /* CIntFromPy.proto */
1328 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1329
1330 /* CIntFromPy.proto */
1331 static CYTHON_INLINE unsigned char __Pyx_PyInt_As_unsigned_char(PyObject *);
1332
1333 /* FastTypeChecks.proto */
1334 #if CYTHON_COMPILING_IN_CPYTHON
1335 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1336 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1337 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1338 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1339 #else
1340 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1341 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1342 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1343 #endif
1344 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1345
1346 /* CheckBinaryVersion.proto */
1347 static int __Pyx_check_binary_version(void);
1348
1349 /* InitStrings.proto */
1350 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1351
1352 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_extract_key(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self, char *__pyx_v_last); /* proto*/
1353 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_process_line(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self); /* proto*/
1354 static StaticTuple *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_value_and_refs(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record); /* proto*/
1355 static StaticTuple *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_item(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record); /* proto*/
1356 static __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__lookup_record(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_sha1); /* proto*/
1357 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__count_records(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_c_content, char *__pyx_v_c_end); /* proto*/
1358 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_bytes(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_data); /* proto*/
1359 static char *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_one_entry(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_c_cur, char *__pyx_v_c_end, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_cur_record); /* proto*/
1360 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__offset_for_sha1(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_sha1); /* proto*/
1361 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__compute_common(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto*/
1362
1363 /* Module declarations from 'libc.string' */
1364
1365 /* Module declarations from 'libc.stdlib' */
1366
1367 /* Module declarations from 'libc.stdio' */
1368
1369 /* Module declarations from '__builtin__' */
1370
1371 /* Module declarations from 'cpython.type' */
1372 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1373
1374 /* Module declarations from 'cpython' */
1375
1376 /* Module declarations from 'cpython.object' */
1377
1378 /* Module declarations from 'cpython.bytes' */
1379
1380 /* Module declarations from 'cpython.list' */
1381
1382 /* Module declarations from 'cpython.mem' */
1383
1384 /* Module declarations from 'cpython.ref' */
1385
1386 /* Module declarations from 'cpython.tuple' */
1387
1388 /* Module declarations from 'breezy.bzr._str_helpers' */
1389 static CYTHON_INLINE void *__pyx_f_6breezy_3bzr_12_str_helpers__my_memrchr(void *, int, size_t); /*proto*/
1390 static CYTHON_INLINE PyObject *__pyx_f_6breezy_3bzr_12_str_helpers_safe_string_from_size(char *, Py_ssize_t); /*proto*/
1391 static CYTHON_INLINE PyObject *__pyx_f_6breezy_3bzr_12_str_helpers_safe_interned_string_from_size(char *, Py_ssize_t); /*proto*/
1392
1393 /* Module declarations from 'breezy._static_tuple_c' */
1394
1395 /* Module declarations from 'breezy._static_tuple_c' */
1396 static PyTypeObject *__pyx_ptype_6breezy_15_static_tuple_c_StaticTuple = 0;
1397
1398 /* Module declarations from 'breezy.bzr._btree_serializer_pyx' */
1399 static PyTypeObject *__pyx_ptype_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser = 0;
1400 static PyTypeObject *__pyx_ptype_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode = 0;
1401 static int __pyx_v_6breezy_3bzr_21_btree_serializer_pyx__unhexbuf[0x100];
1402 static char *__pyx_v_6breezy_3bzr_21_btree_serializer_pyx__hexbuf;
1403 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__populate_unhexbuf(void); /*proto*/
1404 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__unhexlify_sha1(char *, char *); /*proto*/
1405 static void __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__hexlify_sha1(char *, char *); /*proto*/
1406 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__key_to_sha1(PyObject *, char *); /*proto*/
1407 static StaticTuple *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_key(char *); /*proto*/
1408 static unsigned int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_uint(char *); /*proto*/
1409 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__format_record(__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *); /*proto*/
1410 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx___pyx_unpickle_BTreeLeafParser__set_state(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *, PyObject *); /*proto*/
1411 #define __Pyx_MODULE_NAME "breezy.bzr._btree_serializer_pyx"
1412 extern int __pyx_module_is_main_breezy__bzr___btree_serializer_pyx;
1413 int __pyx_module_is_main_breezy__bzr___btree_serializer_pyx = 0;
1414
1415 /* Implementation of 'breezy.bzr._btree_serializer_pyx' */
1416 static PyObject *__pyx_builtin_AssertionError;
1417 static PyObject *__pyx_builtin_ValueError;
1418 static PyObject *__pyx_builtin_KeyError;
1419 static PyObject *__pyx_builtin_TypeError;
1420 static const char __pyx_k_d[] = "%d";
1421 static const char __pyx_k_i[] = "i";
1422 static const char __pyx_k__20[] = "\000";
1423 static const char __pyx_k_key[] = "key ";
1424 static const char __pyx_k_new[] = "__new__";
1425 static const char __pyx_k_out[] = "out";
1426 static const char __pyx_k_sys[] = "sys";
1427 static const char __pyx_k_val[] = "val";
1428 static const char __pyx_k_data[] = "data";
1429 static const char __pyx_k_dict[] = "__dict__";
1430 static const char __pyx_k_join[] = "join";
1431 static const char __pyx_k_line[] = "line";
1432 static const char __pyx_k_main[] = "__main__";
1433 static const char __pyx_k_name[] = "__name__";
1434 static const char __pyx_k_node[] = "node";
1435 static const char __pyx_k_test[] = "__test__";
1436 static const char __pyx_k_bytes[] = "bytes";
1437 static const char __pyx_k_key_2[] = "key";
1438 static const char __pyx_k_parse[] = "parse";
1439 static const char __pyx_k_value[] = "value";
1440 static const char __pyx_k_as_bin[] = "as_bin";
1441 static const char __pyx_k_as_hex[] = "as_hex";
1442 static const char __pyx_k_import[] = "__import__";
1443 static const char __pyx_k_parser[] = "parser";
1444 static const char __pyx_k_pickle[] = "pickle";
1445 static const char __pyx_k_reduce[] = "__reduce__";
1446 static const char __pyx_k_update[] = "update";
1447 static const char __pyx_k_key_len[] = "key_len";
1448 static const char __pyx_k_ref_bit[] = "ref_bit";
1449 static const char __pyx_k_KeyError[] = "KeyError";
1450 static const char __pyx_k_flat_len[] = "flat_len";
1451 static const char __pyx_k_getstate[] = "__getstate__";
1452 static const char __pyx_k_next_len[] = "next_len";
1453 static const char __pyx_k_node_len[] = "node_len";
1454 static const char __pyx_k_pyx_type[] = "__pyx_type";
1455 static const char __pyx_k_ref_list[] = "ref_list";
1456 static const char __pyx_k_refs_len[] = "refs_len";
1457 static const char __pyx_k_setstate[] = "__setstate__";
1458 static const char __pyx_k_sha1_bin[] = "sha1_bin";
1459 static const char __pyx_k_TypeError[] = "TypeError";
1460 static const char __pyx_k_pyx_state[] = "__pyx_state";
1461 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1462 static const char __pyx_k_ref_lists[] = "ref_lists";
1463 static const char __pyx_k_reference[] = "reference";
1464 static const char __pyx_k_value_len[] = "value_len";
1465 static const char __pyx_k_ValueError[] = "ValueError";
1466 static const char __pyx_k_as_bin_sha[] = "as_bin_sha";
1467 static const char __pyx_k_key_length[] = "key_length";
1468 static const char __pyx_k_py_hexlify[] = "_py_hexlify";
1469 static const char __pyx_k_pyx_result[] = "__pyx_result";
1470 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
1471 static const char __pyx_k_string_key[] = "string_key";
1472 static const char __pyx_k_PickleError[] = "PickleError";
1473 static const char __pyx_k_ref_bit_len[] = "ref_bit_len";
1474 static const char __pyx_k_flatten_node[] = "_flatten_node";
1475 static const char __pyx_k_py_unhexlify[] = "_py_unhexlify";
1476 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
1477 static const char __pyx_k_stringsource[] = "stringsource";
1478 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1479 static const char __pyx_k_AssertionError[] = "AssertionError";
1480 static const char __pyx_k_first_ref_list[] = "first_ref_list";
1481 static const char __pyx_k_is_not_present[] = " is not present";
1482 static const char __pyx_k_parse_into_chk[] = "_parse_into_chk";
1483 static const char __pyx_k_py_key_to_sha1[] = "_py_key_to_sha1";
1484 static const char __pyx_k_py_sha1_to_key[] = "_py_sha1_to_key";
1485 static const char __pyx_k_BTreeLeafParser[] = "BTreeLeafParser";
1486 static const char __pyx_k_first_reference[] = "first_reference";
1487 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
1488 static const char __pyx_k_ref_list_length[] = "ref_list_length";
1489 static const char __pyx_k_reference_lists[] = "reference_lists";
1490 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1491 static const char __pyx_k_last_self__start[] = "last < self._start";
1492 static const char __pyx_k_parse_leaf_lines[] = "_parse_leaf_lines";
1493 static const char __pyx_k_GCCHKSHA1LeafNode[] = "GCCHKSHA1LeafNode";
1494 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1495 static const char __pyx_k_have_reference_lists[] = "have_reference_lists";
1496 static const char __pyx_k_We_failed_to_unhexlify[] = "We failed to unhexlify";
1497 static const char __pyx_k_not_a_40_byte_hex_digest[] = "not a 40-byte hex digest";
1498 static const char __pyx_k_Failed_to_parse_record_end[] = "Failed to parse record end";
1499 static const char __pyx_k_not_a_20_byte_binary_digest[] = "not a 20-byte binary digest";
1500 static const char __pyx_k_Failed_to_parse_block_length[] = "Failed to parse block length";
1501 static const char __pyx_k_Failed_to_parse_block_offset[] = "Failed to parse block offset";
1502 static const char __pyx_k_line_did_not_start_with_sha1[] = "line did not start with sha1: ";
1503 static const char __pyx_k_pyx_unpickle_BTreeLeafParser[] = "__pyx_unpickle_BTreeLeafParser";
1504 static const char __pyx_k_Failed_to_find_the_value_area[] = "Failed to find the value area";
1505 static const char __pyx_k_only_1_null_not_2_as_expected[] = "only 1 null, not 2 as expected";
1506 static const char __pyx_k_Expected_bytes_for_value_not_r[] = "Expected bytes for value not: %r";
1507 static const char __pyx_k_self_data_is_not_a_byte_string[] = "self.data is not a byte string.";
1508 static const char __pyx_k_invalid_key_wanted_segment_from[] = "invalid key, wanted segment from ";
1509 static const char __pyx_k_Incompatible_checksums_s_vs_0x9b[] = "Incompatible checksums (%s vs 0x9b802a2 = (_cur_str, _end_str, _header_found, _start, data, key_length, keys, ref_list_length))";
1510 static const char __pyx_k_Line_did_not_contain_40_hex_byte[] = "Line did not contain 40 hex bytes";
1511 static const char __pyx_k_Node_did_not_start_with_type_lea[] = "Node did not start with \"type=leaf\": %r";
1512 static const char __pyx_k_Pyrex_extensions_to_btree_node_p[] = "Pyrex extensions to btree node parsing.";
1513 static const char __pyx_k_Something_went_wrong_while_parsi[] = "Something went wrong while parsing.";
1514 static const char __pyx_k_We_expect_reference_bits_to_be_b[] = "We expect reference bits to be bytes not: %r";
1515 static const char __pyx_k_We_expect_references_to_be_tuple[] = "We expect references to be tuples not: %r";
1516 static const char __pyx_k_We_expected_a_tuple_or_StaticTup[] = "We expected a tuple() or StaticTuple() for node not: %s";
1517 static const char __pyx_k_We_only_support_parsing_byte_str[] = "We only support parsing byte strings.";
1518 static const char __pyx_k_With_ref_lists_we_expected_4_ent[] = "With ref_lists, we expected 4 entries not: %s";
1519 static const char __pyx_k_Without_ref_lists_we_need_at_lea[] = "Without ref_lists, we need at least 3 entries not: %s";
1520 static const char __pyx_k_breezy_bzr__btree_serializer_pyx[] = "breezy/bzr/_btree_serializer_pyx.pyx";
1521 static const char __pyx_k_bytes_did_not_start_with_type_le[] = "bytes did not start with 'type=leaf\\n': ";
1522 static const char __pyx_k_invalid_key_loop_counter_self_re[] = "invalid key, loop_counter != self.ref_list_length";
1523 static const char __pyx_k_self_last_record_self_records_ca[] = "self.last_record,self.records cannot be converted to a Python object for pickling";
1524 static const char __pyx_k_sha1_bin_must_be_a_str_of_exactl[] = "sha1_bin must be a str of exactly 20 bytes";
1525 static const char __pyx_k_tried_to_create_a_string_with_an[] = "tried to create a string with an invalid size: %d";
1526 static const char __pyx_k_unexpected_reference_data_presen[] = "unexpected reference data present";
1527 static const char __pyx_k_breezy_bzr__btree_serializer_pyx_2[] = "breezy.bzr._btree_serializer_pyx";
1528 static PyObject *__pyx_n_s_AssertionError;
1529 static PyObject *__pyx_n_s_BTreeLeafParser;
1530 static PyObject *__pyx_kp_u_Expected_bytes_for_value_not_r;
1531 static PyObject *__pyx_kp_u_Failed_to_find_the_value_area;
1532 static PyObject *__pyx_kp_u_Failed_to_parse_block_length;
1533 static PyObject *__pyx_kp_u_Failed_to_parse_block_offset;
1534 static PyObject *__pyx_kp_u_Failed_to_parse_record_end;
1535 static PyObject *__pyx_n_s_GCCHKSHA1LeafNode;
1536 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x9b;
1537 static PyObject *__pyx_n_s_KeyError;
1538 static PyObject *__pyx_kp_u_Line_did_not_contain_40_hex_byte;
1539 static PyObject *__pyx_kp_u_Node_did_not_start_with_type_lea;
1540 static PyObject *__pyx_n_s_PickleError;
1541 static PyObject *__pyx_kp_u_Something_went_wrong_while_parsi;
1542 static PyObject *__pyx_n_s_TypeError;
1543 static PyObject *__pyx_n_s_ValueError;
1544 static PyObject *__pyx_kp_u_We_expect_reference_bits_to_be_b;
1545 static PyObject *__pyx_kp_u_We_expect_references_to_be_tuple;
1546 static PyObject *__pyx_kp_u_We_expected_a_tuple_or_StaticTup;
1547 static PyObject *__pyx_kp_u_We_failed_to_unhexlify;
1548 static PyObject *__pyx_kp_u_We_only_support_parsing_byte_str;
1549 static PyObject *__pyx_kp_u_With_ref_lists_we_expected_4_ent;
1550 static PyObject *__pyx_kp_u_Without_ref_lists_we_need_at_lea;
1551 static PyObject *__pyx_kp_b__20;
1552 static PyObject *__pyx_n_s_as_bin;
1553 static PyObject *__pyx_n_s_as_bin_sha;
1554 static PyObject *__pyx_n_s_as_hex;
1555 static PyObject *__pyx_kp_s_breezy_bzr__btree_serializer_pyx;
1556 static PyObject *__pyx_n_s_breezy_bzr__btree_serializer_pyx_2;
1557 static PyObject *__pyx_n_s_bytes;
1558 static PyObject *__pyx_kp_u_bytes_did_not_start_with_type_le;
1559 static PyObject *__pyx_n_s_cline_in_traceback;
1560 static PyObject *__pyx_kp_b_d;
1561 static PyObject *__pyx_n_s_data;
1562 static PyObject *__pyx_n_s_dict;
1563 static PyObject *__pyx_n_s_first_ref_list;
1564 static PyObject *__pyx_n_s_first_reference;
1565 static PyObject *__pyx_n_s_flat_len;
1566 static PyObject *__pyx_n_s_flatten_node;
1567 static PyObject *__pyx_n_s_getstate;
1568 static PyObject *__pyx_n_s_have_reference_lists;
1569 static PyObject *__pyx_n_s_i;
1570 static PyObject *__pyx_n_s_import;
1571 static PyObject *__pyx_kp_u_invalid_key_loop_counter_self_re;
1572 static PyObject *__pyx_kp_u_invalid_key_wanted_segment_from;
1573 static PyObject *__pyx_kp_u_is_not_present;
1574 static PyObject *__pyx_n_s_join;
1575 static PyObject *__pyx_kp_u_key;
1576 static PyObject *__pyx_n_s_key_2;
1577 static PyObject *__pyx_n_s_key_len;
1578 static PyObject *__pyx_n_s_key_length;
1579 static PyObject *__pyx_kp_u_last_self__start;
1580 static PyObject *__pyx_n_s_line;
1581 static PyObject *__pyx_kp_u_line_did_not_start_with_sha1;
1582 static PyObject *__pyx_n_s_main;
1583 static PyObject *__pyx_n_s_name;
1584 static PyObject *__pyx_n_s_new;
1585 static PyObject *__pyx_n_s_next_len;
1586 static PyObject *__pyx_n_s_node;
1587 static PyObject *__pyx_n_s_node_len;
1588 static PyObject *__pyx_kp_u_not_a_20_byte_binary_digest;
1589 static PyObject *__pyx_kp_u_not_a_40_byte_hex_digest;
1590 static PyObject *__pyx_kp_u_only_1_null_not_2_as_expected;
1591 static PyObject *__pyx_n_s_out;
1592 static PyObject *__pyx_n_s_parse;
1593 static PyObject *__pyx_n_s_parse_into_chk;
1594 static PyObject *__pyx_n_s_parse_leaf_lines;
1595 static PyObject *__pyx_n_s_parser;
1596 static PyObject *__pyx_n_s_pickle;
1597 static PyObject *__pyx_n_s_py_hexlify;
1598 static PyObject *__pyx_n_s_py_key_to_sha1;
1599 static PyObject *__pyx_n_s_py_sha1_to_key;
1600 static PyObject *__pyx_n_s_py_unhexlify;
1601 static PyObject *__pyx_n_s_pyx_PickleError;
1602 static PyObject *__pyx_n_s_pyx_checksum;
1603 static PyObject *__pyx_n_s_pyx_result;
1604 static PyObject *__pyx_n_s_pyx_state;
1605 static PyObject *__pyx_n_s_pyx_type;
1606 static PyObject *__pyx_n_s_pyx_unpickle_BTreeLeafParser;
1607 static PyObject *__pyx_n_s_pyx_vtable;
1608 static PyObject *__pyx_n_s_reduce;
1609 static PyObject *__pyx_n_s_reduce_cython;
1610 static PyObject *__pyx_n_s_reduce_ex;
1611 static PyObject *__pyx_n_s_ref_bit;
1612 static PyObject *__pyx_n_s_ref_bit_len;
1613 static PyObject *__pyx_n_s_ref_list;
1614 static PyObject *__pyx_n_s_ref_list_length;
1615 static PyObject *__pyx_n_s_ref_lists;
1616 static PyObject *__pyx_n_s_reference;
1617 static PyObject *__pyx_n_s_reference_lists;
1618 static PyObject *__pyx_n_s_refs_len;
1619 static PyObject *__pyx_kp_u_self_data_is_not_a_byte_string;
1620 static PyObject *__pyx_kp_s_self_last_record_self_records_ca;
1621 static PyObject *__pyx_n_s_setstate;
1622 static PyObject *__pyx_n_s_setstate_cython;
1623 static PyObject *__pyx_n_s_sha1_bin;
1624 static PyObject *__pyx_kp_u_sha1_bin_must_be_a_str_of_exactl;
1625 static PyObject *__pyx_n_s_string_key;
1626 static PyObject *__pyx_kp_s_stringsource;
1627 static PyObject *__pyx_n_s_sys;
1628 static PyObject *__pyx_n_s_test;
1629 static PyObject *__pyx_kp_u_tried_to_create_a_string_with_an;
1630 static PyObject *__pyx_kp_u_unexpected_reference_data_presen;
1631 static PyObject *__pyx_n_s_update;
1632 static PyObject *__pyx_n_s_val;
1633 static PyObject *__pyx_n_s_value;
1634 static PyObject *__pyx_n_s_value_len;
1635 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser___init__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self, PyObject *__pyx_v_data, PyObject *__pyx_v_key_length, PyObject *__pyx_v_ref_list_length); /* proto */
1636 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_2parse(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self); /* proto */
1637 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_4__reduce_cython__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self); /* proto */
1638 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_6__setstate_cython__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
1639 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx__parse_leaf_lines(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_key_length, PyObject *__pyx_v_ref_list_length); /* proto */
1640 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_2_py_unhexlify(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_as_hex); /* proto */
1641 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_4_py_hexlify(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_as_bin); /* proto */
1642 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_6_py_key_to_sha1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_key); /* proto */
1643 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_8_py_sha1_to_key(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sha1_bin); /* proto */
1644 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode___sizeof__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1645 static void __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_2__dealloc__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1646 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_4__init__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_bytes); /* proto */
1647 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1648 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1649 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_6__contains__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
1650 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8__getitem__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
1651 static Py_ssize_t __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_10__len__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1652 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12all_keys(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1653 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_14all_items(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1654 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_16_get_offset_for_sha1(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_sha1); /* proto */
1655 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_18_get_offsets(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1656 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1657 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_2__set__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1658 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_4__del__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1659 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1660 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_2__set__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1661 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1662 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_2__set__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1663 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self); /* proto */
1664 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
1665 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_10_parse_into_chk(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_bytes, PyObject *__pyx_v_key_length, PyObject *__pyx_v_ref_list_length); /* proto */
1666 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_12_flatten_node(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_node, PyObject *__pyx_v_reference_lists); /* proto */
1667 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_14__pyx_unpickle_BTreeLeafParser(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
1668 static PyObject *__pyx_tp_new_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1669 static PyObject *__pyx_tp_new_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1670 static PyObject *__pyx_int_0;
1671 static PyObject *__pyx_int_1;
1672 static PyObject *__pyx_int_10;
1673 static PyObject *__pyx_int_163054242;
1674 static PyObject *__pyx_int_2147483648;
1675 static PyObject *__pyx_int_4294967295;
1676 static PyObject *__pyx_tuple_;
1677 static PyObject *__pyx_tuple__2;
1678 static PyObject *__pyx_tuple__3;
1679 static PyObject *__pyx_tuple__4;
1680 static PyObject *__pyx_tuple__5;
1681 static PyObject *__pyx_tuple__6;
1682 static PyObject *__pyx_tuple__7;
1683 static PyObject *__pyx_tuple__8;
1684 static PyObject *__pyx_tuple__9;
1685 static PyObject *__pyx_slice__10;
1686 static PyObject *__pyx_tuple__11;
1687 static PyObject *__pyx_tuple__12;
1688 static PyObject *__pyx_tuple__13;
1689 static PyObject *__pyx_tuple__14;
1690 static PyObject *__pyx_tuple__15;
1691 static PyObject *__pyx_tuple__16;
1692 static PyObject *__pyx_tuple__17;
1693 static PyObject *__pyx_tuple__18;
1694 static PyObject *__pyx_tuple__19;
1695 static PyObject *__pyx_tuple__21;
1696 static PyObject *__pyx_tuple__23;
1697 static PyObject *__pyx_tuple__25;
1698 static PyObject *__pyx_tuple__27;
1699 static PyObject *__pyx_tuple__29;
1700 static PyObject *__pyx_tuple__31;
1701 static PyObject *__pyx_tuple__33;
1702 static PyObject *__pyx_tuple__35;
1703 static PyObject *__pyx_codeobj__22;
1704 static PyObject *__pyx_codeobj__24;
1705 static PyObject *__pyx_codeobj__26;
1706 static PyObject *__pyx_codeobj__28;
1707 static PyObject *__pyx_codeobj__30;
1708 static PyObject *__pyx_codeobj__32;
1709 static PyObject *__pyx_codeobj__34;
1710 static PyObject *__pyx_codeobj__36;
1711 /* Late includes */
1712
1713 /* "breezy/bzr/_btree_serializer_pyx.pyx":120
1714 * cdef int _header_found
1715 *
1716 * def __init__(self, data, key_length, ref_list_length): # <<<<<<<<<<<<<<
1717 * self.data = data
1718 * self.key_length = key_length
1719 */
1720
1721 /* Python wrapper */
1722 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_1__init__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1723 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1724 PyObject *__pyx_v_data = 0;
1725 PyObject *__pyx_v_key_length = 0;
1726 PyObject *__pyx_v_ref_list_length = 0;
1727 int __pyx_lineno = 0;
1728 const char *__pyx_filename = NULL;
1729 int __pyx_clineno = 0;
1730 int __pyx_r;
1731 __Pyx_RefNannyDeclarations
1732 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
1733 {
1734 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_key_length,&__pyx_n_s_ref_list_length,0};
1735 PyObject* values[3] = {0,0,0};
1736 if (unlikely(__pyx_kwds)) {
1737 Py_ssize_t kw_args;
1738 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1739 switch (pos_args) {
1740 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1741 CYTHON_FALLTHROUGH;
1742 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1743 CYTHON_FALLTHROUGH;
1744 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1745 CYTHON_FALLTHROUGH;
1746 case 0: break;
1747 default: goto __pyx_L5_argtuple_error;
1748 }
1749 kw_args = PyDict_Size(__pyx_kwds);
1750 switch (pos_args) {
1751 case 0:
1752 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
1753 else goto __pyx_L5_argtuple_error;
1754 CYTHON_FALLTHROUGH;
1755 case 1:
1756 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key_length)) != 0)) kw_args--;
1757 else {
1758 __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 120, __pyx_L3_error)
1759 }
1760 CYTHON_FALLTHROUGH;
1761 case 2:
1762 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref_list_length)) != 0)) kw_args--;
1763 else {
1764 __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 120, __pyx_L3_error)
1765 }
1766 }
1767 if (unlikely(kw_args > 0)) {
1768 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 120, __pyx_L3_error)
1769 }
1770 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
1771 goto __pyx_L5_argtuple_error;
1772 } else {
1773 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1774 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1775 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1776 }
1777 __pyx_v_data = values[0];
1778 __pyx_v_key_length = values[1];
1779 __pyx_v_ref_list_length = values[2];
1780 }
1781 goto __pyx_L4_argument_unpacking_done;
1782 __pyx_L5_argtuple_error:;
1783 __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 120, __pyx_L3_error)
1784 __pyx_L3_error:;
1785 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.BTreeLeafParser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1786 __Pyx_RefNannyFinishContext();
1787 return -1;
1788 __pyx_L4_argument_unpacking_done:;
1789 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser___init__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self), __pyx_v_data, __pyx_v_key_length, __pyx_v_ref_list_length);
1790
1791 /* function exit code */
1792 __Pyx_RefNannyFinishContext();
1793 return __pyx_r;
1794 }
1795
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser___init__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser * __pyx_v_self,PyObject * __pyx_v_data,PyObject * __pyx_v_key_length,PyObject * __pyx_v_ref_list_length)1796 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser___init__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self, PyObject *__pyx_v_data, PyObject *__pyx_v_key_length, PyObject *__pyx_v_ref_list_length) {
1797 int __pyx_r;
1798 __Pyx_RefNannyDeclarations
1799 int __pyx_t_1;
1800 PyObject *__pyx_t_2 = NULL;
1801 int __pyx_lineno = 0;
1802 const char *__pyx_filename = NULL;
1803 int __pyx_clineno = 0;
1804 __Pyx_RefNannySetupContext("__init__", 0);
1805
1806 /* "breezy/bzr/_btree_serializer_pyx.pyx":121
1807 *
1808 * def __init__(self, data, key_length, ref_list_length):
1809 * self.data = data # <<<<<<<<<<<<<<
1810 * self.key_length = key_length
1811 * self.ref_list_length = ref_list_length
1812 */
1813 __Pyx_INCREF(__pyx_v_data);
1814 __Pyx_GIVEREF(__pyx_v_data);
1815 __Pyx_GOTREF(__pyx_v_self->data);
1816 __Pyx_DECREF(__pyx_v_self->data);
1817 __pyx_v_self->data = __pyx_v_data;
1818
1819 /* "breezy/bzr/_btree_serializer_pyx.pyx":122
1820 * def __init__(self, data, key_length, ref_list_length):
1821 * self.data = data
1822 * self.key_length = key_length # <<<<<<<<<<<<<<
1823 * self.ref_list_length = ref_list_length
1824 * self.keys = []
1825 */
1826 __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_key_length); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 122, __pyx_L1_error)
1827 __pyx_v_self->key_length = __pyx_t_1;
1828
1829 /* "breezy/bzr/_btree_serializer_pyx.pyx":123
1830 * self.data = data
1831 * self.key_length = key_length
1832 * self.ref_list_length = ref_list_length # <<<<<<<<<<<<<<
1833 * self.keys = []
1834 * self._cur_str = NULL
1835 */
1836 __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_ref_list_length); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 123, __pyx_L1_error)
1837 __pyx_v_self->ref_list_length = __pyx_t_1;
1838
1839 /* "breezy/bzr/_btree_serializer_pyx.pyx":124
1840 * self.key_length = key_length
1841 * self.ref_list_length = ref_list_length
1842 * self.keys = [] # <<<<<<<<<<<<<<
1843 * self._cur_str = NULL
1844 * self._end_str = NULL
1845 */
1846 __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
1847 __Pyx_GOTREF(__pyx_t_2);
1848 __Pyx_GIVEREF(__pyx_t_2);
1849 __Pyx_GOTREF(__pyx_v_self->keys);
1850 __Pyx_DECREF(__pyx_v_self->keys);
1851 __pyx_v_self->keys = __pyx_t_2;
1852 __pyx_t_2 = 0;
1853
1854 /* "breezy/bzr/_btree_serializer_pyx.pyx":125
1855 * self.ref_list_length = ref_list_length
1856 * self.keys = []
1857 * self._cur_str = NULL # <<<<<<<<<<<<<<
1858 * self._end_str = NULL
1859 * self._header_found = 0
1860 */
1861 __pyx_v_self->_cur_str = NULL;
1862
1863 /* "breezy/bzr/_btree_serializer_pyx.pyx":126
1864 * self.keys = []
1865 * self._cur_str = NULL
1866 * self._end_str = NULL # <<<<<<<<<<<<<<
1867 * self._header_found = 0
1868 * # keys are tuples
1869 */
1870 __pyx_v_self->_end_str = NULL;
1871
1872 /* "breezy/bzr/_btree_serializer_pyx.pyx":127
1873 * self._cur_str = NULL
1874 * self._end_str = NULL
1875 * self._header_found = 0 # <<<<<<<<<<<<<<
1876 * # keys are tuples
1877 *
1878 */
1879 __pyx_v_self->_header_found = 0;
1880
1881 /* "breezy/bzr/_btree_serializer_pyx.pyx":120
1882 * cdef int _header_found
1883 *
1884 * def __init__(self, data, key_length, ref_list_length): # <<<<<<<<<<<<<<
1885 * self.data = data
1886 * self.key_length = key_length
1887 */
1888
1889 /* function exit code */
1890 __pyx_r = 0;
1891 goto __pyx_L0;
1892 __pyx_L1_error:;
1893 __Pyx_XDECREF(__pyx_t_2);
1894 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.BTreeLeafParser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1895 __pyx_r = -1;
1896 __pyx_L0:;
1897 __Pyx_RefNannyFinishContext();
1898 return __pyx_r;
1899 }
1900
1901 /* "breezy/bzr/_btree_serializer_pyx.pyx":130
1902 * # keys are tuples
1903 *
1904 * cdef extract_key(self, char * last): # <<<<<<<<<<<<<<
1905 * """Extract a key.
1906 *
1907 */
1908
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_extract_key(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser * __pyx_v_self,char * __pyx_v_last)1909 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_extract_key(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self, char *__pyx_v_last) {
1910 char *__pyx_v_temp_ptr;
1911 int __pyx_v_loop_counter;
1912 StaticTuple *__pyx_v_key = 0;
1913 PyObject *__pyx_v_failure_string = NULL;
1914 PyObject *__pyx_v_key_element = NULL;
1915 PyObject *__pyx_r = NULL;
1916 __Pyx_RefNannyDeclarations
1917 PyObject *__pyx_t_1 = NULL;
1918 int __pyx_t_2;
1919 int __pyx_t_3;
1920 PyObject *__pyx_t_4 = NULL;
1921 int __pyx_t_5;
1922 int __pyx_lineno = 0;
1923 const char *__pyx_filename = NULL;
1924 int __pyx_clineno = 0;
1925 __Pyx_RefNannySetupContext("extract_key", 0);
1926
1927 /* "breezy/bzr/_btree_serializer_pyx.pyx":140
1928 * cdef StaticTuple key
1929 *
1930 * key = StaticTuple_New(self.key_length) # <<<<<<<<<<<<<<
1931 * for loop_counter from 0 <= loop_counter < self.key_length:
1932 * # grab a key segment
1933 */
1934 __pyx_t_1 = ((PyObject *)StaticTuple_New(__pyx_v_self->key_length)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
1935 __Pyx_GOTREF(__pyx_t_1);
1936 __pyx_v_key = ((StaticTuple *)__pyx_t_1);
1937 __pyx_t_1 = 0;
1938
1939 /* "breezy/bzr/_btree_serializer_pyx.pyx":141
1940 *
1941 * key = StaticTuple_New(self.key_length)
1942 * for loop_counter from 0 <= loop_counter < self.key_length: # <<<<<<<<<<<<<<
1943 * # grab a key segment
1944 * temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
1945 */
1946 __pyx_t_2 = __pyx_v_self->key_length;
1947 for (__pyx_v_loop_counter = 0; __pyx_v_loop_counter < __pyx_t_2; __pyx_v_loop_counter++) {
1948
1949 /* "breezy/bzr/_btree_serializer_pyx.pyx":143
1950 * for loop_counter from 0 <= loop_counter < self.key_length:
1951 * # grab a key segment
1952 * temp_ptr = <char*>memchr(self._start, c'\0', last - self._start) # <<<<<<<<<<<<<<
1953 * if temp_ptr == NULL:
1954 * if loop_counter + 1 == self.key_length:
1955 */
1956 __pyx_v_temp_ptr = ((char *)memchr(__pyx_v_self->_start, '\x00', (__pyx_v_last - __pyx_v_self->_start)));
1957
1958 /* "breezy/bzr/_btree_serializer_pyx.pyx":144
1959 * # grab a key segment
1960 * temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
1961 * if temp_ptr == NULL: # <<<<<<<<<<<<<<
1962 * if loop_counter + 1 == self.key_length:
1963 * # capture to last
1964 */
1965 __pyx_t_3 = ((__pyx_v_temp_ptr == NULL) != 0);
1966 if (__pyx_t_3) {
1967
1968 /* "breezy/bzr/_btree_serializer_pyx.pyx":145
1969 * temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
1970 * if temp_ptr == NULL:
1971 * if loop_counter + 1 == self.key_length: # <<<<<<<<<<<<<<
1972 * # capture to last
1973 * temp_ptr = last
1974 */
1975 __pyx_t_3 = (((__pyx_v_loop_counter + 1) == __pyx_v_self->key_length) != 0);
1976 if (likely(__pyx_t_3)) {
1977
1978 /* "breezy/bzr/_btree_serializer_pyx.pyx":147
1979 * if loop_counter + 1 == self.key_length:
1980 * # capture to last
1981 * temp_ptr = last # <<<<<<<<<<<<<<
1982 * else:
1983 * # Invalid line
1984 */
1985 __pyx_v_temp_ptr = __pyx_v_last;
1986
1987 /* "breezy/bzr/_btree_serializer_pyx.pyx":145
1988 * temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
1989 * if temp_ptr == NULL:
1990 * if loop_counter + 1 == self.key_length: # <<<<<<<<<<<<<<
1991 * # capture to last
1992 * temp_ptr = last
1993 */
1994 goto __pyx_L6;
1995 }
1996
1997 /* "breezy/bzr/_btree_serializer_pyx.pyx":150
1998 * else:
1999 * # Invalid line
2000 * failure_string = ("invalid key, wanted segment from " + # <<<<<<<<<<<<<<
2001 * repr(safe_string_from_size(self._start,
2002 * last - self._start)))
2003 */
2004 /*else*/ {
2005
2006 /* "breezy/bzr/_btree_serializer_pyx.pyx":151
2007 * # Invalid line
2008 * failure_string = ("invalid key, wanted segment from " +
2009 * repr(safe_string_from_size(self._start, # <<<<<<<<<<<<<<
2010 * last - self._start)))
2011 * raise AssertionError(failure_string)
2012 */
2013 __pyx_t_1 = __pyx_f_6breezy_3bzr_12_str_helpers_safe_string_from_size(__pyx_v_self->_start, (__pyx_v_last - __pyx_v_self->_start)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
2014 __Pyx_GOTREF(__pyx_t_1);
2015 __pyx_t_4 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 151, __pyx_L1_error)
2016 __Pyx_GOTREF(__pyx_t_4);
2017 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2018
2019 /* "breezy/bzr/_btree_serializer_pyx.pyx":150
2020 * else:
2021 * # Invalid line
2022 * failure_string = ("invalid key, wanted segment from " + # <<<<<<<<<<<<<<
2023 * repr(safe_string_from_size(self._start,
2024 * last - self._start)))
2025 */
2026 __pyx_t_1 = __Pyx_PyUnicode_ConcatSafe(__pyx_kp_u_invalid_key_wanted_segment_from, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error)
2027 __Pyx_GOTREF(__pyx_t_1);
2028 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2029 __pyx_v_failure_string = ((PyObject*)__pyx_t_1);
2030 __pyx_t_1 = 0;
2031
2032 /* "breezy/bzr/_btree_serializer_pyx.pyx":153
2033 * repr(safe_string_from_size(self._start,
2034 * last - self._start)))
2035 * raise AssertionError(failure_string) # <<<<<<<<<<<<<<
2036 * # capture the key string
2037 * if (self.key_length == 1
2038 */
2039 __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AssertionError, __pyx_v_failure_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
2040 __Pyx_GOTREF(__pyx_t_1);
2041 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
2042 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2043 __PYX_ERR(0, 153, __pyx_L1_error)
2044 }
2045 __pyx_L6:;
2046
2047 /* "breezy/bzr/_btree_serializer_pyx.pyx":144
2048 * # grab a key segment
2049 * temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
2050 * if temp_ptr == NULL: # <<<<<<<<<<<<<<
2051 * if loop_counter + 1 == self.key_length:
2052 * # capture to last
2053 */
2054 }
2055
2056 /* "breezy/bzr/_btree_serializer_pyx.pyx":155
2057 * raise AssertionError(failure_string)
2058 * # capture the key string
2059 * if (self.key_length == 1 # <<<<<<<<<<<<<<
2060 * and (temp_ptr - self._start) == 45
2061 * and strncmp(self._start, b'sha1:', 5) == 0):
2062 */
2063 __pyx_t_5 = ((__pyx_v_self->key_length == 1) != 0);
2064 if (__pyx_t_5) {
2065 } else {
2066 __pyx_t_3 = __pyx_t_5;
2067 goto __pyx_L8_bool_binop_done;
2068 }
2069
2070 /* "breezy/bzr/_btree_serializer_pyx.pyx":156
2071 * # capture the key string
2072 * if (self.key_length == 1
2073 * and (temp_ptr - self._start) == 45 # <<<<<<<<<<<<<<
2074 * and strncmp(self._start, b'sha1:', 5) == 0):
2075 * key_element = safe_string_from_size(self._start,
2076 */
2077 __pyx_t_5 = (((__pyx_v_temp_ptr - __pyx_v_self->_start) == 45) != 0);
2078 if (__pyx_t_5) {
2079 } else {
2080 __pyx_t_3 = __pyx_t_5;
2081 goto __pyx_L8_bool_binop_done;
2082 }
2083
2084 /* "breezy/bzr/_btree_serializer_pyx.pyx":157
2085 * if (self.key_length == 1
2086 * and (temp_ptr - self._start) == 45
2087 * and strncmp(self._start, b'sha1:', 5) == 0): # <<<<<<<<<<<<<<
2088 * key_element = safe_string_from_size(self._start,
2089 * temp_ptr - self._start)
2090 */
2091 __pyx_t_5 = ((strncmp(__pyx_v_self->_start, ((char const *)"sha1:"), 5) == 0) != 0);
2092 __pyx_t_3 = __pyx_t_5;
2093 __pyx_L8_bool_binop_done:;
2094
2095 /* "breezy/bzr/_btree_serializer_pyx.pyx":155
2096 * raise AssertionError(failure_string)
2097 * # capture the key string
2098 * if (self.key_length == 1 # <<<<<<<<<<<<<<
2099 * and (temp_ptr - self._start) == 45
2100 * and strncmp(self._start, b'sha1:', 5) == 0):
2101 */
2102 if (__pyx_t_3) {
2103
2104 /* "breezy/bzr/_btree_serializer_pyx.pyx":158
2105 * and (temp_ptr - self._start) == 45
2106 * and strncmp(self._start, b'sha1:', 5) == 0):
2107 * key_element = safe_string_from_size(self._start, # <<<<<<<<<<<<<<
2108 * temp_ptr - self._start)
2109 * else:
2110 */
2111 __pyx_t_1 = __pyx_f_6breezy_3bzr_12_str_helpers_safe_string_from_size(__pyx_v_self->_start, (__pyx_v_temp_ptr - __pyx_v_self->_start)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
2112 __Pyx_GOTREF(__pyx_t_1);
2113 __Pyx_XDECREF_SET(__pyx_v_key_element, __pyx_t_1);
2114 __pyx_t_1 = 0;
2115
2116 /* "breezy/bzr/_btree_serializer_pyx.pyx":155
2117 * raise AssertionError(failure_string)
2118 * # capture the key string
2119 * if (self.key_length == 1 # <<<<<<<<<<<<<<
2120 * and (temp_ptr - self._start) == 45
2121 * and strncmp(self._start, b'sha1:', 5) == 0):
2122 */
2123 goto __pyx_L7;
2124 }
2125
2126 /* "breezy/bzr/_btree_serializer_pyx.pyx":161
2127 * temp_ptr - self._start)
2128 * else:
2129 * key_element = safe_interned_string_from_size(self._start, # <<<<<<<<<<<<<<
2130 * temp_ptr - self._start)
2131 * # advance our pointer
2132 */
2133 /*else*/ {
2134
2135 /* "breezy/bzr/_btree_serializer_pyx.pyx":162
2136 * else:
2137 * key_element = safe_interned_string_from_size(self._start,
2138 * temp_ptr - self._start) # <<<<<<<<<<<<<<
2139 * # advance our pointer
2140 * self._start = temp_ptr + 1
2141 */
2142 __pyx_t_1 = __pyx_f_6breezy_3bzr_12_str_helpers_safe_interned_string_from_size(__pyx_v_self->_start, (__pyx_v_temp_ptr - __pyx_v_self->_start)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
2143 __Pyx_GOTREF(__pyx_t_1);
2144 __Pyx_XDECREF_SET(__pyx_v_key_element, __pyx_t_1);
2145 __pyx_t_1 = 0;
2146 }
2147 __pyx_L7:;
2148
2149 /* "breezy/bzr/_btree_serializer_pyx.pyx":164
2150 * temp_ptr - self._start)
2151 * # advance our pointer
2152 * self._start = temp_ptr + 1 # <<<<<<<<<<<<<<
2153 * Py_INCREF(key_element)
2154 * StaticTuple_SET_ITEM(key, loop_counter, key_element)
2155 */
2156 __pyx_v_self->_start = (__pyx_v_temp_ptr + 1);
2157
2158 /* "breezy/bzr/_btree_serializer_pyx.pyx":165
2159 * # advance our pointer
2160 * self._start = temp_ptr + 1
2161 * Py_INCREF(key_element) # <<<<<<<<<<<<<<
2162 * StaticTuple_SET_ITEM(key, loop_counter, key_element)
2163 * key = StaticTuple_Intern(key)
2164 */
2165 Py_INCREF(__pyx_v_key_element);
2166
2167 /* "breezy/bzr/_btree_serializer_pyx.pyx":166
2168 * self._start = temp_ptr + 1
2169 * Py_INCREF(key_element)
2170 * StaticTuple_SET_ITEM(key, loop_counter, key_element) # <<<<<<<<<<<<<<
2171 * key = StaticTuple_Intern(key)
2172 * return key
2173 */
2174 StaticTuple_SET_ITEM(__pyx_v_key, __pyx_v_loop_counter, __pyx_v_key_element);
2175 }
2176
2177 /* "breezy/bzr/_btree_serializer_pyx.pyx":167
2178 * Py_INCREF(key_element)
2179 * StaticTuple_SET_ITEM(key, loop_counter, key_element)
2180 * key = StaticTuple_Intern(key) # <<<<<<<<<<<<<<
2181 * return key
2182 *
2183 */
2184 __pyx_t_1 = ((PyObject *)StaticTuple_Intern(__pyx_v_key)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error)
2185 __Pyx_GOTREF(__pyx_t_1);
2186 __Pyx_DECREF_SET(__pyx_v_key, ((StaticTuple *)__pyx_t_1));
2187 __pyx_t_1 = 0;
2188
2189 /* "breezy/bzr/_btree_serializer_pyx.pyx":168
2190 * StaticTuple_SET_ITEM(key, loop_counter, key_element)
2191 * key = StaticTuple_Intern(key)
2192 * return key # <<<<<<<<<<<<<<
2193 *
2194 * cdef int process_line(self) except -1:
2195 */
2196 __Pyx_XDECREF(__pyx_r);
2197 __Pyx_INCREF(((PyObject *)__pyx_v_key));
2198 __pyx_r = ((PyObject *)__pyx_v_key);
2199 goto __pyx_L0;
2200
2201 /* "breezy/bzr/_btree_serializer_pyx.pyx":130
2202 * # keys are tuples
2203 *
2204 * cdef extract_key(self, char * last): # <<<<<<<<<<<<<<
2205 * """Extract a key.
2206 *
2207 */
2208
2209 /* function exit code */
2210 __pyx_L1_error:;
2211 __Pyx_XDECREF(__pyx_t_1);
2212 __Pyx_XDECREF(__pyx_t_4);
2213 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.BTreeLeafParser.extract_key", __pyx_clineno, __pyx_lineno, __pyx_filename);
2214 __pyx_r = 0;
2215 __pyx_L0:;
2216 __Pyx_XDECREF((PyObject *)__pyx_v_key);
2217 __Pyx_XDECREF(__pyx_v_failure_string);
2218 __Pyx_XDECREF(__pyx_v_key_element);
2219 __Pyx_XGIVEREF(__pyx_r);
2220 __Pyx_RefNannyFinishContext();
2221 return __pyx_r;
2222 }
2223
2224 /* "breezy/bzr/_btree_serializer_pyx.pyx":170
2225 * return key
2226 *
2227 * cdef int process_line(self) except -1: # <<<<<<<<<<<<<<
2228 * """Process a line in the bytes."""
2229 * cdef char *last
2230 */
2231
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_process_line(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser * __pyx_v_self)2232 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_process_line(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self) {
2233 char *__pyx_v_last;
2234 char *__pyx_v_temp_ptr;
2235 char *__pyx_v_ref_ptr;
2236 char *__pyx_v_next_start;
2237 int __pyx_v_loop_counter;
2238 Py_ssize_t __pyx_v_str_len;
2239 PyObject *__pyx_v_key = NULL;
2240 PyObject *__pyx_v_value = NULL;
2241 StaticTuple *__pyx_v_ref_lists = NULL;
2242 PyObject *__pyx_v_ref_list = NULL;
2243 StaticTuple *__pyx_v_node_value = NULL;
2244 int __pyx_r;
2245 __Pyx_RefNannyDeclarations
2246 char *__pyx_t_1;
2247 int __pyx_t_2;
2248 PyObject *__pyx_t_3 = NULL;
2249 PyObject *__pyx_t_4 = NULL;
2250 int __pyx_t_5;
2251 int __pyx_t_6;
2252 PyObject *__pyx_t_7 = NULL;
2253 int __pyx_lineno = 0;
2254 const char *__pyx_filename = NULL;
2255 int __pyx_clineno = 0;
2256 __Pyx_RefNannySetupContext("process_line", 0);
2257
2258 /* "breezy/bzr/_btree_serializer_pyx.pyx":179
2259 * cdef Py_ssize_t str_len
2260 *
2261 * self._start = self._cur_str # <<<<<<<<<<<<<<
2262 * # Find the next newline
2263 * last = <char*>memchr(self._start, c'\n', self._end_str - self._start)
2264 */
2265 __pyx_t_1 = __pyx_v_self->_cur_str;
2266 __pyx_v_self->_start = __pyx_t_1;
2267
2268 /* "breezy/bzr/_btree_serializer_pyx.pyx":181
2269 * self._start = self._cur_str
2270 * # Find the next newline
2271 * last = <char*>memchr(self._start, c'\n', self._end_str - self._start) # <<<<<<<<<<<<<<
2272 * if last == NULL:
2273 * # Process until the end of the file
2274 */
2275 __pyx_v_last = ((char *)memchr(__pyx_v_self->_start, '\n', (__pyx_v_self->_end_str - __pyx_v_self->_start)));
2276
2277 /* "breezy/bzr/_btree_serializer_pyx.pyx":182
2278 * # Find the next newline
2279 * last = <char*>memchr(self._start, c'\n', self._end_str - self._start)
2280 * if last == NULL: # <<<<<<<<<<<<<<
2281 * # Process until the end of the file
2282 * last = self._end_str
2283 */
2284 __pyx_t_2 = ((__pyx_v_last == NULL) != 0);
2285 if (__pyx_t_2) {
2286
2287 /* "breezy/bzr/_btree_serializer_pyx.pyx":184
2288 * if last == NULL:
2289 * # Process until the end of the file
2290 * last = self._end_str # <<<<<<<<<<<<<<
2291 * self._cur_str = self._end_str
2292 * else:
2293 */
2294 __pyx_t_1 = __pyx_v_self->_end_str;
2295 __pyx_v_last = __pyx_t_1;
2296
2297 /* "breezy/bzr/_btree_serializer_pyx.pyx":185
2298 * # Process until the end of the file
2299 * last = self._end_str
2300 * self._cur_str = self._end_str # <<<<<<<<<<<<<<
2301 * else:
2302 * # And the next string is right after it
2303 */
2304 __pyx_t_1 = __pyx_v_self->_end_str;
2305 __pyx_v_self->_cur_str = __pyx_t_1;
2306
2307 /* "breezy/bzr/_btree_serializer_pyx.pyx":182
2308 * # Find the next newline
2309 * last = <char*>memchr(self._start, c'\n', self._end_str - self._start)
2310 * if last == NULL: # <<<<<<<<<<<<<<
2311 * # Process until the end of the file
2312 * last = self._end_str
2313 */
2314 goto __pyx_L3;
2315 }
2316
2317 /* "breezy/bzr/_btree_serializer_pyx.pyx":188
2318 * else:
2319 * # And the next string is right after it
2320 * self._cur_str = last + 1 # <<<<<<<<<<<<<<
2321 * # The last character is right before the '\n'
2322 *
2323 */
2324 /*else*/ {
2325 __pyx_v_self->_cur_str = (__pyx_v_last + 1);
2326 }
2327 __pyx_L3:;
2328
2329 /* "breezy/bzr/_btree_serializer_pyx.pyx":191
2330 * # The last character is right before the '\n'
2331 *
2332 * if last == self._start: # <<<<<<<<<<<<<<
2333 * # parsed it all.
2334 * return 0
2335 */
2336 __pyx_t_2 = ((__pyx_v_last == __pyx_v_self->_start) != 0);
2337 if (__pyx_t_2) {
2338
2339 /* "breezy/bzr/_btree_serializer_pyx.pyx":193
2340 * if last == self._start:
2341 * # parsed it all.
2342 * return 0 # <<<<<<<<<<<<<<
2343 * if last < self._start:
2344 * # Unexpected error condition - fail
2345 */
2346 __pyx_r = 0;
2347 goto __pyx_L0;
2348
2349 /* "breezy/bzr/_btree_serializer_pyx.pyx":191
2350 * # The last character is right before the '\n'
2351 *
2352 * if last == self._start: # <<<<<<<<<<<<<<
2353 * # parsed it all.
2354 * return 0
2355 */
2356 }
2357
2358 /* "breezy/bzr/_btree_serializer_pyx.pyx":194
2359 * # parsed it all.
2360 * return 0
2361 * if last < self._start: # <<<<<<<<<<<<<<
2362 * # Unexpected error condition - fail
2363 * raise AssertionError("last < self._start")
2364 */
2365 __pyx_t_2 = ((__pyx_v_last < __pyx_v_self->_start) != 0);
2366 if (unlikely(__pyx_t_2)) {
2367
2368 /* "breezy/bzr/_btree_serializer_pyx.pyx":196
2369 * if last < self._start:
2370 * # Unexpected error condition - fail
2371 * raise AssertionError("last < self._start") # <<<<<<<<<<<<<<
2372 * if 0 == self._header_found:
2373 * # The first line in a leaf node is the header "type=leaf\n"
2374 */
2375 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error)
2376 __Pyx_GOTREF(__pyx_t_3);
2377 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2378 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2379 __PYX_ERR(0, 196, __pyx_L1_error)
2380
2381 /* "breezy/bzr/_btree_serializer_pyx.pyx":194
2382 * # parsed it all.
2383 * return 0
2384 * if last < self._start: # <<<<<<<<<<<<<<
2385 * # Unexpected error condition - fail
2386 * raise AssertionError("last < self._start")
2387 */
2388 }
2389
2390 /* "breezy/bzr/_btree_serializer_pyx.pyx":197
2391 * # Unexpected error condition - fail
2392 * raise AssertionError("last < self._start")
2393 * if 0 == self._header_found: # <<<<<<<<<<<<<<
2394 * # The first line in a leaf node is the header "type=leaf\n"
2395 * if strncmp(b"type=leaf", self._start, last - self._start) == 0:
2396 */
2397 __pyx_t_2 = ((0 == __pyx_v_self->_header_found) != 0);
2398 if (__pyx_t_2) {
2399
2400 /* "breezy/bzr/_btree_serializer_pyx.pyx":199
2401 * if 0 == self._header_found:
2402 * # The first line in a leaf node is the header "type=leaf\n"
2403 * if strncmp(b"type=leaf", self._start, last - self._start) == 0: # <<<<<<<<<<<<<<
2404 * self._header_found = 1
2405 * return 0
2406 */
2407 __pyx_t_2 = ((strncmp(((char const *)"type=leaf"), __pyx_v_self->_start, (__pyx_v_last - __pyx_v_self->_start)) == 0) != 0);
2408 if (likely(__pyx_t_2)) {
2409
2410 /* "breezy/bzr/_btree_serializer_pyx.pyx":200
2411 * # The first line in a leaf node is the header "type=leaf\n"
2412 * if strncmp(b"type=leaf", self._start, last - self._start) == 0:
2413 * self._header_found = 1 # <<<<<<<<<<<<<<
2414 * return 0
2415 * else:
2416 */
2417 __pyx_v_self->_header_found = 1;
2418
2419 /* "breezy/bzr/_btree_serializer_pyx.pyx":201
2420 * if strncmp(b"type=leaf", self._start, last - self._start) == 0:
2421 * self._header_found = 1
2422 * return 0 # <<<<<<<<<<<<<<
2423 * else:
2424 * raise AssertionError('Node did not start with "type=leaf": %r'
2425 */
2426 __pyx_r = 0;
2427 goto __pyx_L0;
2428
2429 /* "breezy/bzr/_btree_serializer_pyx.pyx":199
2430 * if 0 == self._header_found:
2431 * # The first line in a leaf node is the header "type=leaf\n"
2432 * if strncmp(b"type=leaf", self._start, last - self._start) == 0: # <<<<<<<<<<<<<<
2433 * self._header_found = 1
2434 * return 0
2435 */
2436 }
2437
2438 /* "breezy/bzr/_btree_serializer_pyx.pyx":203
2439 * return 0
2440 * else:
2441 * raise AssertionError('Node did not start with "type=leaf": %r' # <<<<<<<<<<<<<<
2442 * % (safe_string_from_size(self._start, last - self._start)))
2443 *
2444 */
2445 /*else*/ {
2446
2447 /* "breezy/bzr/_btree_serializer_pyx.pyx":204
2448 * else:
2449 * raise AssertionError('Node did not start with "type=leaf": %r'
2450 * % (safe_string_from_size(self._start, last - self._start))) # <<<<<<<<<<<<<<
2451 *
2452 * key = self.extract_key(last)
2453 */
2454 __pyx_t_3 = __pyx_f_6breezy_3bzr_12_str_helpers_safe_string_from_size(__pyx_v_self->_start, (__pyx_v_last - __pyx_v_self->_start)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
2455 __Pyx_GOTREF(__pyx_t_3);
2456 __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Node_did_not_start_with_type_lea, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L1_error)
2457 __Pyx_GOTREF(__pyx_t_4);
2458 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2459
2460 /* "breezy/bzr/_btree_serializer_pyx.pyx":203
2461 * return 0
2462 * else:
2463 * raise AssertionError('Node did not start with "type=leaf": %r' # <<<<<<<<<<<<<<
2464 * % (safe_string_from_size(self._start, last - self._start)))
2465 *
2466 */
2467 __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AssertionError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error)
2468 __Pyx_GOTREF(__pyx_t_3);
2469 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2470 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2471 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2472 __PYX_ERR(0, 203, __pyx_L1_error)
2473 }
2474
2475 /* "breezy/bzr/_btree_serializer_pyx.pyx":197
2476 * # Unexpected error condition - fail
2477 * raise AssertionError("last < self._start")
2478 * if 0 == self._header_found: # <<<<<<<<<<<<<<
2479 * # The first line in a leaf node is the header "type=leaf\n"
2480 * if strncmp(b"type=leaf", self._start, last - self._start) == 0:
2481 */
2482 }
2483
2484 /* "breezy/bzr/_btree_serializer_pyx.pyx":206
2485 * % (safe_string_from_size(self._start, last - self._start)))
2486 *
2487 * key = self.extract_key(last) # <<<<<<<<<<<<<<
2488 * # find the value area
2489 * temp_ptr = <char*>_my_memrchr(self._start, c'\0', last - self._start)
2490 */
2491 __pyx_t_3 = ((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self->__pyx_vtab)->extract_key(__pyx_v_self, __pyx_v_last); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 206, __pyx_L1_error)
2492 __Pyx_GOTREF(__pyx_t_3);
2493 __pyx_v_key = __pyx_t_3;
2494 __pyx_t_3 = 0;
2495
2496 /* "breezy/bzr/_btree_serializer_pyx.pyx":208
2497 * key = self.extract_key(last)
2498 * # find the value area
2499 * temp_ptr = <char*>_my_memrchr(self._start, c'\0', last - self._start) # <<<<<<<<<<<<<<
2500 * if temp_ptr == NULL:
2501 * # Invalid line
2502 */
2503 __pyx_v_temp_ptr = ((char *)__pyx_f_6breezy_3bzr_12_str_helpers__my_memrchr(__pyx_v_self->_start, '\x00', (__pyx_v_last - __pyx_v_self->_start)));
2504
2505 /* "breezy/bzr/_btree_serializer_pyx.pyx":209
2506 * # find the value area
2507 * temp_ptr = <char*>_my_memrchr(self._start, c'\0', last - self._start)
2508 * if temp_ptr == NULL: # <<<<<<<<<<<<<<
2509 * # Invalid line
2510 * raise AssertionError("Failed to find the value area")
2511 */
2512 __pyx_t_2 = ((__pyx_v_temp_ptr == NULL) != 0);
2513 if (unlikely(__pyx_t_2)) {
2514
2515 /* "breezy/bzr/_btree_serializer_pyx.pyx":211
2516 * if temp_ptr == NULL:
2517 * # Invalid line
2518 * raise AssertionError("Failed to find the value area") # <<<<<<<<<<<<<<
2519 * else:
2520 * # Because of how conversions were done, we ended up with *lots* of
2521 */
2522 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error)
2523 __Pyx_GOTREF(__pyx_t_3);
2524 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2525 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2526 __PYX_ERR(0, 211, __pyx_L1_error)
2527
2528 /* "breezy/bzr/_btree_serializer_pyx.pyx":209
2529 * # find the value area
2530 * temp_ptr = <char*>_my_memrchr(self._start, c'\0', last - self._start)
2531 * if temp_ptr == NULL: # <<<<<<<<<<<<<<
2532 * # Invalid line
2533 * raise AssertionError("Failed to find the value area")
2534 */
2535 }
2536
2537 /* "breezy/bzr/_btree_serializer_pyx.pyx":219
2538 * # something like '12607215 328306 0 0', which ends up consuming 1MB
2539 * # of memory, just for those strings.
2540 * str_len = last - temp_ptr - 1 # <<<<<<<<<<<<<<
2541 * if (str_len > 4
2542 * and strncmp(b" 0 0", last - 4, 4) == 0):
2543 */
2544 /*else*/ {
2545 __pyx_v_str_len = ((__pyx_v_last - __pyx_v_temp_ptr) - 1);
2546
2547 /* "breezy/bzr/_btree_serializer_pyx.pyx":220
2548 * # of memory, just for those strings.
2549 * str_len = last - temp_ptr - 1
2550 * if (str_len > 4 # <<<<<<<<<<<<<<
2551 * and strncmp(b" 0 0", last - 4, 4) == 0):
2552 * # This drops peak mem for bzr.dev from 87.4MB => 86.2MB
2553 */
2554 __pyx_t_5 = ((__pyx_v_str_len > 4) != 0);
2555 if (__pyx_t_5) {
2556 } else {
2557 __pyx_t_2 = __pyx_t_5;
2558 goto __pyx_L10_bool_binop_done;
2559 }
2560
2561 /* "breezy/bzr/_btree_serializer_pyx.pyx":221
2562 * str_len = last - temp_ptr - 1
2563 * if (str_len > 4
2564 * and strncmp(b" 0 0", last - 4, 4) == 0): # <<<<<<<<<<<<<<
2565 * # This drops peak mem for bzr.dev from 87.4MB => 86.2MB
2566 * # For Launchpad 236MB => 232MB
2567 */
2568 __pyx_t_5 = ((strncmp(((char const *)" 0 0"), (__pyx_v_last - 4), 4) == 0) != 0);
2569 __pyx_t_2 = __pyx_t_5;
2570 __pyx_L10_bool_binop_done:;
2571
2572 /* "breezy/bzr/_btree_serializer_pyx.pyx":220
2573 * # of memory, just for those strings.
2574 * str_len = last - temp_ptr - 1
2575 * if (str_len > 4 # <<<<<<<<<<<<<<
2576 * and strncmp(b" 0 0", last - 4, 4) == 0):
2577 * # This drops peak mem for bzr.dev from 87.4MB => 86.2MB
2578 */
2579 if (__pyx_t_2) {
2580
2581 /* "breezy/bzr/_btree_serializer_pyx.pyx":224
2582 * # This drops peak mem for bzr.dev from 87.4MB => 86.2MB
2583 * # For Launchpad 236MB => 232MB
2584 * value = safe_interned_string_from_size(temp_ptr + 1, str_len) # <<<<<<<<<<<<<<
2585 * else:
2586 * value = safe_string_from_size(temp_ptr + 1, str_len)
2587 */
2588 __pyx_t_3 = __pyx_f_6breezy_3bzr_12_str_helpers_safe_interned_string_from_size((__pyx_v_temp_ptr + 1), __pyx_v_str_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error)
2589 __Pyx_GOTREF(__pyx_t_3);
2590 __pyx_v_value = __pyx_t_3;
2591 __pyx_t_3 = 0;
2592
2593 /* "breezy/bzr/_btree_serializer_pyx.pyx":220
2594 * # of memory, just for those strings.
2595 * str_len = last - temp_ptr - 1
2596 * if (str_len > 4 # <<<<<<<<<<<<<<
2597 * and strncmp(b" 0 0", last - 4, 4) == 0):
2598 * # This drops peak mem for bzr.dev from 87.4MB => 86.2MB
2599 */
2600 goto __pyx_L9;
2601 }
2602
2603 /* "breezy/bzr/_btree_serializer_pyx.pyx":226
2604 * value = safe_interned_string_from_size(temp_ptr + 1, str_len)
2605 * else:
2606 * value = safe_string_from_size(temp_ptr + 1, str_len) # <<<<<<<<<<<<<<
2607 * # shrink the references end point
2608 * last = temp_ptr
2609 */
2610 /*else*/ {
2611 __pyx_t_3 = __pyx_f_6breezy_3bzr_12_str_helpers_safe_string_from_size((__pyx_v_temp_ptr + 1), __pyx_v_str_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error)
2612 __Pyx_GOTREF(__pyx_t_3);
2613 __pyx_v_value = __pyx_t_3;
2614 __pyx_t_3 = 0;
2615 }
2616 __pyx_L9:;
2617
2618 /* "breezy/bzr/_btree_serializer_pyx.pyx":228
2619 * value = safe_string_from_size(temp_ptr + 1, str_len)
2620 * # shrink the references end point
2621 * last = temp_ptr # <<<<<<<<<<<<<<
2622 *
2623 * if self.ref_list_length:
2624 */
2625 __pyx_v_last = __pyx_v_temp_ptr;
2626 }
2627
2628 /* "breezy/bzr/_btree_serializer_pyx.pyx":230
2629 * last = temp_ptr
2630 *
2631 * if self.ref_list_length: # <<<<<<<<<<<<<<
2632 * ref_lists = StaticTuple_New(self.ref_list_length)
2633 * loop_counter = 0
2634 */
2635 __pyx_t_2 = (__pyx_v_self->ref_list_length != 0);
2636 if (__pyx_t_2) {
2637
2638 /* "breezy/bzr/_btree_serializer_pyx.pyx":231
2639 *
2640 * if self.ref_list_length:
2641 * ref_lists = StaticTuple_New(self.ref_list_length) # <<<<<<<<<<<<<<
2642 * loop_counter = 0
2643 * while loop_counter < self.ref_list_length:
2644 */
2645 __pyx_t_3 = ((PyObject *)StaticTuple_New(__pyx_v_self->ref_list_length)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 231, __pyx_L1_error)
2646 __Pyx_GOTREF(__pyx_t_3);
2647 __pyx_v_ref_lists = ((StaticTuple *)__pyx_t_3);
2648 __pyx_t_3 = 0;
2649
2650 /* "breezy/bzr/_btree_serializer_pyx.pyx":232
2651 * if self.ref_list_length:
2652 * ref_lists = StaticTuple_New(self.ref_list_length)
2653 * loop_counter = 0 # <<<<<<<<<<<<<<
2654 * while loop_counter < self.ref_list_length:
2655 * ref_list = []
2656 */
2657 __pyx_v_loop_counter = 0;
2658
2659 /* "breezy/bzr/_btree_serializer_pyx.pyx":233
2660 * ref_lists = StaticTuple_New(self.ref_list_length)
2661 * loop_counter = 0
2662 * while loop_counter < self.ref_list_length: # <<<<<<<<<<<<<<
2663 * ref_list = []
2664 * # extract a reference list
2665 */
2666 while (1) {
2667 __pyx_t_2 = ((__pyx_v_loop_counter < __pyx_v_self->ref_list_length) != 0);
2668 if (!__pyx_t_2) break;
2669
2670 /* "breezy/bzr/_btree_serializer_pyx.pyx":234
2671 * loop_counter = 0
2672 * while loop_counter < self.ref_list_length:
2673 * ref_list = [] # <<<<<<<<<<<<<<
2674 * # extract a reference list
2675 * loop_counter = loop_counter + 1
2676 */
2677 __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
2678 __Pyx_GOTREF(__pyx_t_3);
2679 __Pyx_XDECREF_SET(__pyx_v_ref_list, __pyx_t_3);
2680 __pyx_t_3 = 0;
2681
2682 /* "breezy/bzr/_btree_serializer_pyx.pyx":236
2683 * ref_list = []
2684 * # extract a reference list
2685 * loop_counter = loop_counter + 1 # <<<<<<<<<<<<<<
2686 * if last < self._start:
2687 * raise AssertionError("last < self._start")
2688 */
2689 __pyx_v_loop_counter = (__pyx_v_loop_counter + 1);
2690
2691 /* "breezy/bzr/_btree_serializer_pyx.pyx":237
2692 * # extract a reference list
2693 * loop_counter = loop_counter + 1
2694 * if last < self._start: # <<<<<<<<<<<<<<
2695 * raise AssertionError("last < self._start")
2696 * # find the next reference list end point:
2697 */
2698 __pyx_t_2 = ((__pyx_v_last < __pyx_v_self->_start) != 0);
2699 if (unlikely(__pyx_t_2)) {
2700
2701 /* "breezy/bzr/_btree_serializer_pyx.pyx":238
2702 * loop_counter = loop_counter + 1
2703 * if last < self._start:
2704 * raise AssertionError("last < self._start") # <<<<<<<<<<<<<<
2705 * # find the next reference list end point:
2706 * temp_ptr = <char*>memchr(self._start, c'\t', last - self._start)
2707 */
2708 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error)
2709 __Pyx_GOTREF(__pyx_t_3);
2710 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2711 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2712 __PYX_ERR(0, 238, __pyx_L1_error)
2713
2714 /* "breezy/bzr/_btree_serializer_pyx.pyx":237
2715 * # extract a reference list
2716 * loop_counter = loop_counter + 1
2717 * if last < self._start: # <<<<<<<<<<<<<<
2718 * raise AssertionError("last < self._start")
2719 * # find the next reference list end point:
2720 */
2721 }
2722
2723 /* "breezy/bzr/_btree_serializer_pyx.pyx":240
2724 * raise AssertionError("last < self._start")
2725 * # find the next reference list end point:
2726 * temp_ptr = <char*>memchr(self._start, c'\t', last - self._start) # <<<<<<<<<<<<<<
2727 * if temp_ptr == NULL:
2728 * # Only valid for the last list
2729 */
2730 __pyx_v_temp_ptr = ((char *)memchr(__pyx_v_self->_start, '\t', (__pyx_v_last - __pyx_v_self->_start)));
2731
2732 /* "breezy/bzr/_btree_serializer_pyx.pyx":241
2733 * # find the next reference list end point:
2734 * temp_ptr = <char*>memchr(self._start, c'\t', last - self._start)
2735 * if temp_ptr == NULL: # <<<<<<<<<<<<<<
2736 * # Only valid for the last list
2737 * if loop_counter != self.ref_list_length:
2738 */
2739 __pyx_t_2 = ((__pyx_v_temp_ptr == NULL) != 0);
2740 if (__pyx_t_2) {
2741
2742 /* "breezy/bzr/_btree_serializer_pyx.pyx":243
2743 * if temp_ptr == NULL:
2744 * # Only valid for the last list
2745 * if loop_counter != self.ref_list_length: # <<<<<<<<<<<<<<
2746 * # Invalid line
2747 * raise AssertionError(
2748 */
2749 __pyx_t_2 = ((__pyx_v_loop_counter != __pyx_v_self->ref_list_length) != 0);
2750 if (unlikely(__pyx_t_2)) {
2751
2752 /* "breezy/bzr/_btree_serializer_pyx.pyx":245
2753 * if loop_counter != self.ref_list_length:
2754 * # Invalid line
2755 * raise AssertionError( # <<<<<<<<<<<<<<
2756 * "invalid key, loop_counter != self.ref_list_length")
2757 * else:
2758 */
2759 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L1_error)
2760 __Pyx_GOTREF(__pyx_t_3);
2761 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2762 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2763 __PYX_ERR(0, 245, __pyx_L1_error)
2764
2765 /* "breezy/bzr/_btree_serializer_pyx.pyx":243
2766 * if temp_ptr == NULL:
2767 * # Only valid for the last list
2768 * if loop_counter != self.ref_list_length: # <<<<<<<<<<<<<<
2769 * # Invalid line
2770 * raise AssertionError(
2771 */
2772 }
2773
2774 /* "breezy/bzr/_btree_serializer_pyx.pyx":249
2775 * else:
2776 * # scan to the end of the ref list area
2777 * ref_ptr = last # <<<<<<<<<<<<<<
2778 * next_start = last
2779 * else:
2780 */
2781 /*else*/ {
2782 __pyx_v_ref_ptr = __pyx_v_last;
2783
2784 /* "breezy/bzr/_btree_serializer_pyx.pyx":250
2785 * # scan to the end of the ref list area
2786 * ref_ptr = last
2787 * next_start = last # <<<<<<<<<<<<<<
2788 * else:
2789 * # scan to the end of this ref list
2790 */
2791 __pyx_v_next_start = __pyx_v_last;
2792 }
2793
2794 /* "breezy/bzr/_btree_serializer_pyx.pyx":241
2795 * # find the next reference list end point:
2796 * temp_ptr = <char*>memchr(self._start, c'\t', last - self._start)
2797 * if temp_ptr == NULL: # <<<<<<<<<<<<<<
2798 * # Only valid for the last list
2799 * if loop_counter != self.ref_list_length:
2800 */
2801 goto __pyx_L16;
2802 }
2803
2804 /* "breezy/bzr/_btree_serializer_pyx.pyx":253
2805 * else:
2806 * # scan to the end of this ref list
2807 * ref_ptr = temp_ptr # <<<<<<<<<<<<<<
2808 * next_start = temp_ptr + 1
2809 * # Now, there may be multiple keys in the ref list.
2810 */
2811 /*else*/ {
2812 __pyx_v_ref_ptr = __pyx_v_temp_ptr;
2813
2814 /* "breezy/bzr/_btree_serializer_pyx.pyx":254
2815 * # scan to the end of this ref list
2816 * ref_ptr = temp_ptr
2817 * next_start = temp_ptr + 1 # <<<<<<<<<<<<<<
2818 * # Now, there may be multiple keys in the ref list.
2819 * while self._start < ref_ptr:
2820 */
2821 __pyx_v_next_start = (__pyx_v_temp_ptr + 1);
2822 }
2823 __pyx_L16:;
2824
2825 /* "breezy/bzr/_btree_serializer_pyx.pyx":256
2826 * next_start = temp_ptr + 1
2827 * # Now, there may be multiple keys in the ref list.
2828 * while self._start < ref_ptr: # <<<<<<<<<<<<<<
2829 * # loop finding keys and extracting them
2830 * temp_ptr = <char*>memchr(self._start, c'\r',
2831 */
2832 while (1) {
2833 __pyx_t_2 = ((__pyx_v_self->_start < __pyx_v_ref_ptr) != 0);
2834 if (!__pyx_t_2) break;
2835
2836 /* "breezy/bzr/_btree_serializer_pyx.pyx":258
2837 * while self._start < ref_ptr:
2838 * # loop finding keys and extracting them
2839 * temp_ptr = <char*>memchr(self._start, c'\r', # <<<<<<<<<<<<<<
2840 * ref_ptr - self._start)
2841 * if temp_ptr == NULL:
2842 */
2843 __pyx_v_temp_ptr = ((char *)memchr(__pyx_v_self->_start, '\r', (__pyx_v_ref_ptr - __pyx_v_self->_start)));
2844
2845 /* "breezy/bzr/_btree_serializer_pyx.pyx":260
2846 * temp_ptr = <char*>memchr(self._start, c'\r',
2847 * ref_ptr - self._start)
2848 * if temp_ptr == NULL: # <<<<<<<<<<<<<<
2849 * # key runs to the end
2850 * temp_ptr = ref_ptr
2851 */
2852 __pyx_t_2 = ((__pyx_v_temp_ptr == NULL) != 0);
2853 if (__pyx_t_2) {
2854
2855 /* "breezy/bzr/_btree_serializer_pyx.pyx":262
2856 * if temp_ptr == NULL:
2857 * # key runs to the end
2858 * temp_ptr = ref_ptr # <<<<<<<<<<<<<<
2859 *
2860 * PyList_Append(ref_list, self.extract_key(temp_ptr))
2861 */
2862 __pyx_v_temp_ptr = __pyx_v_ref_ptr;
2863
2864 /* "breezy/bzr/_btree_serializer_pyx.pyx":260
2865 * temp_ptr = <char*>memchr(self._start, c'\r',
2866 * ref_ptr - self._start)
2867 * if temp_ptr == NULL: # <<<<<<<<<<<<<<
2868 * # key runs to the end
2869 * temp_ptr = ref_ptr
2870 */
2871 }
2872
2873 /* "breezy/bzr/_btree_serializer_pyx.pyx":264
2874 * temp_ptr = ref_ptr
2875 *
2876 * PyList_Append(ref_list, self.extract_key(temp_ptr)) # <<<<<<<<<<<<<<
2877 * ref_list = StaticTuple_Intern(StaticTuple(*ref_list))
2878 * Py_INCREF(ref_list)
2879 */
2880 __pyx_t_3 = ((struct __pyx_vtabstruct_6breezy_3bzr_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_ERR(0, 264, __pyx_L1_error)
2881 __Pyx_GOTREF(__pyx_t_3);
2882 __pyx_t_6 = PyList_Append(__pyx_v_ref_list, __pyx_t_3); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 264, __pyx_L1_error)
2883 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2884 }
2885
2886 /* "breezy/bzr/_btree_serializer_pyx.pyx":265
2887 *
2888 * PyList_Append(ref_list, self.extract_key(temp_ptr))
2889 * ref_list = StaticTuple_Intern(StaticTuple(*ref_list)) # <<<<<<<<<<<<<<
2890 * Py_INCREF(ref_list)
2891 * StaticTuple_SET_ITEM(ref_lists, loop_counter - 1, ref_list)
2892 */
2893 __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_ref_list); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
2894 __Pyx_GOTREF(__pyx_t_3);
2895 __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6breezy_15_static_tuple_c_StaticTuple), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 265, __pyx_L1_error)
2896 __Pyx_GOTREF(__pyx_t_4);
2897 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2898 __pyx_t_3 = ((PyObject *)StaticTuple_Intern(((StaticTuple *)__pyx_t_4))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
2899 __Pyx_GOTREF(__pyx_t_3);
2900 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2901 __Pyx_DECREF_SET(__pyx_v_ref_list, __pyx_t_3);
2902 __pyx_t_3 = 0;
2903
2904 /* "breezy/bzr/_btree_serializer_pyx.pyx":266
2905 * PyList_Append(ref_list, self.extract_key(temp_ptr))
2906 * ref_list = StaticTuple_Intern(StaticTuple(*ref_list))
2907 * Py_INCREF(ref_list) # <<<<<<<<<<<<<<
2908 * StaticTuple_SET_ITEM(ref_lists, loop_counter - 1, ref_list)
2909 * # prepare for the next reference list
2910 */
2911 Py_INCREF(__pyx_v_ref_list);
2912
2913 /* "breezy/bzr/_btree_serializer_pyx.pyx":267
2914 * ref_list = StaticTuple_Intern(StaticTuple(*ref_list))
2915 * Py_INCREF(ref_list)
2916 * StaticTuple_SET_ITEM(ref_lists, loop_counter - 1, ref_list) # <<<<<<<<<<<<<<
2917 * # prepare for the next reference list
2918 * self._start = next_start
2919 */
2920 StaticTuple_SET_ITEM(__pyx_v_ref_lists, (__pyx_v_loop_counter - 1), __pyx_v_ref_list);
2921
2922 /* "breezy/bzr/_btree_serializer_pyx.pyx":269
2923 * StaticTuple_SET_ITEM(ref_lists, loop_counter - 1, ref_list)
2924 * # prepare for the next reference list
2925 * self._start = next_start # <<<<<<<<<<<<<<
2926 * node_value = StaticTuple(value, ref_lists)
2927 * else:
2928 */
2929 __pyx_v_self->_start = __pyx_v_next_start;
2930 }
2931
2932 /* "breezy/bzr/_btree_serializer_pyx.pyx":270
2933 * # prepare for the next reference list
2934 * self._start = next_start
2935 * node_value = StaticTuple(value, ref_lists) # <<<<<<<<<<<<<<
2936 * else:
2937 * if last != self._start:
2938 */
2939 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error)
2940 __Pyx_GOTREF(__pyx_t_3);
2941 __Pyx_INCREF(__pyx_v_value);
2942 __Pyx_GIVEREF(__pyx_v_value);
2943 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value);
2944 __Pyx_INCREF(((PyObject *)__pyx_v_ref_lists));
2945 __Pyx_GIVEREF(((PyObject *)__pyx_v_ref_lists));
2946 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_ref_lists));
2947 __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6breezy_15_static_tuple_c_StaticTuple), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 270, __pyx_L1_error)
2948 __Pyx_GOTREF(__pyx_t_4);
2949 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2950 __pyx_v_node_value = ((StaticTuple *)__pyx_t_4);
2951 __pyx_t_4 = 0;
2952
2953 /* "breezy/bzr/_btree_serializer_pyx.pyx":230
2954 * last = temp_ptr
2955 *
2956 * if self.ref_list_length: # <<<<<<<<<<<<<<
2957 * ref_lists = StaticTuple_New(self.ref_list_length)
2958 * loop_counter = 0
2959 */
2960 goto __pyx_L12;
2961 }
2962
2963 /* "breezy/bzr/_btree_serializer_pyx.pyx":272
2964 * node_value = StaticTuple(value, ref_lists)
2965 * else:
2966 * if last != self._start: # <<<<<<<<<<<<<<
2967 * # unexpected reference data present
2968 * raise AssertionError("unexpected reference data present")
2969 */
2970 /*else*/ {
2971 __pyx_t_2 = ((__pyx_v_last != __pyx_v_self->_start) != 0);
2972 if (unlikely(__pyx_t_2)) {
2973
2974 /* "breezy/bzr/_btree_serializer_pyx.pyx":274
2975 * if last != self._start:
2976 * # unexpected reference data present
2977 * raise AssertionError("unexpected reference data present") # <<<<<<<<<<<<<<
2978 * node_value = StaticTuple(value, StaticTuple())
2979 * PyList_Append(self.keys, StaticTuple(key, node_value))
2980 */
2981 __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
2982 __Pyx_GOTREF(__pyx_t_4);
2983 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
2984 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2985 __PYX_ERR(0, 274, __pyx_L1_error)
2986
2987 /* "breezy/bzr/_btree_serializer_pyx.pyx":272
2988 * node_value = StaticTuple(value, ref_lists)
2989 * else:
2990 * if last != self._start: # <<<<<<<<<<<<<<
2991 * # unexpected reference data present
2992 * raise AssertionError("unexpected reference data present")
2993 */
2994 }
2995
2996 /* "breezy/bzr/_btree_serializer_pyx.pyx":275
2997 * # unexpected reference data present
2998 * raise AssertionError("unexpected reference data present")
2999 * node_value = StaticTuple(value, StaticTuple()) # <<<<<<<<<<<<<<
3000 * PyList_Append(self.keys, StaticTuple(key, node_value))
3001 * return 0
3002 */
3003 __pyx_t_4 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6breezy_15_static_tuple_c_StaticTuple)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 275, __pyx_L1_error)
3004 __Pyx_GOTREF(__pyx_t_4);
3005 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
3006 __Pyx_GOTREF(__pyx_t_3);
3007 __Pyx_INCREF(__pyx_v_value);
3008 __Pyx_GIVEREF(__pyx_v_value);
3009 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value);
3010 __Pyx_GIVEREF(__pyx_t_4);
3011 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
3012 __pyx_t_4 = 0;
3013 __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6breezy_15_static_tuple_c_StaticTuple), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 275, __pyx_L1_error)
3014 __Pyx_GOTREF(__pyx_t_4);
3015 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3016 __pyx_v_node_value = ((StaticTuple *)__pyx_t_4);
3017 __pyx_t_4 = 0;
3018 }
3019 __pyx_L12:;
3020
3021 /* "breezy/bzr/_btree_serializer_pyx.pyx":276
3022 * raise AssertionError("unexpected reference data present")
3023 * node_value = StaticTuple(value, StaticTuple())
3024 * PyList_Append(self.keys, StaticTuple(key, node_value)) # <<<<<<<<<<<<<<
3025 * return 0
3026 *
3027 */
3028 __pyx_t_4 = __pyx_v_self->keys;
3029 __Pyx_INCREF(__pyx_t_4);
3030 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
3031 __Pyx_GOTREF(__pyx_t_3);
3032 __Pyx_INCREF(__pyx_v_key);
3033 __Pyx_GIVEREF(__pyx_v_key);
3034 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_key);
3035 __Pyx_INCREF(((PyObject *)__pyx_v_node_value));
3036 __Pyx_GIVEREF(((PyObject *)__pyx_v_node_value));
3037 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_node_value));
3038 __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6breezy_15_static_tuple_c_StaticTuple), __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 276, __pyx_L1_error)
3039 __Pyx_GOTREF(__pyx_t_7);
3040 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3041 __pyx_t_6 = PyList_Append(__pyx_t_4, __pyx_t_7); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 276, __pyx_L1_error)
3042 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3043 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3044
3045 /* "breezy/bzr/_btree_serializer_pyx.pyx":277
3046 * node_value = StaticTuple(value, StaticTuple())
3047 * PyList_Append(self.keys, StaticTuple(key, node_value))
3048 * return 0 # <<<<<<<<<<<<<<
3049 *
3050 * def parse(self):
3051 */
3052 __pyx_r = 0;
3053 goto __pyx_L0;
3054
3055 /* "breezy/bzr/_btree_serializer_pyx.pyx":170
3056 * return key
3057 *
3058 * cdef int process_line(self) except -1: # <<<<<<<<<<<<<<
3059 * """Process a line in the bytes."""
3060 * cdef char *last
3061 */
3062
3063 /* function exit code */
3064 __pyx_L1_error:;
3065 __Pyx_XDECREF(__pyx_t_3);
3066 __Pyx_XDECREF(__pyx_t_4);
3067 __Pyx_XDECREF(__pyx_t_7);
3068 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.BTreeLeafParser.process_line", __pyx_clineno, __pyx_lineno, __pyx_filename);
3069 __pyx_r = -1;
3070 __pyx_L0:;
3071 __Pyx_XDECREF(__pyx_v_key);
3072 __Pyx_XDECREF(__pyx_v_value);
3073 __Pyx_XDECREF((PyObject *)__pyx_v_ref_lists);
3074 __Pyx_XDECREF(__pyx_v_ref_list);
3075 __Pyx_XDECREF((PyObject *)__pyx_v_node_value);
3076 __Pyx_RefNannyFinishContext();
3077 return __pyx_r;
3078 }
3079
3080 /* "breezy/bzr/_btree_serializer_pyx.pyx":279
3081 * return 0
3082 *
3083 * def parse(self): # <<<<<<<<<<<<<<
3084 * cdef Py_ssize_t byte_count
3085 * if not PyBytes_CheckExact(self.data):
3086 */
3087
3088 /* Python wrapper */
3089 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_3parse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_3parse(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)3090 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_3parse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
3091 PyObject *__pyx_r = 0;
3092 __Pyx_RefNannyDeclarations
3093 __Pyx_RefNannySetupContext("parse (wrapper)", 0);
3094 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_2parse(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self));
3095
3096 /* function exit code */
3097 __Pyx_RefNannyFinishContext();
3098 return __pyx_r;
3099 }
3100
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_2parse(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser * __pyx_v_self)3101 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_2parse(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self) {
3102 Py_ssize_t __pyx_v_byte_count;
3103 PyObject *__pyx_r = NULL;
3104 __Pyx_RefNannyDeclarations
3105 PyObject *__pyx_t_1 = NULL;
3106 int __pyx_t_2;
3107 int __pyx_t_3;
3108 int __pyx_lineno = 0;
3109 const char *__pyx_filename = NULL;
3110 int __pyx_clineno = 0;
3111 __Pyx_RefNannySetupContext("parse", 0);
3112
3113 /* "breezy/bzr/_btree_serializer_pyx.pyx":281
3114 * def parse(self):
3115 * cdef Py_ssize_t byte_count
3116 * if not PyBytes_CheckExact(self.data): # <<<<<<<<<<<<<<
3117 * raise AssertionError('self.data is not a byte string.')
3118 * byte_count = PyBytes_GET_SIZE(self.data)
3119 */
3120 __pyx_t_1 = __pyx_v_self->data;
3121 __Pyx_INCREF(__pyx_t_1);
3122 __pyx_t_2 = ((!(PyBytes_CheckExact(__pyx_t_1) != 0)) != 0);
3123 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3124 if (unlikely(__pyx_t_2)) {
3125
3126 /* "breezy/bzr/_btree_serializer_pyx.pyx":282
3127 * cdef Py_ssize_t byte_count
3128 * if not PyBytes_CheckExact(self.data):
3129 * raise AssertionError('self.data is not a byte string.') # <<<<<<<<<<<<<<
3130 * byte_count = PyBytes_GET_SIZE(self.data)
3131 * self._cur_str = PyBytes_AS_STRING(self.data)
3132 */
3133 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error)
3134 __Pyx_GOTREF(__pyx_t_1);
3135 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
3136 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3137 __PYX_ERR(0, 282, __pyx_L1_error)
3138
3139 /* "breezy/bzr/_btree_serializer_pyx.pyx":281
3140 * def parse(self):
3141 * cdef Py_ssize_t byte_count
3142 * if not PyBytes_CheckExact(self.data): # <<<<<<<<<<<<<<
3143 * raise AssertionError('self.data is not a byte string.')
3144 * byte_count = PyBytes_GET_SIZE(self.data)
3145 */
3146 }
3147
3148 /* "breezy/bzr/_btree_serializer_pyx.pyx":283
3149 * if not PyBytes_CheckExact(self.data):
3150 * raise AssertionError('self.data is not a byte string.')
3151 * byte_count = PyBytes_GET_SIZE(self.data) # <<<<<<<<<<<<<<
3152 * self._cur_str = PyBytes_AS_STRING(self.data)
3153 * # This points to the last character in the string
3154 */
3155 __pyx_t_1 = __pyx_v_self->data;
3156 __Pyx_INCREF(__pyx_t_1);
3157 __pyx_v_byte_count = PyBytes_GET_SIZE(__pyx_t_1);
3158 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3159
3160 /* "breezy/bzr/_btree_serializer_pyx.pyx":284
3161 * raise AssertionError('self.data is not a byte string.')
3162 * byte_count = PyBytes_GET_SIZE(self.data)
3163 * self._cur_str = PyBytes_AS_STRING(self.data) # <<<<<<<<<<<<<<
3164 * # This points to the last character in the string
3165 * self._end_str = self._cur_str + byte_count
3166 */
3167 __pyx_t_1 = __pyx_v_self->data;
3168 __Pyx_INCREF(__pyx_t_1);
3169 __pyx_v_self->_cur_str = PyBytes_AS_STRING(__pyx_t_1);
3170 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3171
3172 /* "breezy/bzr/_btree_serializer_pyx.pyx":286
3173 * self._cur_str = PyBytes_AS_STRING(self.data)
3174 * # This points to the last character in the string
3175 * self._end_str = self._cur_str + byte_count # <<<<<<<<<<<<<<
3176 * while self._cur_str < self._end_str:
3177 * self.process_line()
3178 */
3179 __pyx_v_self->_end_str = (__pyx_v_self->_cur_str + __pyx_v_byte_count);
3180
3181 /* "breezy/bzr/_btree_serializer_pyx.pyx":287
3182 * # This points to the last character in the string
3183 * self._end_str = self._cur_str + byte_count
3184 * while self._cur_str < self._end_str: # <<<<<<<<<<<<<<
3185 * self.process_line()
3186 * return self.keys
3187 */
3188 while (1) {
3189 __pyx_t_2 = ((__pyx_v_self->_cur_str < __pyx_v_self->_end_str) != 0);
3190 if (!__pyx_t_2) break;
3191
3192 /* "breezy/bzr/_btree_serializer_pyx.pyx":288
3193 * self._end_str = self._cur_str + byte_count
3194 * while self._cur_str < self._end_str:
3195 * self.process_line() # <<<<<<<<<<<<<<
3196 * return self.keys
3197 *
3198 */
3199 __pyx_t_3 = ((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self->__pyx_vtab)->process_line(__pyx_v_self); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 288, __pyx_L1_error)
3200 }
3201
3202 /* "breezy/bzr/_btree_serializer_pyx.pyx":289
3203 * while self._cur_str < self._end_str:
3204 * self.process_line()
3205 * return self.keys # <<<<<<<<<<<<<<
3206 *
3207 *
3208 */
3209 __Pyx_XDECREF(__pyx_r);
3210 __Pyx_INCREF(__pyx_v_self->keys);
3211 __pyx_r = __pyx_v_self->keys;
3212 goto __pyx_L0;
3213
3214 /* "breezy/bzr/_btree_serializer_pyx.pyx":279
3215 * return 0
3216 *
3217 * def parse(self): # <<<<<<<<<<<<<<
3218 * cdef Py_ssize_t byte_count
3219 * if not PyBytes_CheckExact(self.data):
3220 */
3221
3222 /* function exit code */
3223 __pyx_L1_error:;
3224 __Pyx_XDECREF(__pyx_t_1);
3225 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.BTreeLeafParser.parse", __pyx_clineno, __pyx_lineno, __pyx_filename);
3226 __pyx_r = NULL;
3227 __pyx_L0:;
3228 __Pyx_XGIVEREF(__pyx_r);
3229 __Pyx_RefNannyFinishContext();
3230 return __pyx_r;
3231 }
3232
3233 /* "(tree fragment)":1
3234 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
3235 * cdef tuple state
3236 * cdef object _dict
3237 */
3238
3239 /* Python wrapper */
3240 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_5__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)3241 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
3242 PyObject *__pyx_r = 0;
3243 __Pyx_RefNannyDeclarations
3244 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
3245 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_4__reduce_cython__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self));
3246
3247 /* function exit code */
3248 __Pyx_RefNannyFinishContext();
3249 return __pyx_r;
3250 }
3251
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_4__reduce_cython__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser * __pyx_v_self)3252 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_4__reduce_cython__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self) {
3253 PyObject *__pyx_v_state = 0;
3254 PyObject *__pyx_v__dict = 0;
3255 int __pyx_v_use_setstate;
3256 PyObject *__pyx_r = NULL;
3257 __Pyx_RefNannyDeclarations
3258 PyObject *__pyx_t_1 = NULL;
3259 PyObject *__pyx_t_2 = NULL;
3260 PyObject *__pyx_t_3 = NULL;
3261 PyObject *__pyx_t_4 = NULL;
3262 PyObject *__pyx_t_5 = NULL;
3263 PyObject *__pyx_t_6 = NULL;
3264 PyObject *__pyx_t_7 = NULL;
3265 int __pyx_t_8;
3266 int __pyx_t_9;
3267 int __pyx_t_10;
3268 int __pyx_lineno = 0;
3269 const char *__pyx_filename = NULL;
3270 int __pyx_clineno = 0;
3271 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
3272
3273 /* "(tree fragment)":5
3274 * cdef object _dict
3275 * cdef bint use_setstate
3276 * state = (self._cur_str, self._end_str, self._header_found, self._start, self.data, self.key_length, self.keys, self.ref_list_length) # <<<<<<<<<<<<<<
3277 * _dict = getattr(self, '__dict__', None)
3278 * if _dict is not None:
3279 */
3280 __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->_cur_str); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
3281 __Pyx_GOTREF(__pyx_t_1);
3282 __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_self->_end_str); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
3283 __Pyx_GOTREF(__pyx_t_2);
3284 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->_header_found); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
3285 __Pyx_GOTREF(__pyx_t_3);
3286 __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->_start); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
3287 __Pyx_GOTREF(__pyx_t_4);
3288 __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->key_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5, __pyx_L1_error)
3289 __Pyx_GOTREF(__pyx_t_5);
3290 __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_self->ref_list_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 5, __pyx_L1_error)
3291 __Pyx_GOTREF(__pyx_t_6);
3292 __pyx_t_7 = PyTuple_New(8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5, __pyx_L1_error)
3293 __Pyx_GOTREF(__pyx_t_7);
3294 __Pyx_GIVEREF(__pyx_t_1);
3295 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
3296 __Pyx_GIVEREF(__pyx_t_2);
3297 PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
3298 __Pyx_GIVEREF(__pyx_t_3);
3299 PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
3300 __Pyx_GIVEREF(__pyx_t_4);
3301 PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_4);
3302 __Pyx_INCREF(__pyx_v_self->data);
3303 __Pyx_GIVEREF(__pyx_v_self->data);
3304 PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_v_self->data);
3305 __Pyx_GIVEREF(__pyx_t_5);
3306 PyTuple_SET_ITEM(__pyx_t_7, 5, __pyx_t_5);
3307 __Pyx_INCREF(__pyx_v_self->keys);
3308 __Pyx_GIVEREF(__pyx_v_self->keys);
3309 PyTuple_SET_ITEM(__pyx_t_7, 6, __pyx_v_self->keys);
3310 __Pyx_GIVEREF(__pyx_t_6);
3311 PyTuple_SET_ITEM(__pyx_t_7, 7, __pyx_t_6);
3312 __pyx_t_1 = 0;
3313 __pyx_t_2 = 0;
3314 __pyx_t_3 = 0;
3315 __pyx_t_4 = 0;
3316 __pyx_t_5 = 0;
3317 __pyx_t_6 = 0;
3318 __pyx_v_state = ((PyObject*)__pyx_t_7);
3319 __pyx_t_7 = 0;
3320
3321 /* "(tree fragment)":6
3322 * cdef bint use_setstate
3323 * state = (self._cur_str, self._end_str, self._header_found, self._start, self.data, self.key_length, self.keys, self.ref_list_length)
3324 * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
3325 * if _dict is not None:
3326 * state += (_dict,)
3327 */
3328 __pyx_t_7 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 6, __pyx_L1_error)
3329 __Pyx_GOTREF(__pyx_t_7);
3330 __pyx_v__dict = __pyx_t_7;
3331 __pyx_t_7 = 0;
3332
3333 /* "(tree fragment)":7
3334 * state = (self._cur_str, self._end_str, self._header_found, self._start, self.data, self.key_length, self.keys, self.ref_list_length)
3335 * _dict = getattr(self, '__dict__', None)
3336 * if _dict is not None: # <<<<<<<<<<<<<<
3337 * state += (_dict,)
3338 * use_setstate = True
3339 */
3340 __pyx_t_8 = (__pyx_v__dict != Py_None);
3341 __pyx_t_9 = (__pyx_t_8 != 0);
3342 if (__pyx_t_9) {
3343
3344 /* "(tree fragment)":8
3345 * _dict = getattr(self, '__dict__', None)
3346 * if _dict is not None:
3347 * state += (_dict,) # <<<<<<<<<<<<<<
3348 * use_setstate = True
3349 * else:
3350 */
3351 __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 8, __pyx_L1_error)
3352 __Pyx_GOTREF(__pyx_t_7);
3353 __Pyx_INCREF(__pyx_v__dict);
3354 __Pyx_GIVEREF(__pyx_v__dict);
3355 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v__dict);
3356 __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 8, __pyx_L1_error)
3357 __Pyx_GOTREF(__pyx_t_6);
3358 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3359 __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_6));
3360 __pyx_t_6 = 0;
3361
3362 /* "(tree fragment)":9
3363 * if _dict is not None:
3364 * state += (_dict,)
3365 * use_setstate = True # <<<<<<<<<<<<<<
3366 * else:
3367 * use_setstate = self.data is not None or self.keys is not None
3368 */
3369 __pyx_v_use_setstate = 1;
3370
3371 /* "(tree fragment)":7
3372 * state = (self._cur_str, self._end_str, self._header_found, self._start, self.data, self.key_length, self.keys, self.ref_list_length)
3373 * _dict = getattr(self, '__dict__', None)
3374 * if _dict is not None: # <<<<<<<<<<<<<<
3375 * state += (_dict,)
3376 * use_setstate = True
3377 */
3378 goto __pyx_L3;
3379 }
3380
3381 /* "(tree fragment)":11
3382 * use_setstate = True
3383 * else:
3384 * use_setstate = self.data is not None or self.keys is not None # <<<<<<<<<<<<<<
3385 * if use_setstate:
3386 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, None), state
3387 */
3388 /*else*/ {
3389 __pyx_t_8 = (__pyx_v_self->data != Py_None);
3390 __pyx_t_10 = (__pyx_t_8 != 0);
3391 if (!__pyx_t_10) {
3392 } else {
3393 __pyx_t_9 = __pyx_t_10;
3394 goto __pyx_L4_bool_binop_done;
3395 }
3396 __pyx_t_10 = (__pyx_v_self->keys != Py_None);
3397 __pyx_t_8 = (__pyx_t_10 != 0);
3398 __pyx_t_9 = __pyx_t_8;
3399 __pyx_L4_bool_binop_done:;
3400 __pyx_v_use_setstate = __pyx_t_9;
3401 }
3402 __pyx_L3:;
3403
3404 /* "(tree fragment)":12
3405 * else:
3406 * use_setstate = self.data is not None or self.keys is not None
3407 * if use_setstate: # <<<<<<<<<<<<<<
3408 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, None), state
3409 * else:
3410 */
3411 __pyx_t_9 = (__pyx_v_use_setstate != 0);
3412 if (__pyx_t_9) {
3413
3414 /* "(tree fragment)":13
3415 * use_setstate = self.data is not None or self.keys is not None
3416 * if use_setstate:
3417 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, None), state # <<<<<<<<<<<<<<
3418 * else:
3419 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, state)
3420 */
3421 __Pyx_XDECREF(__pyx_r);
3422 __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_BTreeLeafParser); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
3423 __Pyx_GOTREF(__pyx_t_6);
3424 __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 13, __pyx_L1_error)
3425 __Pyx_GOTREF(__pyx_t_7);
3426 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
3427 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
3428 PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
3429 __Pyx_INCREF(__pyx_int_163054242);
3430 __Pyx_GIVEREF(__pyx_int_163054242);
3431 PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_163054242);
3432 __Pyx_INCREF(Py_None);
3433 __Pyx_GIVEREF(Py_None);
3434 PyTuple_SET_ITEM(__pyx_t_7, 2, Py_None);
3435 __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
3436 __Pyx_GOTREF(__pyx_t_5);
3437 __Pyx_GIVEREF(__pyx_t_6);
3438 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
3439 __Pyx_GIVEREF(__pyx_t_7);
3440 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7);
3441 __Pyx_INCREF(__pyx_v_state);
3442 __Pyx_GIVEREF(__pyx_v_state);
3443 PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
3444 __pyx_t_6 = 0;
3445 __pyx_t_7 = 0;
3446 __pyx_r = __pyx_t_5;
3447 __pyx_t_5 = 0;
3448 goto __pyx_L0;
3449
3450 /* "(tree fragment)":12
3451 * else:
3452 * use_setstate = self.data is not None or self.keys is not None
3453 * if use_setstate: # <<<<<<<<<<<<<<
3454 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, None), state
3455 * else:
3456 */
3457 }
3458
3459 /* "(tree fragment)":15
3460 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, None), state
3461 * else:
3462 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, state) # <<<<<<<<<<<<<<
3463 * def __setstate_cython__(self, __pyx_state):
3464 * __pyx_unpickle_BTreeLeafParser__set_state(self, __pyx_state)
3465 */
3466 /*else*/ {
3467 __Pyx_XDECREF(__pyx_r);
3468 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_BTreeLeafParser); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
3469 __Pyx_GOTREF(__pyx_t_5);
3470 __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 15, __pyx_L1_error)
3471 __Pyx_GOTREF(__pyx_t_7);
3472 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
3473 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
3474 PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
3475 __Pyx_INCREF(__pyx_int_163054242);
3476 __Pyx_GIVEREF(__pyx_int_163054242);
3477 PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_163054242);
3478 __Pyx_INCREF(__pyx_v_state);
3479 __Pyx_GIVEREF(__pyx_v_state);
3480 PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_state);
3481 __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
3482 __Pyx_GOTREF(__pyx_t_6);
3483 __Pyx_GIVEREF(__pyx_t_5);
3484 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
3485 __Pyx_GIVEREF(__pyx_t_7);
3486 PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
3487 __pyx_t_5 = 0;
3488 __pyx_t_7 = 0;
3489 __pyx_r = __pyx_t_6;
3490 __pyx_t_6 = 0;
3491 goto __pyx_L0;
3492 }
3493
3494 /* "(tree fragment)":1
3495 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
3496 * cdef tuple state
3497 * cdef object _dict
3498 */
3499
3500 /* function exit code */
3501 __pyx_L1_error:;
3502 __Pyx_XDECREF(__pyx_t_1);
3503 __Pyx_XDECREF(__pyx_t_2);
3504 __Pyx_XDECREF(__pyx_t_3);
3505 __Pyx_XDECREF(__pyx_t_4);
3506 __Pyx_XDECREF(__pyx_t_5);
3507 __Pyx_XDECREF(__pyx_t_6);
3508 __Pyx_XDECREF(__pyx_t_7);
3509 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.BTreeLeafParser.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3510 __pyx_r = NULL;
3511 __pyx_L0:;
3512 __Pyx_XDECREF(__pyx_v_state);
3513 __Pyx_XDECREF(__pyx_v__dict);
3514 __Pyx_XGIVEREF(__pyx_r);
3515 __Pyx_RefNannyFinishContext();
3516 return __pyx_r;
3517 }
3518
3519 /* "(tree fragment)":16
3520 * else:
3521 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, state)
3522 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
3523 * __pyx_unpickle_BTreeLeafParser__set_state(self, __pyx_state)
3524 */
3525
3526 /* Python wrapper */
3527 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_7__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)3528 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
3529 PyObject *__pyx_r = 0;
3530 __Pyx_RefNannyDeclarations
3531 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
3532 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_6__setstate_cython__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
3533
3534 /* function exit code */
3535 __Pyx_RefNannyFinishContext();
3536 return __pyx_r;
3537 }
3538
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_6__setstate_cython__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser * __pyx_v_self,PyObject * __pyx_v___pyx_state)3539 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_6__setstate_cython__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
3540 PyObject *__pyx_r = NULL;
3541 __Pyx_RefNannyDeclarations
3542 PyObject *__pyx_t_1 = NULL;
3543 int __pyx_lineno = 0;
3544 const char *__pyx_filename = NULL;
3545 int __pyx_clineno = 0;
3546 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
3547
3548 /* "(tree fragment)":17
3549 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, state)
3550 * def __setstate_cython__(self, __pyx_state):
3551 * __pyx_unpickle_BTreeLeafParser__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
3552 */
3553 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
3554 __pyx_t_1 = __pyx_f_6breezy_3bzr_21_btree_serializer_pyx___pyx_unpickle_BTreeLeafParser__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
3555 __Pyx_GOTREF(__pyx_t_1);
3556 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3557
3558 /* "(tree fragment)":16
3559 * else:
3560 * return __pyx_unpickle_BTreeLeafParser, (type(self), 0x9b802a2, state)
3561 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
3562 * __pyx_unpickle_BTreeLeafParser__set_state(self, __pyx_state)
3563 */
3564
3565 /* function exit code */
3566 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3567 goto __pyx_L0;
3568 __pyx_L1_error:;
3569 __Pyx_XDECREF(__pyx_t_1);
3570 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.BTreeLeafParser.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3571 __pyx_r = NULL;
3572 __pyx_L0:;
3573 __Pyx_XGIVEREF(__pyx_r);
3574 __Pyx_RefNannyFinishContext();
3575 return __pyx_r;
3576 }
3577
3578 /* "breezy/bzr/_btree_serializer_pyx.pyx":292
3579 *
3580 *
3581 * def _parse_leaf_lines(data, key_length, ref_list_length): # <<<<<<<<<<<<<<
3582 * parser = BTreeLeafParser(data, key_length, ref_list_length)
3583 * return parser.parse()
3584 */
3585
3586 /* Python wrapper */
3587 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_1_parse_leaf_lines(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3588 static PyMethodDef __pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_1_parse_leaf_lines = {"_parse_leaf_lines", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_1_parse_leaf_lines, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_1_parse_leaf_lines(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3589 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_1_parse_leaf_lines(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3590 PyObject *__pyx_v_data = 0;
3591 PyObject *__pyx_v_key_length = 0;
3592 PyObject *__pyx_v_ref_list_length = 0;
3593 int __pyx_lineno = 0;
3594 const char *__pyx_filename = NULL;
3595 int __pyx_clineno = 0;
3596 PyObject *__pyx_r = 0;
3597 __Pyx_RefNannyDeclarations
3598 __Pyx_RefNannySetupContext("_parse_leaf_lines (wrapper)", 0);
3599 {
3600 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_key_length,&__pyx_n_s_ref_list_length,0};
3601 PyObject* values[3] = {0,0,0};
3602 if (unlikely(__pyx_kwds)) {
3603 Py_ssize_t kw_args;
3604 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3605 switch (pos_args) {
3606 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3607 CYTHON_FALLTHROUGH;
3608 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3609 CYTHON_FALLTHROUGH;
3610 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3611 CYTHON_FALLTHROUGH;
3612 case 0: break;
3613 default: goto __pyx_L5_argtuple_error;
3614 }
3615 kw_args = PyDict_Size(__pyx_kwds);
3616 switch (pos_args) {
3617 case 0:
3618 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
3619 else goto __pyx_L5_argtuple_error;
3620 CYTHON_FALLTHROUGH;
3621 case 1:
3622 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key_length)) != 0)) kw_args--;
3623 else {
3624 __Pyx_RaiseArgtupleInvalid("_parse_leaf_lines", 1, 3, 3, 1); __PYX_ERR(0, 292, __pyx_L3_error)
3625 }
3626 CYTHON_FALLTHROUGH;
3627 case 2:
3628 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref_list_length)) != 0)) kw_args--;
3629 else {
3630 __Pyx_RaiseArgtupleInvalid("_parse_leaf_lines", 1, 3, 3, 2); __PYX_ERR(0, 292, __pyx_L3_error)
3631 }
3632 }
3633 if (unlikely(kw_args > 0)) {
3634 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse_leaf_lines") < 0)) __PYX_ERR(0, 292, __pyx_L3_error)
3635 }
3636 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
3637 goto __pyx_L5_argtuple_error;
3638 } else {
3639 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3640 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3641 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3642 }
3643 __pyx_v_data = values[0];
3644 __pyx_v_key_length = values[1];
3645 __pyx_v_ref_list_length = values[2];
3646 }
3647 goto __pyx_L4_argument_unpacking_done;
3648 __pyx_L5_argtuple_error:;
3649 __Pyx_RaiseArgtupleInvalid("_parse_leaf_lines", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 292, __pyx_L3_error)
3650 __pyx_L3_error:;
3651 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._parse_leaf_lines", __pyx_clineno, __pyx_lineno, __pyx_filename);
3652 __Pyx_RefNannyFinishContext();
3653 return NULL;
3654 __pyx_L4_argument_unpacking_done:;
3655 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx__parse_leaf_lines(__pyx_self, __pyx_v_data, __pyx_v_key_length, __pyx_v_ref_list_length);
3656
3657 /* function exit code */
3658 __Pyx_RefNannyFinishContext();
3659 return __pyx_r;
3660 }
3661
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx__parse_leaf_lines(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_data,PyObject * __pyx_v_key_length,PyObject * __pyx_v_ref_list_length)3662 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx__parse_leaf_lines(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_key_length, PyObject *__pyx_v_ref_list_length) {
3663 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v_parser = NULL;
3664 PyObject *__pyx_r = NULL;
3665 __Pyx_RefNannyDeclarations
3666 PyObject *__pyx_t_1 = NULL;
3667 PyObject *__pyx_t_2 = NULL;
3668 PyObject *__pyx_t_3 = NULL;
3669 int __pyx_lineno = 0;
3670 const char *__pyx_filename = NULL;
3671 int __pyx_clineno = 0;
3672 __Pyx_RefNannySetupContext("_parse_leaf_lines", 0);
3673
3674 /* "breezy/bzr/_btree_serializer_pyx.pyx":293
3675 *
3676 * def _parse_leaf_lines(data, key_length, ref_list_length):
3677 * parser = BTreeLeafParser(data, key_length, ref_list_length) # <<<<<<<<<<<<<<
3678 * return parser.parse()
3679 *
3680 */
3681 __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error)
3682 __Pyx_GOTREF(__pyx_t_1);
3683 __Pyx_INCREF(__pyx_v_data);
3684 __Pyx_GIVEREF(__pyx_v_data);
3685 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data);
3686 __Pyx_INCREF(__pyx_v_key_length);
3687 __Pyx_GIVEREF(__pyx_v_key_length);
3688 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_key_length);
3689 __Pyx_INCREF(__pyx_v_ref_list_length);
3690 __Pyx_GIVEREF(__pyx_v_ref_list_length);
3691 PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_ref_list_length);
3692 __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 293, __pyx_L1_error)
3693 __Pyx_GOTREF(__pyx_t_2);
3694 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3695 __pyx_v_parser = ((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_t_2);
3696 __pyx_t_2 = 0;
3697
3698 /* "breezy/bzr/_btree_serializer_pyx.pyx":294
3699 * def _parse_leaf_lines(data, key_length, ref_list_length):
3700 * parser = BTreeLeafParser(data, key_length, ref_list_length)
3701 * return parser.parse() # <<<<<<<<<<<<<<
3702 *
3703 *
3704 */
3705 __Pyx_XDECREF(__pyx_r);
3706 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_parser), __pyx_n_s_parse); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
3707 __Pyx_GOTREF(__pyx_t_1);
3708 __pyx_t_3 = NULL;
3709 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
3710 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
3711 if (likely(__pyx_t_3)) {
3712 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3713 __Pyx_INCREF(__pyx_t_3);
3714 __Pyx_INCREF(function);
3715 __Pyx_DECREF_SET(__pyx_t_1, function);
3716 }
3717 }
3718 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
3719 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3720 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error)
3721 __Pyx_GOTREF(__pyx_t_2);
3722 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3723 __pyx_r = __pyx_t_2;
3724 __pyx_t_2 = 0;
3725 goto __pyx_L0;
3726
3727 /* "breezy/bzr/_btree_serializer_pyx.pyx":292
3728 *
3729 *
3730 * def _parse_leaf_lines(data, key_length, ref_list_length): # <<<<<<<<<<<<<<
3731 * parser = BTreeLeafParser(data, key_length, ref_list_length)
3732 * return parser.parse()
3733 */
3734
3735 /* function exit code */
3736 __pyx_L1_error:;
3737 __Pyx_XDECREF(__pyx_t_1);
3738 __Pyx_XDECREF(__pyx_t_2);
3739 __Pyx_XDECREF(__pyx_t_3);
3740 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._parse_leaf_lines", __pyx_clineno, __pyx_lineno, __pyx_filename);
3741 __pyx_r = NULL;
3742 __pyx_L0:;
3743 __Pyx_XDECREF((PyObject *)__pyx_v_parser);
3744 __Pyx_XGIVEREF(__pyx_r);
3745 __Pyx_RefNannyFinishContext();
3746 return __pyx_r;
3747 }
3748
3749 /* "breezy/bzr/_btree_serializer_pyx.pyx":316
3750 * _hexbuf = b'0123456789abcdef'
3751 *
3752 * cdef _populate_unhexbuf(): # <<<<<<<<<<<<<<
3753 * cdef int i
3754 * for i from 0 <= i < 256:
3755 */
3756
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__populate_unhexbuf(void)3757 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__populate_unhexbuf(void) {
3758 int __pyx_v_i;
3759 PyObject *__pyx_r = NULL;
3760 __Pyx_RefNannyDeclarations
3761 __Pyx_RefNannySetupContext("_populate_unhexbuf", 0);
3762
3763 /* "breezy/bzr/_btree_serializer_pyx.pyx":318
3764 * cdef _populate_unhexbuf():
3765 * cdef int i
3766 * for i from 0 <= i < 256: # <<<<<<<<<<<<<<
3767 * _unhexbuf[i] = -1
3768 * for i from 0 <= i < 10: # 0123456789 => map to the raw number
3769 */
3770 for (__pyx_v_i = 0; __pyx_v_i < 0x100; __pyx_v_i++) {
3771
3772 /* "breezy/bzr/_btree_serializer_pyx.pyx":319
3773 * cdef int i
3774 * for i from 0 <= i < 256:
3775 * _unhexbuf[i] = -1 # <<<<<<<<<<<<<<
3776 * for i from 0 <= i < 10: # 0123456789 => map to the raw number
3777 * _unhexbuf[(i + c'0')] = i
3778 */
3779 (__pyx_v_6breezy_3bzr_21_btree_serializer_pyx__unhexbuf[__pyx_v_i]) = -1;
3780 }
3781
3782 /* "breezy/bzr/_btree_serializer_pyx.pyx":320
3783 * for i from 0 <= i < 256:
3784 * _unhexbuf[i] = -1
3785 * for i from 0 <= i < 10: # 0123456789 => map to the raw number # <<<<<<<<<<<<<<
3786 * _unhexbuf[(i + c'0')] = i
3787 * for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16
3788 */
3789 for (__pyx_v_i = 0; __pyx_v_i < 10; __pyx_v_i++) {
3790
3791 /* "breezy/bzr/_btree_serializer_pyx.pyx":321
3792 * _unhexbuf[i] = -1
3793 * for i from 0 <= i < 10: # 0123456789 => map to the raw number
3794 * _unhexbuf[(i + c'0')] = i # <<<<<<<<<<<<<<
3795 * for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16
3796 * _unhexbuf[(i - 10 + c'a')] = i
3797 */
3798 (__pyx_v_6breezy_3bzr_21_btree_serializer_pyx__unhexbuf[(__pyx_v_i + '0')]) = __pyx_v_i;
3799 }
3800
3801 /* "breezy/bzr/_btree_serializer_pyx.pyx":322
3802 * for i from 0 <= i < 10: # 0123456789 => map to the raw number
3803 * _unhexbuf[(i + c'0')] = i
3804 * for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16 # <<<<<<<<<<<<<<
3805 * _unhexbuf[(i - 10 + c'a')] = i
3806 * for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16
3807 */
3808 for (__pyx_v_i = 10; __pyx_v_i < 16; __pyx_v_i++) {
3809
3810 /* "breezy/bzr/_btree_serializer_pyx.pyx":323
3811 * _unhexbuf[(i + c'0')] = i
3812 * for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16
3813 * _unhexbuf[(i - 10 + c'a')] = i # <<<<<<<<<<<<<<
3814 * for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16
3815 * _unhexbuf[(i - 10 + c'A')] = i
3816 */
3817 (__pyx_v_6breezy_3bzr_21_btree_serializer_pyx__unhexbuf[((__pyx_v_i - 10) + 'a')]) = __pyx_v_i;
3818 }
3819
3820 /* "breezy/bzr/_btree_serializer_pyx.pyx":324
3821 * for i from 10 <= i < 16: # abcdef => 10, 11, 12, 13, 14, 15, 16
3822 * _unhexbuf[(i - 10 + c'a')] = i
3823 * for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16 # <<<<<<<<<<<<<<
3824 * _unhexbuf[(i - 10 + c'A')] = i
3825 * _populate_unhexbuf()
3826 */
3827 for (__pyx_v_i = 10; __pyx_v_i < 16; __pyx_v_i++) {
3828
3829 /* "breezy/bzr/_btree_serializer_pyx.pyx":325
3830 * _unhexbuf[(i - 10 + c'a')] = i
3831 * for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16
3832 * _unhexbuf[(i - 10 + c'A')] = i # <<<<<<<<<<<<<<
3833 * _populate_unhexbuf()
3834 *
3835 */
3836 (__pyx_v_6breezy_3bzr_21_btree_serializer_pyx__unhexbuf[((__pyx_v_i - 10) + 'A')]) = __pyx_v_i;
3837 }
3838
3839 /* "breezy/bzr/_btree_serializer_pyx.pyx":316
3840 * _hexbuf = b'0123456789abcdef'
3841 *
3842 * cdef _populate_unhexbuf(): # <<<<<<<<<<<<<<
3843 * cdef int i
3844 * for i from 0 <= i < 256:
3845 */
3846
3847 /* function exit code */
3848 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3849 __Pyx_XGIVEREF(__pyx_r);
3850 __Pyx_RefNannyFinishContext();
3851 return __pyx_r;
3852 }
3853
3854 /* "breezy/bzr/_btree_serializer_pyx.pyx":329
3855 *
3856 *
3857 * cdef int _unhexlify_sha1(char *as_hex, char *as_bin): # cannot_raise # <<<<<<<<<<<<<<
3858 * """Take the hex sha1 in as_hex and make it binary in as_bin
3859 *
3860 */
3861
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__unhexlify_sha1(char * __pyx_v_as_hex,char * __pyx_v_as_bin)3862 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__unhexlify_sha1(char *__pyx_v_as_hex, char *__pyx_v_as_bin) {
3863 int __pyx_v_top;
3864 int __pyx_v_bot;
3865 int __pyx_v_i;
3866 int __pyx_v_j;
3867 int __pyx_r;
3868 __Pyx_RefNannyDeclarations
3869 int __pyx_t_1;
3870 int __pyx_t_2;
3871 __Pyx_RefNannySetupContext("_unhexlify_sha1", 0);
3872
3873 /* "breezy/bzr/_btree_serializer_pyx.pyx":341
3874 * # binascii does this using isupper() and tolower() and ?: syntax. I'm
3875 * # guessing a simple lookup array should be faster.
3876 * j = 0 # <<<<<<<<<<<<<<
3877 * for i from 0 <= i < 20:
3878 * top = _unhexbuf[<unsigned char>(as_hex[j])]
3879 */
3880 __pyx_v_j = 0;
3881
3882 /* "breezy/bzr/_btree_serializer_pyx.pyx":342
3883 * # guessing a simple lookup array should be faster.
3884 * j = 0
3885 * for i from 0 <= i < 20: # <<<<<<<<<<<<<<
3886 * top = _unhexbuf[<unsigned char>(as_hex[j])]
3887 * j = j + 1
3888 */
3889 for (__pyx_v_i = 0; __pyx_v_i < 20; __pyx_v_i++) {
3890
3891 /* "breezy/bzr/_btree_serializer_pyx.pyx":343
3892 * j = 0
3893 * for i from 0 <= i < 20:
3894 * top = _unhexbuf[<unsigned char>(as_hex[j])] # <<<<<<<<<<<<<<
3895 * j = j + 1
3896 * bot = _unhexbuf[<unsigned char>(as_hex[j])]
3897 */
3898 __pyx_v_top = (__pyx_v_6breezy_3bzr_21_btree_serializer_pyx__unhexbuf[((unsigned char)(__pyx_v_as_hex[__pyx_v_j]))]);
3899
3900 /* "breezy/bzr/_btree_serializer_pyx.pyx":344
3901 * for i from 0 <= i < 20:
3902 * top = _unhexbuf[<unsigned char>(as_hex[j])]
3903 * j = j + 1 # <<<<<<<<<<<<<<
3904 * bot = _unhexbuf[<unsigned char>(as_hex[j])]
3905 * j = j + 1
3906 */
3907 __pyx_v_j = (__pyx_v_j + 1);
3908
3909 /* "breezy/bzr/_btree_serializer_pyx.pyx":345
3910 * top = _unhexbuf[<unsigned char>(as_hex[j])]
3911 * j = j + 1
3912 * bot = _unhexbuf[<unsigned char>(as_hex[j])] # <<<<<<<<<<<<<<
3913 * j = j + 1
3914 * if top == -1 or bot == -1:
3915 */
3916 __pyx_v_bot = (__pyx_v_6breezy_3bzr_21_btree_serializer_pyx__unhexbuf[((unsigned char)(__pyx_v_as_hex[__pyx_v_j]))]);
3917
3918 /* "breezy/bzr/_btree_serializer_pyx.pyx":346
3919 * j = j + 1
3920 * bot = _unhexbuf[<unsigned char>(as_hex[j])]
3921 * j = j + 1 # <<<<<<<<<<<<<<
3922 * if top == -1 or bot == -1:
3923 * return 0
3924 */
3925 __pyx_v_j = (__pyx_v_j + 1);
3926
3927 /* "breezy/bzr/_btree_serializer_pyx.pyx":347
3928 * bot = _unhexbuf[<unsigned char>(as_hex[j])]
3929 * j = j + 1
3930 * if top == -1 or bot == -1: # <<<<<<<<<<<<<<
3931 * return 0
3932 * as_bin[i] = <unsigned char>((top << 4) + bot);
3933 */
3934 __pyx_t_2 = ((__pyx_v_top == -1L) != 0);
3935 if (!__pyx_t_2) {
3936 } else {
3937 __pyx_t_1 = __pyx_t_2;
3938 goto __pyx_L6_bool_binop_done;
3939 }
3940 __pyx_t_2 = ((__pyx_v_bot == -1L) != 0);
3941 __pyx_t_1 = __pyx_t_2;
3942 __pyx_L6_bool_binop_done:;
3943 if (__pyx_t_1) {
3944
3945 /* "breezy/bzr/_btree_serializer_pyx.pyx":348
3946 * j = j + 1
3947 * if top == -1 or bot == -1:
3948 * return 0 # <<<<<<<<<<<<<<
3949 * as_bin[i] = <unsigned char>((top << 4) + bot);
3950 * return 1
3951 */
3952 __pyx_r = 0;
3953 goto __pyx_L0;
3954
3955 /* "breezy/bzr/_btree_serializer_pyx.pyx":347
3956 * bot = _unhexbuf[<unsigned char>(as_hex[j])]
3957 * j = j + 1
3958 * if top == -1 or bot == -1: # <<<<<<<<<<<<<<
3959 * return 0
3960 * as_bin[i] = <unsigned char>((top << 4) + bot);
3961 */
3962 }
3963
3964 /* "breezy/bzr/_btree_serializer_pyx.pyx":349
3965 * if top == -1 or bot == -1:
3966 * return 0
3967 * as_bin[i] = <unsigned char>((top << 4) + bot); # <<<<<<<<<<<<<<
3968 * return 1
3969 *
3970 */
3971 (__pyx_v_as_bin[__pyx_v_i]) = ((unsigned char)((__pyx_v_top << 4) + __pyx_v_bot));
3972 }
3973
3974 /* "breezy/bzr/_btree_serializer_pyx.pyx":350
3975 * return 0
3976 * as_bin[i] = <unsigned char>((top << 4) + bot);
3977 * return 1 # <<<<<<<<<<<<<<
3978 *
3979 *
3980 */
3981 __pyx_r = 1;
3982 goto __pyx_L0;
3983
3984 /* "breezy/bzr/_btree_serializer_pyx.pyx":329
3985 *
3986 *
3987 * cdef int _unhexlify_sha1(char *as_hex, char *as_bin): # cannot_raise # <<<<<<<<<<<<<<
3988 * """Take the hex sha1 in as_hex and make it binary in as_bin
3989 *
3990 */
3991
3992 /* function exit code */
3993 __pyx_L0:;
3994 __Pyx_RefNannyFinishContext();
3995 return __pyx_r;
3996 }
3997
3998 /* "breezy/bzr/_btree_serializer_pyx.pyx":353
3999 *
4000 *
4001 * def _py_unhexlify(as_hex): # <<<<<<<<<<<<<<
4002 * """For the test infrastructure, just thunks to _unhexlify_sha1"""
4003 * if not PyBytes_CheckExact(as_hex) or PyBytes_GET_SIZE(as_hex) != 40:
4004 */
4005
4006 /* Python wrapper */
4007 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_3_py_unhexlify(PyObject *__pyx_self, PyObject *__pyx_v_as_hex); /*proto*/
4008 static char __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_2_py_unhexlify[] = "For the test infrastructure, just thunks to _unhexlify_sha1";
4009 static PyMethodDef __pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_3_py_unhexlify = {"_py_unhexlify", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_3_py_unhexlify, METH_O, __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_2_py_unhexlify};
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_3_py_unhexlify(PyObject * __pyx_self,PyObject * __pyx_v_as_hex)4010 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_3_py_unhexlify(PyObject *__pyx_self, PyObject *__pyx_v_as_hex) {
4011 PyObject *__pyx_r = 0;
4012 __Pyx_RefNannyDeclarations
4013 __Pyx_RefNannySetupContext("_py_unhexlify (wrapper)", 0);
4014 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_2_py_unhexlify(__pyx_self, ((PyObject *)__pyx_v_as_hex));
4015
4016 /* function exit code */
4017 __Pyx_RefNannyFinishContext();
4018 return __pyx_r;
4019 }
4020
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_2_py_unhexlify(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_as_hex)4021 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_2_py_unhexlify(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_as_hex) {
4022 PyObject *__pyx_v_as_bin = NULL;
4023 PyObject *__pyx_r = NULL;
4024 __Pyx_RefNannyDeclarations
4025 int __pyx_t_1;
4026 int __pyx_t_2;
4027 PyObject *__pyx_t_3 = NULL;
4028 int __pyx_lineno = 0;
4029 const char *__pyx_filename = NULL;
4030 int __pyx_clineno = 0;
4031 __Pyx_RefNannySetupContext("_py_unhexlify", 0);
4032
4033 /* "breezy/bzr/_btree_serializer_pyx.pyx":355
4034 * def _py_unhexlify(as_hex):
4035 * """For the test infrastructure, just thunks to _unhexlify_sha1"""
4036 * if not PyBytes_CheckExact(as_hex) or PyBytes_GET_SIZE(as_hex) != 40: # <<<<<<<<<<<<<<
4037 * raise ValueError('not a 40-byte hex digest')
4038 * as_bin = PyBytes_FromStringAndSize(NULL, 20)
4039 */
4040 __pyx_t_2 = ((!(PyBytes_CheckExact(__pyx_v_as_hex) != 0)) != 0);
4041 if (!__pyx_t_2) {
4042 } else {
4043 __pyx_t_1 = __pyx_t_2;
4044 goto __pyx_L4_bool_binop_done;
4045 }
4046 __pyx_t_2 = ((PyBytes_GET_SIZE(__pyx_v_as_hex) != 40) != 0);
4047 __pyx_t_1 = __pyx_t_2;
4048 __pyx_L4_bool_binop_done:;
4049 if (unlikely(__pyx_t_1)) {
4050
4051 /* "breezy/bzr/_btree_serializer_pyx.pyx":356
4052 * """For the test infrastructure, just thunks to _unhexlify_sha1"""
4053 * if not PyBytes_CheckExact(as_hex) or PyBytes_GET_SIZE(as_hex) != 40:
4054 * raise ValueError('not a 40-byte hex digest') # <<<<<<<<<<<<<<
4055 * as_bin = PyBytes_FromStringAndSize(NULL, 20)
4056 * if _unhexlify_sha1(PyBytes_AS_STRING(as_hex), PyBytes_AS_STRING(as_bin)):
4057 */
4058 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 356, __pyx_L1_error)
4059 __Pyx_GOTREF(__pyx_t_3);
4060 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
4061 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4062 __PYX_ERR(0, 356, __pyx_L1_error)
4063
4064 /* "breezy/bzr/_btree_serializer_pyx.pyx":355
4065 * def _py_unhexlify(as_hex):
4066 * """For the test infrastructure, just thunks to _unhexlify_sha1"""
4067 * if not PyBytes_CheckExact(as_hex) or PyBytes_GET_SIZE(as_hex) != 40: # <<<<<<<<<<<<<<
4068 * raise ValueError('not a 40-byte hex digest')
4069 * as_bin = PyBytes_FromStringAndSize(NULL, 20)
4070 */
4071 }
4072
4073 /* "breezy/bzr/_btree_serializer_pyx.pyx":357
4074 * if not PyBytes_CheckExact(as_hex) or PyBytes_GET_SIZE(as_hex) != 40:
4075 * raise ValueError('not a 40-byte hex digest')
4076 * as_bin = PyBytes_FromStringAndSize(NULL, 20) # <<<<<<<<<<<<<<
4077 * if _unhexlify_sha1(PyBytes_AS_STRING(as_hex), PyBytes_AS_STRING(as_bin)):
4078 * return as_bin
4079 */
4080 __pyx_t_3 = PyBytes_FromStringAndSize(NULL, 20); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 357, __pyx_L1_error)
4081 __Pyx_GOTREF(__pyx_t_3);
4082 __pyx_v_as_bin = ((PyObject*)__pyx_t_3);
4083 __pyx_t_3 = 0;
4084
4085 /* "breezy/bzr/_btree_serializer_pyx.pyx":358
4086 * raise ValueError('not a 40-byte hex digest')
4087 * as_bin = PyBytes_FromStringAndSize(NULL, 20)
4088 * if _unhexlify_sha1(PyBytes_AS_STRING(as_hex), PyBytes_AS_STRING(as_bin)): # <<<<<<<<<<<<<<
4089 * return as_bin
4090 * return None
4091 */
4092 __pyx_t_1 = (__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__unhexlify_sha1(PyBytes_AS_STRING(__pyx_v_as_hex), PyBytes_AS_STRING(__pyx_v_as_bin)) != 0);
4093 if (__pyx_t_1) {
4094
4095 /* "breezy/bzr/_btree_serializer_pyx.pyx":359
4096 * as_bin = PyBytes_FromStringAndSize(NULL, 20)
4097 * if _unhexlify_sha1(PyBytes_AS_STRING(as_hex), PyBytes_AS_STRING(as_bin)):
4098 * return as_bin # <<<<<<<<<<<<<<
4099 * return None
4100 *
4101 */
4102 __Pyx_XDECREF(__pyx_r);
4103 __Pyx_INCREF(__pyx_v_as_bin);
4104 __pyx_r = __pyx_v_as_bin;
4105 goto __pyx_L0;
4106
4107 /* "breezy/bzr/_btree_serializer_pyx.pyx":358
4108 * raise ValueError('not a 40-byte hex digest')
4109 * as_bin = PyBytes_FromStringAndSize(NULL, 20)
4110 * if _unhexlify_sha1(PyBytes_AS_STRING(as_hex), PyBytes_AS_STRING(as_bin)): # <<<<<<<<<<<<<<
4111 * return as_bin
4112 * return None
4113 */
4114 }
4115
4116 /* "breezy/bzr/_btree_serializer_pyx.pyx":360
4117 * if _unhexlify_sha1(PyBytes_AS_STRING(as_hex), PyBytes_AS_STRING(as_bin)):
4118 * return as_bin
4119 * return None # <<<<<<<<<<<<<<
4120 *
4121 *
4122 */
4123 __Pyx_XDECREF(__pyx_r);
4124 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4125 goto __pyx_L0;
4126
4127 /* "breezy/bzr/_btree_serializer_pyx.pyx":353
4128 *
4129 *
4130 * def _py_unhexlify(as_hex): # <<<<<<<<<<<<<<
4131 * """For the test infrastructure, just thunks to _unhexlify_sha1"""
4132 * if not PyBytes_CheckExact(as_hex) or PyBytes_GET_SIZE(as_hex) != 40:
4133 */
4134
4135 /* function exit code */
4136 __pyx_L1_error:;
4137 __Pyx_XDECREF(__pyx_t_3);
4138 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._py_unhexlify", __pyx_clineno, __pyx_lineno, __pyx_filename);
4139 __pyx_r = NULL;
4140 __pyx_L0:;
4141 __Pyx_XDECREF(__pyx_v_as_bin);
4142 __Pyx_XGIVEREF(__pyx_r);
4143 __Pyx_RefNannyFinishContext();
4144 return __pyx_r;
4145 }
4146
4147 /* "breezy/bzr/_btree_serializer_pyx.pyx":363
4148 *
4149 *
4150 * cdef void _hexlify_sha1(char *as_bin, char *as_hex): # cannot_raise # <<<<<<<<<<<<<<
4151 * cdef int i, j
4152 * cdef char c
4153 */
4154
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__hexlify_sha1(char * __pyx_v_as_bin,char * __pyx_v_as_hex)4155 static void __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__hexlify_sha1(char *__pyx_v_as_bin, char *__pyx_v_as_hex) {
4156 int __pyx_v_i;
4157 int __pyx_v_j;
4158 char __pyx_v_c;
4159 __Pyx_RefNannyDeclarations
4160 __Pyx_RefNannySetupContext("_hexlify_sha1", 0);
4161
4162 /* "breezy/bzr/_btree_serializer_pyx.pyx":367
4163 * cdef char c
4164 *
4165 * j = 0 # <<<<<<<<<<<<<<
4166 * for i from 0 <= i < 20:
4167 * c = as_bin[i]
4168 */
4169 __pyx_v_j = 0;
4170
4171 /* "breezy/bzr/_btree_serializer_pyx.pyx":368
4172 *
4173 * j = 0
4174 * for i from 0 <= i < 20: # <<<<<<<<<<<<<<
4175 * c = as_bin[i]
4176 * as_hex[j] = _hexbuf[(c>>4)&0xf]
4177 */
4178 for (__pyx_v_i = 0; __pyx_v_i < 20; __pyx_v_i++) {
4179
4180 /* "breezy/bzr/_btree_serializer_pyx.pyx":369
4181 * j = 0
4182 * for i from 0 <= i < 20:
4183 * c = as_bin[i] # <<<<<<<<<<<<<<
4184 * as_hex[j] = _hexbuf[(c>>4)&0xf]
4185 * j = j + 1
4186 */
4187 __pyx_v_c = (__pyx_v_as_bin[__pyx_v_i]);
4188
4189 /* "breezy/bzr/_btree_serializer_pyx.pyx":370
4190 * for i from 0 <= i < 20:
4191 * c = as_bin[i]
4192 * as_hex[j] = _hexbuf[(c>>4)&0xf] # <<<<<<<<<<<<<<
4193 * j = j + 1
4194 * as_hex[j] = _hexbuf[(c)&0xf]
4195 */
4196 (__pyx_v_as_hex[__pyx_v_j]) = (__pyx_v_6breezy_3bzr_21_btree_serializer_pyx__hexbuf[((__pyx_v_c >> 4) & 0xf)]);
4197
4198 /* "breezy/bzr/_btree_serializer_pyx.pyx":371
4199 * c = as_bin[i]
4200 * as_hex[j] = _hexbuf[(c>>4)&0xf]
4201 * j = j + 1 # <<<<<<<<<<<<<<
4202 * as_hex[j] = _hexbuf[(c)&0xf]
4203 * j = j + 1
4204 */
4205 __pyx_v_j = (__pyx_v_j + 1);
4206
4207 /* "breezy/bzr/_btree_serializer_pyx.pyx":372
4208 * as_hex[j] = _hexbuf[(c>>4)&0xf]
4209 * j = j + 1
4210 * as_hex[j] = _hexbuf[(c)&0xf] # <<<<<<<<<<<<<<
4211 * j = j + 1
4212 *
4213 */
4214 (__pyx_v_as_hex[__pyx_v_j]) = (__pyx_v_6breezy_3bzr_21_btree_serializer_pyx__hexbuf[(__pyx_v_c & 0xf)]);
4215
4216 /* "breezy/bzr/_btree_serializer_pyx.pyx":373
4217 * j = j + 1
4218 * as_hex[j] = _hexbuf[(c)&0xf]
4219 * j = j + 1 # <<<<<<<<<<<<<<
4220 *
4221 *
4222 */
4223 __pyx_v_j = (__pyx_v_j + 1);
4224 }
4225
4226 /* "breezy/bzr/_btree_serializer_pyx.pyx":363
4227 *
4228 *
4229 * cdef void _hexlify_sha1(char *as_bin, char *as_hex): # cannot_raise # <<<<<<<<<<<<<<
4230 * cdef int i, j
4231 * cdef char c
4232 */
4233
4234 /* function exit code */
4235 __Pyx_RefNannyFinishContext();
4236 }
4237
4238 /* "breezy/bzr/_btree_serializer_pyx.pyx":376
4239 *
4240 *
4241 * def _py_hexlify(as_bin): # <<<<<<<<<<<<<<
4242 * """For test infrastructure, thunk to _hexlify_sha1"""
4243 * if len(as_bin) != 20 or not PyBytes_CheckExact(as_bin):
4244 */
4245
4246 /* Python wrapper */
4247 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_5_py_hexlify(PyObject *__pyx_self, PyObject *__pyx_v_as_bin); /*proto*/
4248 static char __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_4_py_hexlify[] = "For test infrastructure, thunk to _hexlify_sha1";
4249 static PyMethodDef __pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_5_py_hexlify = {"_py_hexlify", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_5_py_hexlify, METH_O, __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_4_py_hexlify};
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_5_py_hexlify(PyObject * __pyx_self,PyObject * __pyx_v_as_bin)4250 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_5_py_hexlify(PyObject *__pyx_self, PyObject *__pyx_v_as_bin) {
4251 PyObject *__pyx_r = 0;
4252 __Pyx_RefNannyDeclarations
4253 __Pyx_RefNannySetupContext("_py_hexlify (wrapper)", 0);
4254 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_4_py_hexlify(__pyx_self, ((PyObject *)__pyx_v_as_bin));
4255
4256 /* function exit code */
4257 __Pyx_RefNannyFinishContext();
4258 return __pyx_r;
4259 }
4260
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_4_py_hexlify(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_as_bin)4261 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_4_py_hexlify(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_as_bin) {
4262 PyObject *__pyx_v_as_hex = NULL;
4263 PyObject *__pyx_r = NULL;
4264 __Pyx_RefNannyDeclarations
4265 int __pyx_t_1;
4266 Py_ssize_t __pyx_t_2;
4267 int __pyx_t_3;
4268 PyObject *__pyx_t_4 = NULL;
4269 int __pyx_lineno = 0;
4270 const char *__pyx_filename = NULL;
4271 int __pyx_clineno = 0;
4272 __Pyx_RefNannySetupContext("_py_hexlify", 0);
4273
4274 /* "breezy/bzr/_btree_serializer_pyx.pyx":378
4275 * def _py_hexlify(as_bin):
4276 * """For test infrastructure, thunk to _hexlify_sha1"""
4277 * if len(as_bin) != 20 or not PyBytes_CheckExact(as_bin): # <<<<<<<<<<<<<<
4278 * raise ValueError('not a 20-byte binary digest')
4279 * as_hex = PyBytes_FromStringAndSize(NULL, 40)
4280 */
4281 __pyx_t_2 = PyObject_Length(__pyx_v_as_bin); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 378, __pyx_L1_error)
4282 __pyx_t_3 = ((__pyx_t_2 != 20) != 0);
4283 if (!__pyx_t_3) {
4284 } else {
4285 __pyx_t_1 = __pyx_t_3;
4286 goto __pyx_L4_bool_binop_done;
4287 }
4288 __pyx_t_3 = ((!(PyBytes_CheckExact(__pyx_v_as_bin) != 0)) != 0);
4289 __pyx_t_1 = __pyx_t_3;
4290 __pyx_L4_bool_binop_done:;
4291 if (unlikely(__pyx_t_1)) {
4292
4293 /* "breezy/bzr/_btree_serializer_pyx.pyx":379
4294 * """For test infrastructure, thunk to _hexlify_sha1"""
4295 * if len(as_bin) != 20 or not PyBytes_CheckExact(as_bin):
4296 * raise ValueError('not a 20-byte binary digest') # <<<<<<<<<<<<<<
4297 * as_hex = PyBytes_FromStringAndSize(NULL, 40)
4298 * _hexlify_sha1(PyBytes_AS_STRING(as_bin), PyBytes_AS_STRING(as_hex))
4299 */
4300 __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 379, __pyx_L1_error)
4301 __Pyx_GOTREF(__pyx_t_4);
4302 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
4303 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4304 __PYX_ERR(0, 379, __pyx_L1_error)
4305
4306 /* "breezy/bzr/_btree_serializer_pyx.pyx":378
4307 * def _py_hexlify(as_bin):
4308 * """For test infrastructure, thunk to _hexlify_sha1"""
4309 * if len(as_bin) != 20 or not PyBytes_CheckExact(as_bin): # <<<<<<<<<<<<<<
4310 * raise ValueError('not a 20-byte binary digest')
4311 * as_hex = PyBytes_FromStringAndSize(NULL, 40)
4312 */
4313 }
4314
4315 /* "breezy/bzr/_btree_serializer_pyx.pyx":380
4316 * if len(as_bin) != 20 or not PyBytes_CheckExact(as_bin):
4317 * raise ValueError('not a 20-byte binary digest')
4318 * as_hex = PyBytes_FromStringAndSize(NULL, 40) # <<<<<<<<<<<<<<
4319 * _hexlify_sha1(PyBytes_AS_STRING(as_bin), PyBytes_AS_STRING(as_hex))
4320 * return as_hex
4321 */
4322 __pyx_t_4 = PyBytes_FromStringAndSize(NULL, 40); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
4323 __Pyx_GOTREF(__pyx_t_4);
4324 __pyx_v_as_hex = ((PyObject*)__pyx_t_4);
4325 __pyx_t_4 = 0;
4326
4327 /* "breezy/bzr/_btree_serializer_pyx.pyx":381
4328 * raise ValueError('not a 20-byte binary digest')
4329 * as_hex = PyBytes_FromStringAndSize(NULL, 40)
4330 * _hexlify_sha1(PyBytes_AS_STRING(as_bin), PyBytes_AS_STRING(as_hex)) # <<<<<<<<<<<<<<
4331 * return as_hex
4332 *
4333 */
4334 __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__hexlify_sha1(PyBytes_AS_STRING(__pyx_v_as_bin), PyBytes_AS_STRING(__pyx_v_as_hex));
4335
4336 /* "breezy/bzr/_btree_serializer_pyx.pyx":382
4337 * as_hex = PyBytes_FromStringAndSize(NULL, 40)
4338 * _hexlify_sha1(PyBytes_AS_STRING(as_bin), PyBytes_AS_STRING(as_hex))
4339 * return as_hex # <<<<<<<<<<<<<<
4340 *
4341 *
4342 */
4343 __Pyx_XDECREF(__pyx_r);
4344 __Pyx_INCREF(__pyx_v_as_hex);
4345 __pyx_r = __pyx_v_as_hex;
4346 goto __pyx_L0;
4347
4348 /* "breezy/bzr/_btree_serializer_pyx.pyx":376
4349 *
4350 *
4351 * def _py_hexlify(as_bin): # <<<<<<<<<<<<<<
4352 * """For test infrastructure, thunk to _hexlify_sha1"""
4353 * if len(as_bin) != 20 or not PyBytes_CheckExact(as_bin):
4354 */
4355
4356 /* function exit code */
4357 __pyx_L1_error:;
4358 __Pyx_XDECREF(__pyx_t_4);
4359 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._py_hexlify", __pyx_clineno, __pyx_lineno, __pyx_filename);
4360 __pyx_r = NULL;
4361 __pyx_L0:;
4362 __Pyx_XDECREF(__pyx_v_as_hex);
4363 __Pyx_XGIVEREF(__pyx_r);
4364 __Pyx_RefNannyFinishContext();
4365 return __pyx_r;
4366 }
4367
4368 /* "breezy/bzr/_btree_serializer_pyx.pyx":385
4369 *
4370 *
4371 * cdef int _key_to_sha1(key, char *sha1): # cannot_raise # <<<<<<<<<<<<<<
4372 * """Map a key into its sha1 content.
4373 *
4374 */
4375
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__key_to_sha1(PyObject * __pyx_v_key,char * __pyx_v_sha1)4376 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__key_to_sha1(PyObject *__pyx_v_key, char *__pyx_v_sha1) {
4377 char *__pyx_v_c_val;
4378 PyObject *__pyx_v_p_val;
4379 int __pyx_r;
4380 __Pyx_RefNannyDeclarations
4381 int __pyx_t_1;
4382 int __pyx_t_2;
4383 int __pyx_lineno = 0;
4384 const char *__pyx_filename = NULL;
4385 int __pyx_clineno = 0;
4386 __Pyx_RefNannySetupContext("_key_to_sha1", 0);
4387
4388 /* "breezy/bzr/_btree_serializer_pyx.pyx":395
4389 * cdef PyObject *p_val
4390 *
4391 * if StaticTuple_CheckExact(key) and StaticTuple_GET_SIZE(key) == 1: # <<<<<<<<<<<<<<
4392 * p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0)
4393 * elif PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1:
4394 */
4395 __pyx_t_2 = (StaticTuple_CheckExact(__pyx_v_key) != 0);
4396 if (__pyx_t_2) {
4397 } else {
4398 __pyx_t_1 = __pyx_t_2;
4399 goto __pyx_L4_bool_binop_done;
4400 }
4401 if (!(likely(((__pyx_v_key) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_key, __pyx_ptype_6breezy_15_static_tuple_c_StaticTuple))))) __PYX_ERR(0, 395, __pyx_L1_error)
4402 __pyx_t_2 = ((StaticTuple_GET_SIZE(((StaticTuple *)__pyx_v_key)) == 1) != 0);
4403 __pyx_t_1 = __pyx_t_2;
4404 __pyx_L4_bool_binop_done:;
4405 if (__pyx_t_1) {
4406
4407 /* "breezy/bzr/_btree_serializer_pyx.pyx":396
4408 *
4409 * if StaticTuple_CheckExact(key) and StaticTuple_GET_SIZE(key) == 1:
4410 * p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0) # <<<<<<<<<<<<<<
4411 * elif PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1:
4412 * p_val = PyTuple_GET_ITEM(key, 0)
4413 */
4414 if (!(likely(((__pyx_v_key) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_key, __pyx_ptype_6breezy_15_static_tuple_c_StaticTuple))))) __PYX_ERR(0, 396, __pyx_L1_error)
4415 __pyx_v_p_val = ((PyObject *)StaticTuple_GET_ITEM(((StaticTuple *)__pyx_v_key), 0));
4416
4417 /* "breezy/bzr/_btree_serializer_pyx.pyx":395
4418 * cdef PyObject *p_val
4419 *
4420 * if StaticTuple_CheckExact(key) and StaticTuple_GET_SIZE(key) == 1: # <<<<<<<<<<<<<<
4421 * p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0)
4422 * elif PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1:
4423 */
4424 goto __pyx_L3;
4425 }
4426
4427 /* "breezy/bzr/_btree_serializer_pyx.pyx":397
4428 * if StaticTuple_CheckExact(key) and StaticTuple_GET_SIZE(key) == 1:
4429 * p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0)
4430 * elif PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1: # <<<<<<<<<<<<<<
4431 * p_val = PyTuple_GET_ITEM(key, 0)
4432 * else:
4433 */
4434 __pyx_t_2 = (PyTuple_CheckExact(__pyx_v_key) != 0);
4435 if (__pyx_t_2) {
4436 } else {
4437 __pyx_t_1 = __pyx_t_2;
4438 goto __pyx_L6_bool_binop_done;
4439 }
4440 __pyx_t_2 = ((PyTuple_GET_SIZE(__pyx_v_key) == 1) != 0);
4441 __pyx_t_1 = __pyx_t_2;
4442 __pyx_L6_bool_binop_done:;
4443 if (__pyx_t_1) {
4444
4445 /* "breezy/bzr/_btree_serializer_pyx.pyx":398
4446 * p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0)
4447 * elif PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1:
4448 * p_val = PyTuple_GET_ITEM(key, 0) # <<<<<<<<<<<<<<
4449 * else:
4450 * # Not a tuple or a StaticTuple
4451 */
4452 __pyx_v_p_val = PyTuple_GET_ITEM(__pyx_v_key, 0);
4453
4454 /* "breezy/bzr/_btree_serializer_pyx.pyx":397
4455 * if StaticTuple_CheckExact(key) and StaticTuple_GET_SIZE(key) == 1:
4456 * p_val = <PyObject *>StaticTuple_GET_ITEM(key, 0)
4457 * elif PyTuple_CheckExact(key) and PyTuple_GET_SIZE(key) == 1: # <<<<<<<<<<<<<<
4458 * p_val = PyTuple_GET_ITEM(key, 0)
4459 * else:
4460 */
4461 goto __pyx_L3;
4462 }
4463
4464 /* "breezy/bzr/_btree_serializer_pyx.pyx":401
4465 * else:
4466 * # Not a tuple or a StaticTuple
4467 * return 0 # <<<<<<<<<<<<<<
4468 * if (PyBytes_CheckExact(<object>p_val)
4469 * and PyBytes_GET_SIZE(<object>p_val) == 45):
4470 */
4471 /*else*/ {
4472 __pyx_r = 0;
4473 goto __pyx_L0;
4474 }
4475 __pyx_L3:;
4476
4477 /* "breezy/bzr/_btree_serializer_pyx.pyx":402
4478 * # Not a tuple or a StaticTuple
4479 * return 0
4480 * if (PyBytes_CheckExact(<object>p_val) # <<<<<<<<<<<<<<
4481 * and PyBytes_GET_SIZE(<object>p_val) == 45):
4482 * c_val = PyBytes_AS_STRING(<object>p_val)
4483 */
4484 __pyx_t_2 = (PyBytes_CheckExact(((PyObject *)__pyx_v_p_val)) != 0);
4485 if (__pyx_t_2) {
4486 } else {
4487 __pyx_t_1 = __pyx_t_2;
4488 goto __pyx_L9_bool_binop_done;
4489 }
4490
4491 /* "breezy/bzr/_btree_serializer_pyx.pyx":403
4492 * return 0
4493 * if (PyBytes_CheckExact(<object>p_val)
4494 * and PyBytes_GET_SIZE(<object>p_val) == 45): # <<<<<<<<<<<<<<
4495 * c_val = PyBytes_AS_STRING(<object>p_val)
4496 * else:
4497 */
4498 __pyx_t_2 = ((PyBytes_GET_SIZE(((PyObject *)__pyx_v_p_val)) == 45) != 0);
4499 __pyx_t_1 = __pyx_t_2;
4500 __pyx_L9_bool_binop_done:;
4501
4502 /* "breezy/bzr/_btree_serializer_pyx.pyx":402
4503 * # Not a tuple or a StaticTuple
4504 * return 0
4505 * if (PyBytes_CheckExact(<object>p_val) # <<<<<<<<<<<<<<
4506 * and PyBytes_GET_SIZE(<object>p_val) == 45):
4507 * c_val = PyBytes_AS_STRING(<object>p_val)
4508 */
4509 if (__pyx_t_1) {
4510
4511 /* "breezy/bzr/_btree_serializer_pyx.pyx":404
4512 * if (PyBytes_CheckExact(<object>p_val)
4513 * and PyBytes_GET_SIZE(<object>p_val) == 45):
4514 * c_val = PyBytes_AS_STRING(<object>p_val) # <<<<<<<<<<<<<<
4515 * else:
4516 * return 0
4517 */
4518 __pyx_v_c_val = PyBytes_AS_STRING(((PyObject *)__pyx_v_p_val));
4519
4520 /* "breezy/bzr/_btree_serializer_pyx.pyx":402
4521 * # Not a tuple or a StaticTuple
4522 * return 0
4523 * if (PyBytes_CheckExact(<object>p_val) # <<<<<<<<<<<<<<
4524 * and PyBytes_GET_SIZE(<object>p_val) == 45):
4525 * c_val = PyBytes_AS_STRING(<object>p_val)
4526 */
4527 goto __pyx_L8;
4528 }
4529
4530 /* "breezy/bzr/_btree_serializer_pyx.pyx":406
4531 * c_val = PyBytes_AS_STRING(<object>p_val)
4532 * else:
4533 * return 0 # <<<<<<<<<<<<<<
4534 * if strncmp(c_val, b'sha1:', 5) != 0:
4535 * return 0
4536 */
4537 /*else*/ {
4538 __pyx_r = 0;
4539 goto __pyx_L0;
4540 }
4541 __pyx_L8:;
4542
4543 /* "breezy/bzr/_btree_serializer_pyx.pyx":407
4544 * else:
4545 * return 0
4546 * if strncmp(c_val, b'sha1:', 5) != 0: # <<<<<<<<<<<<<<
4547 * return 0
4548 * if not _unhexlify_sha1(c_val + 5, sha1):
4549 */
4550 __pyx_t_1 = ((strncmp(__pyx_v_c_val, ((char const *)"sha1:"), 5) != 0) != 0);
4551 if (__pyx_t_1) {
4552
4553 /* "breezy/bzr/_btree_serializer_pyx.pyx":408
4554 * return 0
4555 * if strncmp(c_val, b'sha1:', 5) != 0:
4556 * return 0 # <<<<<<<<<<<<<<
4557 * if not _unhexlify_sha1(c_val + 5, sha1):
4558 * return 0
4559 */
4560 __pyx_r = 0;
4561 goto __pyx_L0;
4562
4563 /* "breezy/bzr/_btree_serializer_pyx.pyx":407
4564 * else:
4565 * return 0
4566 * if strncmp(c_val, b'sha1:', 5) != 0: # <<<<<<<<<<<<<<
4567 * return 0
4568 * if not _unhexlify_sha1(c_val + 5, sha1):
4569 */
4570 }
4571
4572 /* "breezy/bzr/_btree_serializer_pyx.pyx":409
4573 * if strncmp(c_val, b'sha1:', 5) != 0:
4574 * return 0
4575 * if not _unhexlify_sha1(c_val + 5, sha1): # <<<<<<<<<<<<<<
4576 * return 0
4577 * return 1
4578 */
4579 __pyx_t_1 = ((!(__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__unhexlify_sha1((__pyx_v_c_val + 5), __pyx_v_sha1) != 0)) != 0);
4580 if (__pyx_t_1) {
4581
4582 /* "breezy/bzr/_btree_serializer_pyx.pyx":410
4583 * return 0
4584 * if not _unhexlify_sha1(c_val + 5, sha1):
4585 * return 0 # <<<<<<<<<<<<<<
4586 * return 1
4587 *
4588 */
4589 __pyx_r = 0;
4590 goto __pyx_L0;
4591
4592 /* "breezy/bzr/_btree_serializer_pyx.pyx":409
4593 * if strncmp(c_val, b'sha1:', 5) != 0:
4594 * return 0
4595 * if not _unhexlify_sha1(c_val + 5, sha1): # <<<<<<<<<<<<<<
4596 * return 0
4597 * return 1
4598 */
4599 }
4600
4601 /* "breezy/bzr/_btree_serializer_pyx.pyx":411
4602 * if not _unhexlify_sha1(c_val + 5, sha1):
4603 * return 0
4604 * return 1 # <<<<<<<<<<<<<<
4605 *
4606 *
4607 */
4608 __pyx_r = 1;
4609 goto __pyx_L0;
4610
4611 /* "breezy/bzr/_btree_serializer_pyx.pyx":385
4612 *
4613 *
4614 * cdef int _key_to_sha1(key, char *sha1): # cannot_raise # <<<<<<<<<<<<<<
4615 * """Map a key into its sha1 content.
4616 *
4617 */
4618
4619 /* function exit code */
4620 __pyx_L1_error:;
4621 __Pyx_WriteUnraisable("breezy.bzr._btree_serializer_pyx._key_to_sha1", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
4622 __pyx_r = 0;
4623 __pyx_L0:;
4624 __Pyx_RefNannyFinishContext();
4625 return __pyx_r;
4626 }
4627
4628 /* "breezy/bzr/_btree_serializer_pyx.pyx":414
4629 *
4630 *
4631 * def _py_key_to_sha1(key): # <<<<<<<<<<<<<<
4632 * """Map a key to a simple sha1 string.
4633 *
4634 */
4635
4636 /* Python wrapper */
4637 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_7_py_key_to_sha1(PyObject *__pyx_self, PyObject *__pyx_v_key); /*proto*/
4638 static char __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_6_py_key_to_sha1[] = "Map a key to a simple sha1 string.\n\n This is a testing thunk to the C function.\n ";
4639 static PyMethodDef __pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_7_py_key_to_sha1 = {"_py_key_to_sha1", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_7_py_key_to_sha1, METH_O, __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_6_py_key_to_sha1};
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_7_py_key_to_sha1(PyObject * __pyx_self,PyObject * __pyx_v_key)4640 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_7_py_key_to_sha1(PyObject *__pyx_self, PyObject *__pyx_v_key) {
4641 PyObject *__pyx_r = 0;
4642 __Pyx_RefNannyDeclarations
4643 __Pyx_RefNannySetupContext("_py_key_to_sha1 (wrapper)", 0);
4644 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_6_py_key_to_sha1(__pyx_self, ((PyObject *)__pyx_v_key));
4645
4646 /* function exit code */
4647 __Pyx_RefNannyFinishContext();
4648 return __pyx_r;
4649 }
4650
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_6_py_key_to_sha1(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_key)4651 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_6_py_key_to_sha1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_key) {
4652 PyObject *__pyx_v_as_bin_sha = NULL;
4653 PyObject *__pyx_r = NULL;
4654 __Pyx_RefNannyDeclarations
4655 PyObject *__pyx_t_1 = NULL;
4656 int __pyx_t_2;
4657 int __pyx_lineno = 0;
4658 const char *__pyx_filename = NULL;
4659 int __pyx_clineno = 0;
4660 __Pyx_RefNannySetupContext("_py_key_to_sha1", 0);
4661
4662 /* "breezy/bzr/_btree_serializer_pyx.pyx":419
4663 * This is a testing thunk to the C function.
4664 * """
4665 * as_bin_sha = PyBytes_FromStringAndSize(NULL, 20) # <<<<<<<<<<<<<<
4666 * if _key_to_sha1(key, PyBytes_AS_STRING(as_bin_sha)):
4667 * return as_bin_sha
4668 */
4669 __pyx_t_1 = PyBytes_FromStringAndSize(NULL, 20); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __pyx_L1_error)
4670 __Pyx_GOTREF(__pyx_t_1);
4671 __pyx_v_as_bin_sha = ((PyObject*)__pyx_t_1);
4672 __pyx_t_1 = 0;
4673
4674 /* "breezy/bzr/_btree_serializer_pyx.pyx":420
4675 * """
4676 * as_bin_sha = PyBytes_FromStringAndSize(NULL, 20)
4677 * if _key_to_sha1(key, PyBytes_AS_STRING(as_bin_sha)): # <<<<<<<<<<<<<<
4678 * return as_bin_sha
4679 * return None
4680 */
4681 __pyx_t_2 = (__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__key_to_sha1(__pyx_v_key, PyBytes_AS_STRING(__pyx_v_as_bin_sha)) != 0);
4682 if (__pyx_t_2) {
4683
4684 /* "breezy/bzr/_btree_serializer_pyx.pyx":421
4685 * as_bin_sha = PyBytes_FromStringAndSize(NULL, 20)
4686 * if _key_to_sha1(key, PyBytes_AS_STRING(as_bin_sha)):
4687 * return as_bin_sha # <<<<<<<<<<<<<<
4688 * return None
4689 *
4690 */
4691 __Pyx_XDECREF(__pyx_r);
4692 __Pyx_INCREF(__pyx_v_as_bin_sha);
4693 __pyx_r = __pyx_v_as_bin_sha;
4694 goto __pyx_L0;
4695
4696 /* "breezy/bzr/_btree_serializer_pyx.pyx":420
4697 * """
4698 * as_bin_sha = PyBytes_FromStringAndSize(NULL, 20)
4699 * if _key_to_sha1(key, PyBytes_AS_STRING(as_bin_sha)): # <<<<<<<<<<<<<<
4700 * return as_bin_sha
4701 * return None
4702 */
4703 }
4704
4705 /* "breezy/bzr/_btree_serializer_pyx.pyx":422
4706 * if _key_to_sha1(key, PyBytes_AS_STRING(as_bin_sha)):
4707 * return as_bin_sha
4708 * return None # <<<<<<<<<<<<<<
4709 *
4710 *
4711 */
4712 __Pyx_XDECREF(__pyx_r);
4713 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4714 goto __pyx_L0;
4715
4716 /* "breezy/bzr/_btree_serializer_pyx.pyx":414
4717 *
4718 *
4719 * def _py_key_to_sha1(key): # <<<<<<<<<<<<<<
4720 * """Map a key to a simple sha1 string.
4721 *
4722 */
4723
4724 /* function exit code */
4725 __pyx_L1_error:;
4726 __Pyx_XDECREF(__pyx_t_1);
4727 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._py_key_to_sha1", __pyx_clineno, __pyx_lineno, __pyx_filename);
4728 __pyx_r = NULL;
4729 __pyx_L0:;
4730 __Pyx_XDECREF(__pyx_v_as_bin_sha);
4731 __Pyx_XGIVEREF(__pyx_r);
4732 __Pyx_RefNannyFinishContext();
4733 return __pyx_r;
4734 }
4735
4736 /* "breezy/bzr/_btree_serializer_pyx.pyx":425
4737 *
4738 *
4739 * cdef StaticTuple _sha1_to_key(char *sha1): # <<<<<<<<<<<<<<
4740 * """Compute a ('sha1:abcd',) key for a given sha1."""
4741 * cdef StaticTuple key
4742 */
4743
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_key(char * __pyx_v_sha1)4744 static StaticTuple *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_key(char *__pyx_v_sha1) {
4745 StaticTuple *__pyx_v_key = 0;
4746 PyObject *__pyx_v_hexxed = 0;
4747 char *__pyx_v_c_buf;
4748 StaticTuple *__pyx_r = NULL;
4749 __Pyx_RefNannyDeclarations
4750 PyObject *__pyx_t_1 = NULL;
4751 int __pyx_lineno = 0;
4752 const char *__pyx_filename = NULL;
4753 int __pyx_clineno = 0;
4754 __Pyx_RefNannySetupContext("_sha1_to_key", 0);
4755
4756 /* "breezy/bzr/_btree_serializer_pyx.pyx":430
4757 * cdef object hexxed
4758 * cdef char *c_buf
4759 * hexxed = PyBytes_FromStringAndSize(NULL, 45) # <<<<<<<<<<<<<<
4760 * c_buf = PyBytes_AS_STRING(hexxed)
4761 * memcpy(c_buf, b'sha1:', 5)
4762 */
4763 __pyx_t_1 = PyBytes_FromStringAndSize(NULL, 45); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error)
4764 __Pyx_GOTREF(__pyx_t_1);
4765 __pyx_v_hexxed = __pyx_t_1;
4766 __pyx_t_1 = 0;
4767
4768 /* "breezy/bzr/_btree_serializer_pyx.pyx":431
4769 * cdef char *c_buf
4770 * hexxed = PyBytes_FromStringAndSize(NULL, 45)
4771 * c_buf = PyBytes_AS_STRING(hexxed) # <<<<<<<<<<<<<<
4772 * memcpy(c_buf, b'sha1:', 5)
4773 * _hexlify_sha1(sha1, c_buf+5)
4774 */
4775 __pyx_v_c_buf = PyBytes_AS_STRING(__pyx_v_hexxed);
4776
4777 /* "breezy/bzr/_btree_serializer_pyx.pyx":432
4778 * hexxed = PyBytes_FromStringAndSize(NULL, 45)
4779 * c_buf = PyBytes_AS_STRING(hexxed)
4780 * memcpy(c_buf, b'sha1:', 5) # <<<<<<<<<<<<<<
4781 * _hexlify_sha1(sha1, c_buf+5)
4782 * key = StaticTuple_New(1)
4783 */
4784 (void)(memcpy(__pyx_v_c_buf, ((char *)"sha1:"), 5));
4785
4786 /* "breezy/bzr/_btree_serializer_pyx.pyx":433
4787 * c_buf = PyBytes_AS_STRING(hexxed)
4788 * memcpy(c_buf, b'sha1:', 5)
4789 * _hexlify_sha1(sha1, c_buf+5) # <<<<<<<<<<<<<<
4790 * key = StaticTuple_New(1)
4791 * Py_INCREF(hexxed)
4792 */
4793 __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__hexlify_sha1(__pyx_v_sha1, (__pyx_v_c_buf + 5));
4794
4795 /* "breezy/bzr/_btree_serializer_pyx.pyx":434
4796 * memcpy(c_buf, b'sha1:', 5)
4797 * _hexlify_sha1(sha1, c_buf+5)
4798 * key = StaticTuple_New(1) # <<<<<<<<<<<<<<
4799 * Py_INCREF(hexxed)
4800 * StaticTuple_SET_ITEM(key, 0, hexxed)
4801 */
4802 __pyx_t_1 = ((PyObject *)StaticTuple_New(1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 434, __pyx_L1_error)
4803 __Pyx_GOTREF(__pyx_t_1);
4804 __pyx_v_key = ((StaticTuple *)__pyx_t_1);
4805 __pyx_t_1 = 0;
4806
4807 /* "breezy/bzr/_btree_serializer_pyx.pyx":435
4808 * _hexlify_sha1(sha1, c_buf+5)
4809 * key = StaticTuple_New(1)
4810 * Py_INCREF(hexxed) # <<<<<<<<<<<<<<
4811 * StaticTuple_SET_ITEM(key, 0, hexxed)
4812 * # This is a bit expensive. To parse 120 keys takes 48us, to return them all
4813 */
4814 Py_INCREF(__pyx_v_hexxed);
4815
4816 /* "breezy/bzr/_btree_serializer_pyx.pyx":436
4817 * key = StaticTuple_New(1)
4818 * Py_INCREF(hexxed)
4819 * StaticTuple_SET_ITEM(key, 0, hexxed) # <<<<<<<<<<<<<<
4820 * # This is a bit expensive. To parse 120 keys takes 48us, to return them all
4821 * # can be done in 66.6us (so 18.6us to build them all).
4822 */
4823 StaticTuple_SET_ITEM(__pyx_v_key, 0, __pyx_v_hexxed);
4824
4825 /* "breezy/bzr/_btree_serializer_pyx.pyx":446
4826 * # We *could* hang the PyObject form off of the gc_chk_sha1_record for ones
4827 * # that we have deserialized. Something to think about, at least.
4828 * key = StaticTuple_Intern(key) # <<<<<<<<<<<<<<
4829 * return key
4830 *
4831 */
4832 __pyx_t_1 = ((PyObject *)StaticTuple_Intern(__pyx_v_key)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
4833 __Pyx_GOTREF(__pyx_t_1);
4834 __Pyx_DECREF_SET(__pyx_v_key, ((StaticTuple *)__pyx_t_1));
4835 __pyx_t_1 = 0;
4836
4837 /* "breezy/bzr/_btree_serializer_pyx.pyx":447
4838 * # that we have deserialized. Something to think about, at least.
4839 * key = StaticTuple_Intern(key)
4840 * return key # <<<<<<<<<<<<<<
4841 *
4842 *
4843 */
4844 __Pyx_XDECREF(((PyObject *)__pyx_r));
4845 __Pyx_INCREF(((PyObject *)__pyx_v_key));
4846 __pyx_r = __pyx_v_key;
4847 goto __pyx_L0;
4848
4849 /* "breezy/bzr/_btree_serializer_pyx.pyx":425
4850 *
4851 *
4852 * cdef StaticTuple _sha1_to_key(char *sha1): # <<<<<<<<<<<<<<
4853 * """Compute a ('sha1:abcd',) key for a given sha1."""
4854 * cdef StaticTuple key
4855 */
4856
4857 /* function exit code */
4858 __pyx_L1_error:;
4859 __Pyx_XDECREF(__pyx_t_1);
4860 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._sha1_to_key", __pyx_clineno, __pyx_lineno, __pyx_filename);
4861 __pyx_r = 0;
4862 __pyx_L0:;
4863 __Pyx_XDECREF((PyObject *)__pyx_v_key);
4864 __Pyx_XDECREF(__pyx_v_hexxed);
4865 __Pyx_XGIVEREF((PyObject *)__pyx_r);
4866 __Pyx_RefNannyFinishContext();
4867 return __pyx_r;
4868 }
4869
4870 /* "breezy/bzr/_btree_serializer_pyx.pyx":450
4871 *
4872 *
4873 * def _py_sha1_to_key(sha1_bin): # <<<<<<<<<<<<<<
4874 * """Test thunk to check the sha1 mapping."""
4875 * if not PyBytes_CheckExact(sha1_bin) or PyBytes_GET_SIZE(sha1_bin) != 20:
4876 */
4877
4878 /* Python wrapper */
4879 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_9_py_sha1_to_key(PyObject *__pyx_self, PyObject *__pyx_v_sha1_bin); /*proto*/
4880 static char __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_8_py_sha1_to_key[] = "Test thunk to check the sha1 mapping.";
4881 static PyMethodDef __pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_9_py_sha1_to_key = {"_py_sha1_to_key", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_9_py_sha1_to_key, METH_O, __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_8_py_sha1_to_key};
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_9_py_sha1_to_key(PyObject * __pyx_self,PyObject * __pyx_v_sha1_bin)4882 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_9_py_sha1_to_key(PyObject *__pyx_self, PyObject *__pyx_v_sha1_bin) {
4883 PyObject *__pyx_r = 0;
4884 __Pyx_RefNannyDeclarations
4885 __Pyx_RefNannySetupContext("_py_sha1_to_key (wrapper)", 0);
4886 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_8_py_sha1_to_key(__pyx_self, ((PyObject *)__pyx_v_sha1_bin));
4887
4888 /* function exit code */
4889 __Pyx_RefNannyFinishContext();
4890 return __pyx_r;
4891 }
4892
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_8_py_sha1_to_key(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_sha1_bin)4893 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_8_py_sha1_to_key(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sha1_bin) {
4894 PyObject *__pyx_r = NULL;
4895 __Pyx_RefNannyDeclarations
4896 int __pyx_t_1;
4897 int __pyx_t_2;
4898 PyObject *__pyx_t_3 = NULL;
4899 int __pyx_lineno = 0;
4900 const char *__pyx_filename = NULL;
4901 int __pyx_clineno = 0;
4902 __Pyx_RefNannySetupContext("_py_sha1_to_key", 0);
4903
4904 /* "breezy/bzr/_btree_serializer_pyx.pyx":452
4905 * def _py_sha1_to_key(sha1_bin):
4906 * """Test thunk to check the sha1 mapping."""
4907 * if not PyBytes_CheckExact(sha1_bin) or PyBytes_GET_SIZE(sha1_bin) != 20: # <<<<<<<<<<<<<<
4908 * raise ValueError('sha1_bin must be a str of exactly 20 bytes')
4909 * return _sha1_to_key(PyBytes_AS_STRING(sha1_bin))
4910 */
4911 __pyx_t_2 = ((!(PyBytes_CheckExact(__pyx_v_sha1_bin) != 0)) != 0);
4912 if (!__pyx_t_2) {
4913 } else {
4914 __pyx_t_1 = __pyx_t_2;
4915 goto __pyx_L4_bool_binop_done;
4916 }
4917 __pyx_t_2 = ((PyBytes_GET_SIZE(__pyx_v_sha1_bin) != 20) != 0);
4918 __pyx_t_1 = __pyx_t_2;
4919 __pyx_L4_bool_binop_done:;
4920 if (unlikely(__pyx_t_1)) {
4921
4922 /* "breezy/bzr/_btree_serializer_pyx.pyx":453
4923 * """Test thunk to check the sha1 mapping."""
4924 * if not PyBytes_CheckExact(sha1_bin) or PyBytes_GET_SIZE(sha1_bin) != 20:
4925 * raise ValueError('sha1_bin must be a str of exactly 20 bytes') # <<<<<<<<<<<<<<
4926 * return _sha1_to_key(PyBytes_AS_STRING(sha1_bin))
4927 *
4928 */
4929 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 453, __pyx_L1_error)
4930 __Pyx_GOTREF(__pyx_t_3);
4931 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
4932 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4933 __PYX_ERR(0, 453, __pyx_L1_error)
4934
4935 /* "breezy/bzr/_btree_serializer_pyx.pyx":452
4936 * def _py_sha1_to_key(sha1_bin):
4937 * """Test thunk to check the sha1 mapping."""
4938 * if not PyBytes_CheckExact(sha1_bin) or PyBytes_GET_SIZE(sha1_bin) != 20: # <<<<<<<<<<<<<<
4939 * raise ValueError('sha1_bin must be a str of exactly 20 bytes')
4940 * return _sha1_to_key(PyBytes_AS_STRING(sha1_bin))
4941 */
4942 }
4943
4944 /* "breezy/bzr/_btree_serializer_pyx.pyx":454
4945 * if not PyBytes_CheckExact(sha1_bin) or PyBytes_GET_SIZE(sha1_bin) != 20:
4946 * raise ValueError('sha1_bin must be a str of exactly 20 bytes')
4947 * return _sha1_to_key(PyBytes_AS_STRING(sha1_bin)) # <<<<<<<<<<<<<<
4948 *
4949 *
4950 */
4951 __Pyx_XDECREF(__pyx_r);
4952 __pyx_t_3 = ((PyObject *)__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_key(PyBytes_AS_STRING(__pyx_v_sha1_bin))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L1_error)
4953 __Pyx_GOTREF(__pyx_t_3);
4954 __pyx_r = __pyx_t_3;
4955 __pyx_t_3 = 0;
4956 goto __pyx_L0;
4957
4958 /* "breezy/bzr/_btree_serializer_pyx.pyx":450
4959 *
4960 *
4961 * def _py_sha1_to_key(sha1_bin): # <<<<<<<<<<<<<<
4962 * """Test thunk to check the sha1 mapping."""
4963 * if not PyBytes_CheckExact(sha1_bin) or PyBytes_GET_SIZE(sha1_bin) != 20:
4964 */
4965
4966 /* function exit code */
4967 __pyx_L1_error:;
4968 __Pyx_XDECREF(__pyx_t_3);
4969 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._py_sha1_to_key", __pyx_clineno, __pyx_lineno, __pyx_filename);
4970 __pyx_r = NULL;
4971 __pyx_L0:;
4972 __Pyx_XGIVEREF(__pyx_r);
4973 __Pyx_RefNannyFinishContext();
4974 return __pyx_r;
4975 }
4976
4977 /* "breezy/bzr/_btree_serializer_pyx.pyx":457
4978 *
4979 *
4980 * cdef unsigned int _sha1_to_uint(char *sha1): # cannot_raise # <<<<<<<<<<<<<<
4981 * cdef unsigned int val
4982 * # Must be in MSB, because that is how the content is sorted
4983 */
4984
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_uint(char * __pyx_v_sha1)4985 static unsigned int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_uint(char *__pyx_v_sha1) {
4986 unsigned int __pyx_v_val;
4987 unsigned int __pyx_r;
4988 __Pyx_RefNannyDeclarations
4989 __Pyx_RefNannySetupContext("_sha1_to_uint", 0);
4990
4991 /* "breezy/bzr/_btree_serializer_pyx.pyx":463
4992 * | ((<unsigned int>(sha1[1]) & 0xff) << 16)
4993 * | ((<unsigned int>(sha1[2]) & 0xff) << 8)
4994 * | ((<unsigned int>(sha1[3]) & 0xff) << 0)) # <<<<<<<<<<<<<<
4995 * return val
4996 *
4997 */
4998 __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));
4999
5000 /* "breezy/bzr/_btree_serializer_pyx.pyx":464
5001 * | ((<unsigned int>(sha1[2]) & 0xff) << 8)
5002 * | ((<unsigned int>(sha1[3]) & 0xff) << 0))
5003 * return val # <<<<<<<<<<<<<<
5004 *
5005 *
5006 */
5007 __pyx_r = __pyx_v_val;
5008 goto __pyx_L0;
5009
5010 /* "breezy/bzr/_btree_serializer_pyx.pyx":457
5011 *
5012 *
5013 * cdef unsigned int _sha1_to_uint(char *sha1): # cannot_raise # <<<<<<<<<<<<<<
5014 * cdef unsigned int val
5015 * # Must be in MSB, because that is how the content is sorted
5016 */
5017
5018 /* function exit code */
5019 __pyx_L0:;
5020 __Pyx_RefNannyFinishContext();
5021 return __pyx_r;
5022 }
5023
5024 /* "breezy/bzr/_btree_serializer_pyx.pyx":467
5025 *
5026 *
5027 * cdef _format_record(gc_chk_sha1_record *record): # <<<<<<<<<<<<<<
5028 * # This is inefficient to go from a logical state back to a bytes object,
5029 * # but it makes things work a bit better internally for now.
5030 */
5031
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__format_record(__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record * __pyx_v_record)5032 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__format_record(__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record) {
5033 PyObject *__pyx_v_block_offset_str = NULL;
5034 PyObject *__pyx_v_value = NULL;
5035 PyObject *__pyx_r = NULL;
5036 __Pyx_RefNannyDeclarations
5037 PyObject *__pyx_t_1 = NULL;
5038 PyObject *__pyx_t_2 = NULL;
5039 int __pyx_t_3;
5040 int __pyx_lineno = 0;
5041 const char *__pyx_filename = NULL;
5042 int __pyx_clineno = 0;
5043 __Pyx_RefNannySetupContext("_format_record", 0);
5044
5045 /* "breezy/bzr/_btree_serializer_pyx.pyx":470
5046 * # This is inefficient to go from a logical state back to a bytes object,
5047 * # but it makes things work a bit better internally for now.
5048 * if record.block_offset >= 0xFFFFFFFF: # <<<<<<<<<<<<<<
5049 * # Could use %llu which was added to Python 2.7 but it oddly is missing
5050 * # from the Python 3 equivalent functions, so hack still needed. :(
5051 */
5052 __pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_record->block_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error)
5053 __Pyx_GOTREF(__pyx_t_1);
5054 __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_4294967295, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error)
5055 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5056 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 470, __pyx_L1_error)
5057 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5058 if (__pyx_t_3) {
5059
5060 /* "breezy/bzr/_btree_serializer_pyx.pyx":473
5061 * # Could use %llu which was added to Python 2.7 but it oddly is missing
5062 * # from the Python 3 equivalent functions, so hack still needed. :(
5063 * block_offset_str = b'%d' % record.block_offset # <<<<<<<<<<<<<<
5064 * value = PyBytes_FromFormat(
5065 * '%s %u %u %u', PyBytes_AS_STRING(block_offset_str),
5066 */
5067 __pyx_t_2 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_record->block_offset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 473, __pyx_L1_error)
5068 __Pyx_GOTREF(__pyx_t_2);
5069 __pyx_t_1 = PyNumber_Remainder(__pyx_kp_b_d, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 473, __pyx_L1_error)
5070 __Pyx_GOTREF(__pyx_t_1);
5071 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5072 __pyx_v_block_offset_str = ((PyObject*)__pyx_t_1);
5073 __pyx_t_1 = 0;
5074
5075 /* "breezy/bzr/_btree_serializer_pyx.pyx":474
5076 * # from the Python 3 equivalent functions, so hack still needed. :(
5077 * block_offset_str = b'%d' % record.block_offset
5078 * value = PyBytes_FromFormat( # <<<<<<<<<<<<<<
5079 * '%s %u %u %u', PyBytes_AS_STRING(block_offset_str),
5080 * record.block_length, record.record_start, record.record_end)
5081 */
5082 __pyx_t_1 = PyBytes_FromFormat(((char *)"%s %u %u %u"), PyBytes_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_1)) __PYX_ERR(0, 474, __pyx_L1_error)
5083 __Pyx_GOTREF(__pyx_t_1);
5084 __pyx_v_value = ((PyObject*)__pyx_t_1);
5085 __pyx_t_1 = 0;
5086
5087 /* "breezy/bzr/_btree_serializer_pyx.pyx":470
5088 * # This is inefficient to go from a logical state back to a bytes object,
5089 * # but it makes things work a bit better internally for now.
5090 * if record.block_offset >= 0xFFFFFFFF: # <<<<<<<<<<<<<<
5091 * # Could use %llu which was added to Python 2.7 but it oddly is missing
5092 * # from the Python 3 equivalent functions, so hack still needed. :(
5093 */
5094 goto __pyx_L3;
5095 }
5096
5097 /* "breezy/bzr/_btree_serializer_pyx.pyx":478
5098 * record.block_length, record.record_start, record.record_end)
5099 * else:
5100 * value = PyBytes_FromFormat( # <<<<<<<<<<<<<<
5101 * '%lu %u %u %u', <unsigned long>record.block_offset,
5102 * record.block_length, record.record_start, record.record_end)
5103 */
5104 /*else*/ {
5105
5106 /* "breezy/bzr/_btree_serializer_pyx.pyx":480
5107 * value = PyBytes_FromFormat(
5108 * '%lu %u %u %u', <unsigned long>record.block_offset,
5109 * record.block_length, record.record_start, record.record_end) # <<<<<<<<<<<<<<
5110 * return value
5111 *
5112 */
5113 __pyx_t_1 = PyBytes_FromFormat(((char *)"%lu %u %u %u"), ((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_1)) __PYX_ERR(0, 478, __pyx_L1_error)
5114 __Pyx_GOTREF(__pyx_t_1);
5115 __pyx_v_value = ((PyObject*)__pyx_t_1);
5116 __pyx_t_1 = 0;
5117 }
5118 __pyx_L3:;
5119
5120 /* "breezy/bzr/_btree_serializer_pyx.pyx":481
5121 * '%lu %u %u %u', <unsigned long>record.block_offset,
5122 * record.block_length, record.record_start, record.record_end)
5123 * return value # <<<<<<<<<<<<<<
5124 *
5125 *
5126 */
5127 __Pyx_XDECREF(__pyx_r);
5128 __Pyx_INCREF(__pyx_v_value);
5129 __pyx_r = __pyx_v_value;
5130 goto __pyx_L0;
5131
5132 /* "breezy/bzr/_btree_serializer_pyx.pyx":467
5133 *
5134 *
5135 * cdef _format_record(gc_chk_sha1_record *record): # <<<<<<<<<<<<<<
5136 * # This is inefficient to go from a logical state back to a bytes object,
5137 * # but it makes things work a bit better internally for now.
5138 */
5139
5140 /* function exit code */
5141 __pyx_L1_error:;
5142 __Pyx_XDECREF(__pyx_t_1);
5143 __Pyx_XDECREF(__pyx_t_2);
5144 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._format_record", __pyx_clineno, __pyx_lineno, __pyx_filename);
5145 __pyx_r = 0;
5146 __pyx_L0:;
5147 __Pyx_XDECREF(__pyx_v_block_offset_str);
5148 __Pyx_XDECREF(__pyx_v_value);
5149 __Pyx_XGIVEREF(__pyx_r);
5150 __Pyx_RefNannyFinishContext();
5151 return __pyx_r;
5152 }
5153
5154 /* "breezy/bzr/_btree_serializer_pyx.pyx":502
5155 * cdef unsigned char offsets[257]
5156 *
5157 * def __sizeof__(self): # <<<<<<<<<<<<<<
5158 * return (
5159 * sizeof(GCCHKSHA1LeafNode) +
5160 */
5161
5162 /* Python wrapper */
5163 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_1__sizeof__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_1__sizeof__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)5164 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_1__sizeof__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
5165 PyObject *__pyx_r = 0;
5166 __Pyx_RefNannyDeclarations
5167 __Pyx_RefNannySetupContext("__sizeof__ (wrapper)", 0);
5168 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode___sizeof__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
5169
5170 /* function exit code */
5171 __Pyx_RefNannyFinishContext();
5172 return __pyx_r;
5173 }
5174
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode___sizeof__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)5175 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode___sizeof__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
5176 PyObject *__pyx_r = NULL;
5177 __Pyx_RefNannyDeclarations
5178 PyObject *__pyx_t_1 = NULL;
5179 int __pyx_lineno = 0;
5180 const char *__pyx_filename = NULL;
5181 int __pyx_clineno = 0;
5182 __Pyx_RefNannySetupContext("__sizeof__", 0);
5183
5184 /* "breezy/bzr/_btree_serializer_pyx.pyx":503
5185 *
5186 * def __sizeof__(self):
5187 * return ( # <<<<<<<<<<<<<<
5188 * sizeof(GCCHKSHA1LeafNode) +
5189 * sizeof(gc_chk_sha1_record) * self.num_records)
5190 */
5191 __Pyx_XDECREF(__pyx_r);
5192
5193 /* "breezy/bzr/_btree_serializer_pyx.pyx":504
5194 * def __sizeof__(self):
5195 * return (
5196 * sizeof(GCCHKSHA1LeafNode) + # <<<<<<<<<<<<<<
5197 * sizeof(gc_chk_sha1_record) * self.num_records)
5198 *
5199 */
5200 __pyx_t_1 = __Pyx_PyInt_FromSize_t(((sizeof(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode)) + ((sizeof(__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record)) * __pyx_v_self->num_records))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 504, __pyx_L1_error)
5201 __Pyx_GOTREF(__pyx_t_1);
5202 __pyx_r = __pyx_t_1;
5203 __pyx_t_1 = 0;
5204 goto __pyx_L0;
5205
5206 /* "breezy/bzr/_btree_serializer_pyx.pyx":502
5207 * cdef unsigned char offsets[257]
5208 *
5209 * def __sizeof__(self): # <<<<<<<<<<<<<<
5210 * return (
5211 * sizeof(GCCHKSHA1LeafNode) +
5212 */
5213
5214 /* function exit code */
5215 __pyx_L1_error:;
5216 __Pyx_XDECREF(__pyx_t_1);
5217 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.__sizeof__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5218 __pyx_r = NULL;
5219 __pyx_L0:;
5220 __Pyx_XGIVEREF(__pyx_r);
5221 __Pyx_RefNannyFinishContext();
5222 return __pyx_r;
5223 }
5224
5225 /* "breezy/bzr/_btree_serializer_pyx.pyx":507
5226 * sizeof(gc_chk_sha1_record) * self.num_records)
5227 *
5228 * def __dealloc__(self): # <<<<<<<<<<<<<<
5229 * if self.records != NULL:
5230 * PyMem_Free(self.records)
5231 */
5232
5233 /* Python wrapper */
5234 static void __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_3__dealloc__(PyObject * __pyx_v_self)5235 static void __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_3__dealloc__(PyObject *__pyx_v_self) {
5236 __Pyx_RefNannyDeclarations
5237 __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
5238 __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_2__dealloc__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
5239
5240 /* function exit code */
5241 __Pyx_RefNannyFinishContext();
5242 }
5243
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_2__dealloc__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)5244 static void __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_2__dealloc__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
5245 __Pyx_RefNannyDeclarations
5246 int __pyx_t_1;
5247 __Pyx_RefNannySetupContext("__dealloc__", 0);
5248
5249 /* "breezy/bzr/_btree_serializer_pyx.pyx":508
5250 *
5251 * def __dealloc__(self):
5252 * if self.records != NULL: # <<<<<<<<<<<<<<
5253 * PyMem_Free(self.records)
5254 * self.records = NULL
5255 */
5256 __pyx_t_1 = ((__pyx_v_self->records != NULL) != 0);
5257 if (__pyx_t_1) {
5258
5259 /* "breezy/bzr/_btree_serializer_pyx.pyx":509
5260 * def __dealloc__(self):
5261 * if self.records != NULL:
5262 * PyMem_Free(self.records) # <<<<<<<<<<<<<<
5263 * self.records = NULL
5264 *
5265 */
5266 PyMem_Free(__pyx_v_self->records);
5267
5268 /* "breezy/bzr/_btree_serializer_pyx.pyx":510
5269 * if self.records != NULL:
5270 * PyMem_Free(self.records)
5271 * self.records = NULL # <<<<<<<<<<<<<<
5272 *
5273 * def __init__(self, bytes):
5274 */
5275 __pyx_v_self->records = NULL;
5276
5277 /* "breezy/bzr/_btree_serializer_pyx.pyx":508
5278 *
5279 * def __dealloc__(self):
5280 * if self.records != NULL: # <<<<<<<<<<<<<<
5281 * PyMem_Free(self.records)
5282 * self.records = NULL
5283 */
5284 }
5285
5286 /* "breezy/bzr/_btree_serializer_pyx.pyx":507
5287 * sizeof(gc_chk_sha1_record) * self.num_records)
5288 *
5289 * def __dealloc__(self): # <<<<<<<<<<<<<<
5290 * if self.records != NULL:
5291 * PyMem_Free(self.records)
5292 */
5293
5294 /* function exit code */
5295 __Pyx_RefNannyFinishContext();
5296 }
5297
5298 /* "breezy/bzr/_btree_serializer_pyx.pyx":512
5299 * self.records = NULL
5300 *
5301 * def __init__(self, bytes): # <<<<<<<<<<<<<<
5302 * self._parse_bytes(bytes)
5303 * self.last_key = None
5304 */
5305
5306 /* Python wrapper */
5307 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_5__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_5__init__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5308 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_5__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5309 PyObject *__pyx_v_bytes = 0;
5310 int __pyx_lineno = 0;
5311 const char *__pyx_filename = NULL;
5312 int __pyx_clineno = 0;
5313 int __pyx_r;
5314 __Pyx_RefNannyDeclarations
5315 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
5316 {
5317 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bytes,0};
5318 PyObject* values[1] = {0};
5319 if (unlikely(__pyx_kwds)) {
5320 Py_ssize_t kw_args;
5321 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5322 switch (pos_args) {
5323 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5324 CYTHON_FALLTHROUGH;
5325 case 0: break;
5326 default: goto __pyx_L5_argtuple_error;
5327 }
5328 kw_args = PyDict_Size(__pyx_kwds);
5329 switch (pos_args) {
5330 case 0:
5331 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bytes)) != 0)) kw_args--;
5332 else goto __pyx_L5_argtuple_error;
5333 }
5334 if (unlikely(kw_args > 0)) {
5335 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 512, __pyx_L3_error)
5336 }
5337 } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
5338 goto __pyx_L5_argtuple_error;
5339 } else {
5340 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5341 }
5342 __pyx_v_bytes = values[0];
5343 }
5344 goto __pyx_L4_argument_unpacking_done;
5345 __pyx_L5_argtuple_error:;
5346 __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 512, __pyx_L3_error)
5347 __pyx_L3_error:;
5348 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5349 __Pyx_RefNannyFinishContext();
5350 return -1;
5351 __pyx_L4_argument_unpacking_done:;
5352 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_4__init__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), __pyx_v_bytes);
5353
5354 /* function exit code */
5355 __Pyx_RefNannyFinishContext();
5356 return __pyx_r;
5357 }
5358
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_4__init__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,PyObject * __pyx_v_bytes)5359 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_4__init__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_bytes) {
5360 int __pyx_r;
5361 __Pyx_RefNannyDeclarations
5362 PyObject *__pyx_t_1 = NULL;
5363 int __pyx_lineno = 0;
5364 const char *__pyx_filename = NULL;
5365 int __pyx_clineno = 0;
5366 __Pyx_RefNannySetupContext("__init__", 0);
5367
5368 /* "breezy/bzr/_btree_serializer_pyx.pyx":513
5369 *
5370 * def __init__(self, bytes):
5371 * self._parse_bytes(bytes) # <<<<<<<<<<<<<<
5372 * self.last_key = None
5373 * self.last_record = NULL
5374 */
5375 __pyx_t_1 = ((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_parse_bytes(__pyx_v_self, __pyx_v_bytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
5376 __Pyx_GOTREF(__pyx_t_1);
5377 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5378
5379 /* "breezy/bzr/_btree_serializer_pyx.pyx":514
5380 * def __init__(self, bytes):
5381 * self._parse_bytes(bytes)
5382 * self.last_key = None # <<<<<<<<<<<<<<
5383 * self.last_record = NULL
5384 *
5385 */
5386 __Pyx_INCREF(Py_None);
5387 __Pyx_GIVEREF(Py_None);
5388 __Pyx_GOTREF(__pyx_v_self->last_key);
5389 __Pyx_DECREF(__pyx_v_self->last_key);
5390 __pyx_v_self->last_key = Py_None;
5391
5392 /* "breezy/bzr/_btree_serializer_pyx.pyx":515
5393 * self._parse_bytes(bytes)
5394 * self.last_key = None
5395 * self.last_record = NULL # <<<<<<<<<<<<<<
5396 *
5397 * property min_key:
5398 */
5399 __pyx_v_self->last_record = NULL;
5400
5401 /* "breezy/bzr/_btree_serializer_pyx.pyx":512
5402 * self.records = NULL
5403 *
5404 * def __init__(self, bytes): # <<<<<<<<<<<<<<
5405 * self._parse_bytes(bytes)
5406 * self.last_key = None
5407 */
5408
5409 /* function exit code */
5410 __pyx_r = 0;
5411 goto __pyx_L0;
5412 __pyx_L1_error:;
5413 __Pyx_XDECREF(__pyx_t_1);
5414 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5415 __pyx_r = -1;
5416 __pyx_L0:;
5417 __Pyx_RefNannyFinishContext();
5418 return __pyx_r;
5419 }
5420
5421 /* "breezy/bzr/_btree_serializer_pyx.pyx":518
5422 *
5423 * property min_key:
5424 * def __get__(self): # <<<<<<<<<<<<<<
5425 * if self.num_records > 0:
5426 * return _sha1_to_key(self.records[0].sha1)
5427 */
5428
5429 /* Python wrapper */
5430 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key_1__get__(PyObject * __pyx_v_self)5431 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key_1__get__(PyObject *__pyx_v_self) {
5432 PyObject *__pyx_r = 0;
5433 __Pyx_RefNannyDeclarations
5434 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
5435 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key___get__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
5436
5437 /* function exit code */
5438 __Pyx_RefNannyFinishContext();
5439 return __pyx_r;
5440 }
5441
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)5442 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
5443 PyObject *__pyx_r = NULL;
5444 __Pyx_RefNannyDeclarations
5445 int __pyx_t_1;
5446 PyObject *__pyx_t_2 = NULL;
5447 int __pyx_lineno = 0;
5448 const char *__pyx_filename = NULL;
5449 int __pyx_clineno = 0;
5450 __Pyx_RefNannySetupContext("__get__", 0);
5451
5452 /* "breezy/bzr/_btree_serializer_pyx.pyx":519
5453 * property min_key:
5454 * def __get__(self):
5455 * if self.num_records > 0: # <<<<<<<<<<<<<<
5456 * return _sha1_to_key(self.records[0].sha1)
5457 * return None
5458 */
5459 __pyx_t_1 = ((__pyx_v_self->num_records > 0) != 0);
5460 if (__pyx_t_1) {
5461
5462 /* "breezy/bzr/_btree_serializer_pyx.pyx":520
5463 * def __get__(self):
5464 * if self.num_records > 0:
5465 * return _sha1_to_key(self.records[0].sha1) # <<<<<<<<<<<<<<
5466 * return None
5467 *
5468 */
5469 __Pyx_XDECREF(__pyx_r);
5470 __pyx_t_2 = ((PyObject *)__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_key((__pyx_v_self->records[0]).sha1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 520, __pyx_L1_error)
5471 __Pyx_GOTREF(__pyx_t_2);
5472 __pyx_r = __pyx_t_2;
5473 __pyx_t_2 = 0;
5474 goto __pyx_L0;
5475
5476 /* "breezy/bzr/_btree_serializer_pyx.pyx":519
5477 * property min_key:
5478 * def __get__(self):
5479 * if self.num_records > 0: # <<<<<<<<<<<<<<
5480 * return _sha1_to_key(self.records[0].sha1)
5481 * return None
5482 */
5483 }
5484
5485 /* "breezy/bzr/_btree_serializer_pyx.pyx":521
5486 * if self.num_records > 0:
5487 * return _sha1_to_key(self.records[0].sha1)
5488 * return None # <<<<<<<<<<<<<<
5489 *
5490 * property max_key:
5491 */
5492 __Pyx_XDECREF(__pyx_r);
5493 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5494 goto __pyx_L0;
5495
5496 /* "breezy/bzr/_btree_serializer_pyx.pyx":518
5497 *
5498 * property min_key:
5499 * def __get__(self): # <<<<<<<<<<<<<<
5500 * if self.num_records > 0:
5501 * return _sha1_to_key(self.records[0].sha1)
5502 */
5503
5504 /* function exit code */
5505 __pyx_L1_error:;
5506 __Pyx_XDECREF(__pyx_t_2);
5507 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.min_key.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5508 __pyx_r = NULL;
5509 __pyx_L0:;
5510 __Pyx_XGIVEREF(__pyx_r);
5511 __Pyx_RefNannyFinishContext();
5512 return __pyx_r;
5513 }
5514
5515 /* "breezy/bzr/_btree_serializer_pyx.pyx":524
5516 *
5517 * property max_key:
5518 * def __get__(self): # <<<<<<<<<<<<<<
5519 * if self.num_records > 0:
5520 * return _sha1_to_key(self.records[self.num_records-1].sha1)
5521 */
5522
5523 /* Python wrapper */
5524 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key_1__get__(PyObject * __pyx_v_self)5525 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key_1__get__(PyObject *__pyx_v_self) {
5526 PyObject *__pyx_r = 0;
5527 __Pyx_RefNannyDeclarations
5528 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
5529 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key___get__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
5530
5531 /* function exit code */
5532 __Pyx_RefNannyFinishContext();
5533 return __pyx_r;
5534 }
5535
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)5536 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
5537 PyObject *__pyx_r = NULL;
5538 __Pyx_RefNannyDeclarations
5539 int __pyx_t_1;
5540 PyObject *__pyx_t_2 = NULL;
5541 int __pyx_lineno = 0;
5542 const char *__pyx_filename = NULL;
5543 int __pyx_clineno = 0;
5544 __Pyx_RefNannySetupContext("__get__", 0);
5545
5546 /* "breezy/bzr/_btree_serializer_pyx.pyx":525
5547 * property max_key:
5548 * def __get__(self):
5549 * if self.num_records > 0: # <<<<<<<<<<<<<<
5550 * return _sha1_to_key(self.records[self.num_records-1].sha1)
5551 * return None
5552 */
5553 __pyx_t_1 = ((__pyx_v_self->num_records > 0) != 0);
5554 if (__pyx_t_1) {
5555
5556 /* "breezy/bzr/_btree_serializer_pyx.pyx":526
5557 * def __get__(self):
5558 * if self.num_records > 0:
5559 * return _sha1_to_key(self.records[self.num_records-1].sha1) # <<<<<<<<<<<<<<
5560 * return None
5561 *
5562 */
5563 __Pyx_XDECREF(__pyx_r);
5564 __pyx_t_2 = ((PyObject *)__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_key((__pyx_v_self->records[(__pyx_v_self->num_records - 1)]).sha1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 526, __pyx_L1_error)
5565 __Pyx_GOTREF(__pyx_t_2);
5566 __pyx_r = __pyx_t_2;
5567 __pyx_t_2 = 0;
5568 goto __pyx_L0;
5569
5570 /* "breezy/bzr/_btree_serializer_pyx.pyx":525
5571 * property max_key:
5572 * def __get__(self):
5573 * if self.num_records > 0: # <<<<<<<<<<<<<<
5574 * return _sha1_to_key(self.records[self.num_records-1].sha1)
5575 * return None
5576 */
5577 }
5578
5579 /* "breezy/bzr/_btree_serializer_pyx.pyx":527
5580 * if self.num_records > 0:
5581 * return _sha1_to_key(self.records[self.num_records-1].sha1)
5582 * return None # <<<<<<<<<<<<<<
5583 *
5584 * cdef StaticTuple _record_to_value_and_refs(self,
5585 */
5586 __Pyx_XDECREF(__pyx_r);
5587 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5588 goto __pyx_L0;
5589
5590 /* "breezy/bzr/_btree_serializer_pyx.pyx":524
5591 *
5592 * property max_key:
5593 * def __get__(self): # <<<<<<<<<<<<<<
5594 * if self.num_records > 0:
5595 * return _sha1_to_key(self.records[self.num_records-1].sha1)
5596 */
5597
5598 /* function exit code */
5599 __pyx_L1_error:;
5600 __Pyx_XDECREF(__pyx_t_2);
5601 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.max_key.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5602 __pyx_r = NULL;
5603 __pyx_L0:;
5604 __Pyx_XGIVEREF(__pyx_r);
5605 __Pyx_RefNannyFinishContext();
5606 return __pyx_r;
5607 }
5608
5609 /* "breezy/bzr/_btree_serializer_pyx.pyx":529
5610 * return None
5611 *
5612 * cdef StaticTuple _record_to_value_and_refs(self, # <<<<<<<<<<<<<<
5613 * gc_chk_sha1_record *record):
5614 * """Extract the refs and value part of this record."""
5615 */
5616
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_value_and_refs(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record * __pyx_v_record)5617 static StaticTuple *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_value_and_refs(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record) {
5618 StaticTuple *__pyx_v_value_and_refs = 0;
5619 StaticTuple *__pyx_v_empty = 0;
5620 PyObject *__pyx_v_value = NULL;
5621 StaticTuple *__pyx_r = NULL;
5622 __Pyx_RefNannyDeclarations
5623 PyObject *__pyx_t_1 = NULL;
5624 int __pyx_lineno = 0;
5625 const char *__pyx_filename = NULL;
5626 int __pyx_clineno = 0;
5627 __Pyx_RefNannySetupContext("_record_to_value_and_refs", 0);
5628
5629 /* "breezy/bzr/_btree_serializer_pyx.pyx":534
5630 * cdef StaticTuple value_and_refs
5631 * cdef StaticTuple empty
5632 * value_and_refs = StaticTuple_New(2) # <<<<<<<<<<<<<<
5633 * value = _format_record(record)
5634 * Py_INCREF(value)
5635 */
5636 __pyx_t_1 = ((PyObject *)StaticTuple_New(2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
5637 __Pyx_GOTREF(__pyx_t_1);
5638 __pyx_v_value_and_refs = ((StaticTuple *)__pyx_t_1);
5639 __pyx_t_1 = 0;
5640
5641 /* "breezy/bzr/_btree_serializer_pyx.pyx":535
5642 * cdef StaticTuple empty
5643 * value_and_refs = StaticTuple_New(2)
5644 * value = _format_record(record) # <<<<<<<<<<<<<<
5645 * Py_INCREF(value)
5646 * StaticTuple_SET_ITEM(value_and_refs, 0, value)
5647 */
5648 __pyx_t_1 = __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__format_record(__pyx_v_record); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L1_error)
5649 __Pyx_GOTREF(__pyx_t_1);
5650 __pyx_v_value = __pyx_t_1;
5651 __pyx_t_1 = 0;
5652
5653 /* "breezy/bzr/_btree_serializer_pyx.pyx":536
5654 * value_and_refs = StaticTuple_New(2)
5655 * value = _format_record(record)
5656 * Py_INCREF(value) # <<<<<<<<<<<<<<
5657 * StaticTuple_SET_ITEM(value_and_refs, 0, value)
5658 * # Always empty refs
5659 */
5660 Py_INCREF(__pyx_v_value);
5661
5662 /* "breezy/bzr/_btree_serializer_pyx.pyx":537
5663 * value = _format_record(record)
5664 * Py_INCREF(value)
5665 * StaticTuple_SET_ITEM(value_and_refs, 0, value) # <<<<<<<<<<<<<<
5666 * # Always empty refs
5667 * empty = StaticTuple_New(0)
5668 */
5669 StaticTuple_SET_ITEM(__pyx_v_value_and_refs, 0, __pyx_v_value);
5670
5671 /* "breezy/bzr/_btree_serializer_pyx.pyx":539
5672 * StaticTuple_SET_ITEM(value_and_refs, 0, value)
5673 * # Always empty refs
5674 * empty = StaticTuple_New(0) # <<<<<<<<<<<<<<
5675 * Py_INCREF(empty)
5676 * StaticTuple_SET_ITEM(value_and_refs, 1, empty)
5677 */
5678 __pyx_t_1 = ((PyObject *)StaticTuple_New(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
5679 __Pyx_GOTREF(__pyx_t_1);
5680 __pyx_v_empty = ((StaticTuple *)__pyx_t_1);
5681 __pyx_t_1 = 0;
5682
5683 /* "breezy/bzr/_btree_serializer_pyx.pyx":540
5684 * # Always empty refs
5685 * empty = StaticTuple_New(0)
5686 * Py_INCREF(empty) # <<<<<<<<<<<<<<
5687 * StaticTuple_SET_ITEM(value_and_refs, 1, empty)
5688 * return value_and_refs
5689 */
5690 Py_INCREF(((PyObject *)__pyx_v_empty));
5691
5692 /* "breezy/bzr/_btree_serializer_pyx.pyx":541
5693 * empty = StaticTuple_New(0)
5694 * Py_INCREF(empty)
5695 * StaticTuple_SET_ITEM(value_and_refs, 1, empty) # <<<<<<<<<<<<<<
5696 * return value_and_refs
5697 *
5698 */
5699 StaticTuple_SET_ITEM(__pyx_v_value_and_refs, 1, ((PyObject *)__pyx_v_empty));
5700
5701 /* "breezy/bzr/_btree_serializer_pyx.pyx":542
5702 * Py_INCREF(empty)
5703 * StaticTuple_SET_ITEM(value_and_refs, 1, empty)
5704 * return value_and_refs # <<<<<<<<<<<<<<
5705 *
5706 * cdef StaticTuple _record_to_item(self, gc_chk_sha1_record *record):
5707 */
5708 __Pyx_XDECREF(((PyObject *)__pyx_r));
5709 __Pyx_INCREF(((PyObject *)__pyx_v_value_and_refs));
5710 __pyx_r = __pyx_v_value_and_refs;
5711 goto __pyx_L0;
5712
5713 /* "breezy/bzr/_btree_serializer_pyx.pyx":529
5714 * return None
5715 *
5716 * cdef StaticTuple _record_to_value_and_refs(self, # <<<<<<<<<<<<<<
5717 * gc_chk_sha1_record *record):
5718 * """Extract the refs and value part of this record."""
5719 */
5720
5721 /* function exit code */
5722 __pyx_L1_error:;
5723 __Pyx_XDECREF(__pyx_t_1);
5724 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode._record_to_value_and_refs", __pyx_clineno, __pyx_lineno, __pyx_filename);
5725 __pyx_r = 0;
5726 __pyx_L0:;
5727 __Pyx_XDECREF((PyObject *)__pyx_v_value_and_refs);
5728 __Pyx_XDECREF((PyObject *)__pyx_v_empty);
5729 __Pyx_XDECREF(__pyx_v_value);
5730 __Pyx_XGIVEREF((PyObject *)__pyx_r);
5731 __Pyx_RefNannyFinishContext();
5732 return __pyx_r;
5733 }
5734
5735 /* "breezy/bzr/_btree_serializer_pyx.pyx":544
5736 * return value_and_refs
5737 *
5738 * cdef StaticTuple _record_to_item(self, gc_chk_sha1_record *record): # <<<<<<<<<<<<<<
5739 * """Turn a given record back into a fully fledged item.
5740 * """
5741 */
5742
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_item(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record * __pyx_v_record)5743 static StaticTuple *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_item(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record) {
5744 StaticTuple *__pyx_v_item = 0;
5745 StaticTuple *__pyx_v_key = 0;
5746 StaticTuple *__pyx_v_value_and_refs = 0;
5747 StaticTuple *__pyx_r = NULL;
5748 __Pyx_RefNannyDeclarations
5749 PyObject *__pyx_t_1 = NULL;
5750 int __pyx_lineno = 0;
5751 const char *__pyx_filename = NULL;
5752 int __pyx_clineno = 0;
5753 __Pyx_RefNannySetupContext("_record_to_item", 0);
5754
5755 /* "breezy/bzr/_btree_serializer_pyx.pyx":551
5756 * cdef StaticTuple value_and_refs
5757 * cdef object value
5758 * key = _sha1_to_key(record.sha1) # <<<<<<<<<<<<<<
5759 * item = StaticTuple_New(2)
5760 * Py_INCREF(key)
5761 */
5762 __pyx_t_1 = ((PyObject *)__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_key(__pyx_v_record->sha1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L1_error)
5763 __Pyx_GOTREF(__pyx_t_1);
5764 __pyx_v_key = ((StaticTuple *)__pyx_t_1);
5765 __pyx_t_1 = 0;
5766
5767 /* "breezy/bzr/_btree_serializer_pyx.pyx":552
5768 * cdef object value
5769 * key = _sha1_to_key(record.sha1)
5770 * item = StaticTuple_New(2) # <<<<<<<<<<<<<<
5771 * Py_INCREF(key)
5772 * StaticTuple_SET_ITEM(item, 0, key)
5773 */
5774 __pyx_t_1 = ((PyObject *)StaticTuple_New(2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 552, __pyx_L1_error)
5775 __Pyx_GOTREF(__pyx_t_1);
5776 __pyx_v_item = ((StaticTuple *)__pyx_t_1);
5777 __pyx_t_1 = 0;
5778
5779 /* "breezy/bzr/_btree_serializer_pyx.pyx":553
5780 * key = _sha1_to_key(record.sha1)
5781 * item = StaticTuple_New(2)
5782 * Py_INCREF(key) # <<<<<<<<<<<<<<
5783 * StaticTuple_SET_ITEM(item, 0, key)
5784 * value_and_refs = self._record_to_value_and_refs(record)
5785 */
5786 Py_INCREF(((PyObject *)__pyx_v_key));
5787
5788 /* "breezy/bzr/_btree_serializer_pyx.pyx":554
5789 * item = StaticTuple_New(2)
5790 * Py_INCREF(key)
5791 * StaticTuple_SET_ITEM(item, 0, key) # <<<<<<<<<<<<<<
5792 * value_and_refs = self._record_to_value_and_refs(record)
5793 * Py_INCREF(value_and_refs)
5794 */
5795 StaticTuple_SET_ITEM(__pyx_v_item, 0, ((PyObject *)__pyx_v_key));
5796
5797 /* "breezy/bzr/_btree_serializer_pyx.pyx":555
5798 * Py_INCREF(key)
5799 * StaticTuple_SET_ITEM(item, 0, key)
5800 * value_and_refs = self._record_to_value_and_refs(record) # <<<<<<<<<<<<<<
5801 * Py_INCREF(value_and_refs)
5802 * StaticTuple_SET_ITEM(item, 1, value_and_refs)
5803 */
5804 __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6breezy_3bzr_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_ERR(0, 555, __pyx_L1_error)
5805 __Pyx_GOTREF(__pyx_t_1);
5806 __pyx_v_value_and_refs = ((StaticTuple *)__pyx_t_1);
5807 __pyx_t_1 = 0;
5808
5809 /* "breezy/bzr/_btree_serializer_pyx.pyx":556
5810 * StaticTuple_SET_ITEM(item, 0, key)
5811 * value_and_refs = self._record_to_value_and_refs(record)
5812 * Py_INCREF(value_and_refs) # <<<<<<<<<<<<<<
5813 * StaticTuple_SET_ITEM(item, 1, value_and_refs)
5814 * return item
5815 */
5816 Py_INCREF(((PyObject *)__pyx_v_value_and_refs));
5817
5818 /* "breezy/bzr/_btree_serializer_pyx.pyx":557
5819 * value_and_refs = self._record_to_value_and_refs(record)
5820 * Py_INCREF(value_and_refs)
5821 * StaticTuple_SET_ITEM(item, 1, value_and_refs) # <<<<<<<<<<<<<<
5822 * return item
5823 *
5824 */
5825 StaticTuple_SET_ITEM(__pyx_v_item, 1, ((PyObject *)__pyx_v_value_and_refs));
5826
5827 /* "breezy/bzr/_btree_serializer_pyx.pyx":558
5828 * Py_INCREF(value_and_refs)
5829 * StaticTuple_SET_ITEM(item, 1, value_and_refs)
5830 * return item # <<<<<<<<<<<<<<
5831 *
5832 * cdef gc_chk_sha1_record* _lookup_record(self, char *sha1) except? NULL:
5833 */
5834 __Pyx_XDECREF(((PyObject *)__pyx_r));
5835 __Pyx_INCREF(((PyObject *)__pyx_v_item));
5836 __pyx_r = __pyx_v_item;
5837 goto __pyx_L0;
5838
5839 /* "breezy/bzr/_btree_serializer_pyx.pyx":544
5840 * return value_and_refs
5841 *
5842 * cdef StaticTuple _record_to_item(self, gc_chk_sha1_record *record): # <<<<<<<<<<<<<<
5843 * """Turn a given record back into a fully fledged item.
5844 * """
5845 */
5846
5847 /* function exit code */
5848 __pyx_L1_error:;
5849 __Pyx_XDECREF(__pyx_t_1);
5850 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode._record_to_item", __pyx_clineno, __pyx_lineno, __pyx_filename);
5851 __pyx_r = 0;
5852 __pyx_L0:;
5853 __Pyx_XDECREF((PyObject *)__pyx_v_item);
5854 __Pyx_XDECREF((PyObject *)__pyx_v_key);
5855 __Pyx_XDECREF((PyObject *)__pyx_v_value_and_refs);
5856 __Pyx_XGIVEREF((PyObject *)__pyx_r);
5857 __Pyx_RefNannyFinishContext();
5858 return __pyx_r;
5859 }
5860
5861 /* "breezy/bzr/_btree_serializer_pyx.pyx":560
5862 * return item
5863 *
5864 * cdef gc_chk_sha1_record* _lookup_record(self, char *sha1) except? NULL: # <<<<<<<<<<<<<<
5865 * """Find a gc_chk_sha1_record that matches the sha1 supplied."""
5866 * cdef int lo, hi, mid, the_cmp
5867 */
5868
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__lookup_record(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,char * __pyx_v_sha1)5869 static __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__lookup_record(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_sha1) {
5870 int __pyx_v_lo;
5871 int __pyx_v_hi;
5872 int __pyx_v_mid;
5873 int __pyx_v_the_cmp;
5874 int __pyx_v_offset;
5875 CYTHON_UNUSED long __pyx_v_local_n_cmp;
5876 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_r;
5877 __Pyx_RefNannyDeclarations
5878 int __pyx_t_1;
5879 int __pyx_t_2;
5880 int __pyx_lineno = 0;
5881 const char *__pyx_filename = NULL;
5882 int __pyx_clineno = 0;
5883 __Pyx_RefNannySetupContext("_lookup_record", 0);
5884
5885 /* "breezy/bzr/_btree_serializer_pyx.pyx":574
5886 * # the offset array dropped us from 23us to 20us and 156 comparisions
5887 * # (1.3/key)
5888 * offset = self._offset_for_sha1(sha1) # <<<<<<<<<<<<<<
5889 * lo = self.offsets[offset]
5890 * hi = self.offsets[offset+1]
5891 */
5892 __pyx_t_1 = ((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_offset_for_sha1(__pyx_v_self, __pyx_v_sha1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 574, __pyx_L1_error)
5893 __pyx_v_offset = __pyx_t_1;
5894
5895 /* "breezy/bzr/_btree_serializer_pyx.pyx":575
5896 * # (1.3/key)
5897 * offset = self._offset_for_sha1(sha1)
5898 * lo = self.offsets[offset] # <<<<<<<<<<<<<<
5899 * hi = self.offsets[offset+1]
5900 * if hi == 255:
5901 */
5902 __pyx_v_lo = (__pyx_v_self->offsets[__pyx_v_offset]);
5903
5904 /* "breezy/bzr/_btree_serializer_pyx.pyx":576
5905 * offset = self._offset_for_sha1(sha1)
5906 * lo = self.offsets[offset]
5907 * hi = self.offsets[offset+1] # <<<<<<<<<<<<<<
5908 * if hi == 255:
5909 * # if hi == 255 that means we potentially ran off the end of the
5910 */
5911 __pyx_v_hi = (__pyx_v_self->offsets[(__pyx_v_offset + 1)]);
5912
5913 /* "breezy/bzr/_btree_serializer_pyx.pyx":577
5914 * lo = self.offsets[offset]
5915 * hi = self.offsets[offset+1]
5916 * if hi == 255: # <<<<<<<<<<<<<<
5917 * # if hi == 255 that means we potentially ran off the end of the
5918 * # list, so push it up to num_records
5919 */
5920 __pyx_t_2 = ((__pyx_v_hi == 0xFF) != 0);
5921 if (__pyx_t_2) {
5922
5923 /* "breezy/bzr/_btree_serializer_pyx.pyx":582
5924 * # note that if 'lo' == 255, that is ok, because we can start
5925 * # searching from that part of the list.
5926 * hi = self.num_records # <<<<<<<<<<<<<<
5927 * local_n_cmp = 0
5928 * while lo < hi:
5929 */
5930 __pyx_t_1 = __pyx_v_self->num_records;
5931 __pyx_v_hi = __pyx_t_1;
5932
5933 /* "breezy/bzr/_btree_serializer_pyx.pyx":577
5934 * lo = self.offsets[offset]
5935 * hi = self.offsets[offset+1]
5936 * if hi == 255: # <<<<<<<<<<<<<<
5937 * # if hi == 255 that means we potentially ran off the end of the
5938 * # list, so push it up to num_records
5939 */
5940 }
5941
5942 /* "breezy/bzr/_btree_serializer_pyx.pyx":583
5943 * # searching from that part of the list.
5944 * hi = self.num_records
5945 * local_n_cmp = 0 # <<<<<<<<<<<<<<
5946 * while lo < hi:
5947 * mid = (lo + hi) // 2
5948 */
5949 __pyx_v_local_n_cmp = 0;
5950
5951 /* "breezy/bzr/_btree_serializer_pyx.pyx":584
5952 * hi = self.num_records
5953 * local_n_cmp = 0
5954 * while lo < hi: # <<<<<<<<<<<<<<
5955 * mid = (lo + hi) // 2
5956 * the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
5957 */
5958 while (1) {
5959 __pyx_t_2 = ((__pyx_v_lo < __pyx_v_hi) != 0);
5960 if (!__pyx_t_2) break;
5961
5962 /* "breezy/bzr/_btree_serializer_pyx.pyx":585
5963 * local_n_cmp = 0
5964 * while lo < hi:
5965 * mid = (lo + hi) // 2 # <<<<<<<<<<<<<<
5966 * the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
5967 * if the_cmp == 0:
5968 */
5969 __pyx_v_mid = __Pyx_div_long((__pyx_v_lo + __pyx_v_hi), 2);
5970
5971 /* "breezy/bzr/_btree_serializer_pyx.pyx":586
5972 * while lo < hi:
5973 * mid = (lo + hi) // 2
5974 * the_cmp = memcmp(self.records[mid].sha1, sha1, 20) # <<<<<<<<<<<<<<
5975 * if the_cmp == 0:
5976 * return &self.records[mid]
5977 */
5978 __pyx_v_the_cmp = memcmp((__pyx_v_self->records[__pyx_v_mid]).sha1, __pyx_v_sha1, 20);
5979
5980 /* "breezy/bzr/_btree_serializer_pyx.pyx":587
5981 * mid = (lo + hi) // 2
5982 * the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
5983 * if the_cmp == 0: # <<<<<<<<<<<<<<
5984 * return &self.records[mid]
5985 * elif the_cmp < 0:
5986 */
5987 __pyx_t_2 = ((__pyx_v_the_cmp == 0) != 0);
5988 if (__pyx_t_2) {
5989
5990 /* "breezy/bzr/_btree_serializer_pyx.pyx":588
5991 * the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
5992 * if the_cmp == 0:
5993 * return &self.records[mid] # <<<<<<<<<<<<<<
5994 * elif the_cmp < 0:
5995 * lo = mid + 1
5996 */
5997 __pyx_r = (&(__pyx_v_self->records[__pyx_v_mid]));
5998 goto __pyx_L0;
5999
6000 /* "breezy/bzr/_btree_serializer_pyx.pyx":587
6001 * mid = (lo + hi) // 2
6002 * the_cmp = memcmp(self.records[mid].sha1, sha1, 20)
6003 * if the_cmp == 0: # <<<<<<<<<<<<<<
6004 * return &self.records[mid]
6005 * elif the_cmp < 0:
6006 */
6007 }
6008
6009 /* "breezy/bzr/_btree_serializer_pyx.pyx":589
6010 * if the_cmp == 0:
6011 * return &self.records[mid]
6012 * elif the_cmp < 0: # <<<<<<<<<<<<<<
6013 * lo = mid + 1
6014 * else:
6015 */
6016 __pyx_t_2 = ((__pyx_v_the_cmp < 0) != 0);
6017 if (__pyx_t_2) {
6018
6019 /* "breezy/bzr/_btree_serializer_pyx.pyx":590
6020 * return &self.records[mid]
6021 * elif the_cmp < 0:
6022 * lo = mid + 1 # <<<<<<<<<<<<<<
6023 * else:
6024 * hi = mid
6025 */
6026 __pyx_v_lo = (__pyx_v_mid + 1);
6027
6028 /* "breezy/bzr/_btree_serializer_pyx.pyx":589
6029 * if the_cmp == 0:
6030 * return &self.records[mid]
6031 * elif the_cmp < 0: # <<<<<<<<<<<<<<
6032 * lo = mid + 1
6033 * else:
6034 */
6035 goto __pyx_L6;
6036 }
6037
6038 /* "breezy/bzr/_btree_serializer_pyx.pyx":592
6039 * lo = mid + 1
6040 * else:
6041 * hi = mid # <<<<<<<<<<<<<<
6042 * return NULL
6043 *
6044 */
6045 /*else*/ {
6046 __pyx_v_hi = __pyx_v_mid;
6047 }
6048 __pyx_L6:;
6049 }
6050
6051 /* "breezy/bzr/_btree_serializer_pyx.pyx":593
6052 * else:
6053 * hi = mid
6054 * return NULL # <<<<<<<<<<<<<<
6055 *
6056 * def __contains__(self, key):
6057 */
6058 __pyx_r = NULL;
6059 goto __pyx_L0;
6060
6061 /* "breezy/bzr/_btree_serializer_pyx.pyx":560
6062 * return item
6063 *
6064 * cdef gc_chk_sha1_record* _lookup_record(self, char *sha1) except? NULL: # <<<<<<<<<<<<<<
6065 * """Find a gc_chk_sha1_record that matches the sha1 supplied."""
6066 * cdef int lo, hi, mid, the_cmp
6067 */
6068
6069 /* function exit code */
6070 __pyx_L1_error:;
6071 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode._lookup_record", __pyx_clineno, __pyx_lineno, __pyx_filename);
6072 __pyx_r = NULL;
6073 __pyx_L0:;
6074 __Pyx_RefNannyFinishContext();
6075 return __pyx_r;
6076 }
6077
6078 /* "breezy/bzr/_btree_serializer_pyx.pyx":595
6079 * return NULL
6080 *
6081 * def __contains__(self, key): # <<<<<<<<<<<<<<
6082 * cdef char sha1[20]
6083 * cdef gc_chk_sha1_record *record
6084 */
6085
6086 /* Python wrapper */
6087 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7__contains__(PyObject * __pyx_v_self,PyObject * __pyx_v_key)6088 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
6089 int __pyx_r;
6090 __Pyx_RefNannyDeclarations
6091 __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
6092 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_6__contains__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), ((PyObject *)__pyx_v_key));
6093
6094 /* function exit code */
6095 __Pyx_RefNannyFinishContext();
6096 return __pyx_r;
6097 }
6098
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_6__contains__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,PyObject * __pyx_v_key)6099 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_6__contains__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_key) {
6100 char __pyx_v_sha1[20];
6101 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record;
6102 int __pyx_r;
6103 __Pyx_RefNannyDeclarations
6104 int __pyx_t_1;
6105 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_t_2;
6106 int __pyx_lineno = 0;
6107 const char *__pyx_filename = NULL;
6108 int __pyx_clineno = 0;
6109 __Pyx_RefNannySetupContext("__contains__", 0);
6110
6111 /* "breezy/bzr/_btree_serializer_pyx.pyx":598
6112 * cdef char sha1[20]
6113 * cdef gc_chk_sha1_record *record
6114 * if _key_to_sha1(key, sha1): # <<<<<<<<<<<<<<
6115 * # If it isn't a sha1 key, then it won't be in this leaf node
6116 * record = self._lookup_record(sha1)
6117 */
6118 __pyx_t_1 = (__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__key_to_sha1(__pyx_v_key, __pyx_v_sha1) != 0);
6119 if (__pyx_t_1) {
6120
6121 /* "breezy/bzr/_btree_serializer_pyx.pyx":600
6122 * if _key_to_sha1(key, sha1):
6123 * # If it isn't a sha1 key, then it won't be in this leaf node
6124 * record = self._lookup_record(sha1) # <<<<<<<<<<<<<<
6125 * if record != NULL:
6126 * self.last_key = key
6127 */
6128 __pyx_t_2 = ((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_lookup_record(__pyx_v_self, __pyx_v_sha1); if (unlikely(__pyx_t_2 == ((__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 600, __pyx_L1_error)
6129 __pyx_v_record = __pyx_t_2;
6130
6131 /* "breezy/bzr/_btree_serializer_pyx.pyx":601
6132 * # If it isn't a sha1 key, then it won't be in this leaf node
6133 * record = self._lookup_record(sha1)
6134 * if record != NULL: # <<<<<<<<<<<<<<
6135 * self.last_key = key
6136 * self.last_record = record
6137 */
6138 __pyx_t_1 = ((__pyx_v_record != NULL) != 0);
6139 if (__pyx_t_1) {
6140
6141 /* "breezy/bzr/_btree_serializer_pyx.pyx":602
6142 * record = self._lookup_record(sha1)
6143 * if record != NULL:
6144 * self.last_key = key # <<<<<<<<<<<<<<
6145 * self.last_record = record
6146 * return True
6147 */
6148 __Pyx_INCREF(__pyx_v_key);
6149 __Pyx_GIVEREF(__pyx_v_key);
6150 __Pyx_GOTREF(__pyx_v_self->last_key);
6151 __Pyx_DECREF(__pyx_v_self->last_key);
6152 __pyx_v_self->last_key = __pyx_v_key;
6153
6154 /* "breezy/bzr/_btree_serializer_pyx.pyx":603
6155 * if record != NULL:
6156 * self.last_key = key
6157 * self.last_record = record # <<<<<<<<<<<<<<
6158 * return True
6159 * return False
6160 */
6161 __pyx_v_self->last_record = __pyx_v_record;
6162
6163 /* "breezy/bzr/_btree_serializer_pyx.pyx":604
6164 * self.last_key = key
6165 * self.last_record = record
6166 * return True # <<<<<<<<<<<<<<
6167 * return False
6168 *
6169 */
6170 __pyx_r = 1;
6171 goto __pyx_L0;
6172
6173 /* "breezy/bzr/_btree_serializer_pyx.pyx":601
6174 * # If it isn't a sha1 key, then it won't be in this leaf node
6175 * record = self._lookup_record(sha1)
6176 * if record != NULL: # <<<<<<<<<<<<<<
6177 * self.last_key = key
6178 * self.last_record = record
6179 */
6180 }
6181
6182 /* "breezy/bzr/_btree_serializer_pyx.pyx":598
6183 * cdef char sha1[20]
6184 * cdef gc_chk_sha1_record *record
6185 * if _key_to_sha1(key, sha1): # <<<<<<<<<<<<<<
6186 * # If it isn't a sha1 key, then it won't be in this leaf node
6187 * record = self._lookup_record(sha1)
6188 */
6189 }
6190
6191 /* "breezy/bzr/_btree_serializer_pyx.pyx":605
6192 * self.last_record = record
6193 * return True
6194 * return False # <<<<<<<<<<<<<<
6195 *
6196 * def __getitem__(self, key):
6197 */
6198 __pyx_r = 0;
6199 goto __pyx_L0;
6200
6201 /* "breezy/bzr/_btree_serializer_pyx.pyx":595
6202 * return NULL
6203 *
6204 * def __contains__(self, key): # <<<<<<<<<<<<<<
6205 * cdef char sha1[20]
6206 * cdef gc_chk_sha1_record *record
6207 */
6208
6209 /* function exit code */
6210 __pyx_L1_error:;
6211 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
6212 __pyx_r = -1;
6213 __pyx_L0:;
6214 __Pyx_RefNannyFinishContext();
6215 return __pyx_r;
6216 }
6217
6218 /* "breezy/bzr/_btree_serializer_pyx.pyx":607
6219 * return False
6220 *
6221 * def __getitem__(self, key): # <<<<<<<<<<<<<<
6222 * cdef char sha1[20]
6223 * cdef gc_chk_sha1_record *record
6224 */
6225
6226 /* Python wrapper */
6227 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_9__getitem__(PyObject * __pyx_v_self,PyObject * __pyx_v_key)6228 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
6229 PyObject *__pyx_r = 0;
6230 __Pyx_RefNannyDeclarations
6231 __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
6232 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8__getitem__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), ((PyObject *)__pyx_v_key));
6233
6234 /* function exit code */
6235 __Pyx_RefNannyFinishContext();
6236 return __pyx_r;
6237 }
6238
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8__getitem__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,PyObject * __pyx_v_key)6239 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8__getitem__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_key) {
6240 char __pyx_v_sha1[20];
6241 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_record;
6242 PyObject *__pyx_r = NULL;
6243 __Pyx_RefNannyDeclarations
6244 int __pyx_t_1;
6245 int __pyx_t_2;
6246 int __pyx_t_3;
6247 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_t_4;
6248 PyObject *__pyx_t_5 = NULL;
6249 Py_ssize_t __pyx_t_6;
6250 Py_UCS4 __pyx_t_7;
6251 PyObject *__pyx_t_8 = NULL;
6252 int __pyx_lineno = 0;
6253 const char *__pyx_filename = NULL;
6254 int __pyx_clineno = 0;
6255 __Pyx_RefNannySetupContext("__getitem__", 0);
6256
6257 /* "breezy/bzr/_btree_serializer_pyx.pyx":610
6258 * cdef char sha1[20]
6259 * cdef gc_chk_sha1_record *record
6260 * record = NULL # <<<<<<<<<<<<<<
6261 * if self.last_record != NULL and key is self.last_key:
6262 * record = self.last_record
6263 */
6264 __pyx_v_record = NULL;
6265
6266 /* "breezy/bzr/_btree_serializer_pyx.pyx":611
6267 * cdef gc_chk_sha1_record *record
6268 * record = NULL
6269 * if self.last_record != NULL and key is self.last_key: # <<<<<<<<<<<<<<
6270 * record = self.last_record
6271 * elif _key_to_sha1(key, sha1):
6272 */
6273 __pyx_t_2 = ((__pyx_v_self->last_record != NULL) != 0);
6274 if (__pyx_t_2) {
6275 } else {
6276 __pyx_t_1 = __pyx_t_2;
6277 goto __pyx_L4_bool_binop_done;
6278 }
6279 __pyx_t_2 = (__pyx_v_key == __pyx_v_self->last_key);
6280 __pyx_t_3 = (__pyx_t_2 != 0);
6281 __pyx_t_1 = __pyx_t_3;
6282 __pyx_L4_bool_binop_done:;
6283 if (__pyx_t_1) {
6284
6285 /* "breezy/bzr/_btree_serializer_pyx.pyx":612
6286 * record = NULL
6287 * if self.last_record != NULL and key is self.last_key:
6288 * record = self.last_record # <<<<<<<<<<<<<<
6289 * elif _key_to_sha1(key, sha1):
6290 * record = self._lookup_record(sha1)
6291 */
6292 __pyx_t_4 = __pyx_v_self->last_record;
6293 __pyx_v_record = __pyx_t_4;
6294
6295 /* "breezy/bzr/_btree_serializer_pyx.pyx":611
6296 * cdef gc_chk_sha1_record *record
6297 * record = NULL
6298 * if self.last_record != NULL and key is self.last_key: # <<<<<<<<<<<<<<
6299 * record = self.last_record
6300 * elif _key_to_sha1(key, sha1):
6301 */
6302 goto __pyx_L3;
6303 }
6304
6305 /* "breezy/bzr/_btree_serializer_pyx.pyx":613
6306 * if self.last_record != NULL and key is self.last_key:
6307 * record = self.last_record
6308 * elif _key_to_sha1(key, sha1): # <<<<<<<<<<<<<<
6309 * record = self._lookup_record(sha1)
6310 * if record == NULL:
6311 */
6312 __pyx_t_1 = (__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__key_to_sha1(__pyx_v_key, __pyx_v_sha1) != 0);
6313 if (__pyx_t_1) {
6314
6315 /* "breezy/bzr/_btree_serializer_pyx.pyx":614
6316 * record = self.last_record
6317 * elif _key_to_sha1(key, sha1):
6318 * record = self._lookup_record(sha1) # <<<<<<<<<<<<<<
6319 * if record == NULL:
6320 * raise KeyError('key %r is not present' % (key,))
6321 */
6322 __pyx_t_4 = ((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_lookup_record(__pyx_v_self, __pyx_v_sha1); if (unlikely(__pyx_t_4 == ((__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 614, __pyx_L1_error)
6323 __pyx_v_record = __pyx_t_4;
6324
6325 /* "breezy/bzr/_btree_serializer_pyx.pyx":613
6326 * if self.last_record != NULL and key is self.last_key:
6327 * record = self.last_record
6328 * elif _key_to_sha1(key, sha1): # <<<<<<<<<<<<<<
6329 * record = self._lookup_record(sha1)
6330 * if record == NULL:
6331 */
6332 }
6333 __pyx_L3:;
6334
6335 /* "breezy/bzr/_btree_serializer_pyx.pyx":615
6336 * elif _key_to_sha1(key, sha1):
6337 * record = self._lookup_record(sha1)
6338 * if record == NULL: # <<<<<<<<<<<<<<
6339 * raise KeyError('key %r is not present' % (key,))
6340 * return self._record_to_value_and_refs(record)
6341 */
6342 __pyx_t_1 = ((__pyx_v_record == NULL) != 0);
6343 if (unlikely(__pyx_t_1)) {
6344
6345 /* "breezy/bzr/_btree_serializer_pyx.pyx":616
6346 * record = self._lookup_record(sha1)
6347 * if record == NULL:
6348 * raise KeyError('key %r is not present' % (key,)) # <<<<<<<<<<<<<<
6349 * return self._record_to_value_and_refs(record)
6350 *
6351 */
6352 __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 616, __pyx_L1_error)
6353 __Pyx_GOTREF(__pyx_t_5);
6354 __pyx_t_6 = 0;
6355 __pyx_t_7 = 127;
6356 __Pyx_INCREF(__pyx_kp_u_key);
6357 __pyx_t_6 += 4;
6358 __Pyx_GIVEREF(__pyx_kp_u_key);
6359 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_key);
6360 __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_key), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 616, __pyx_L1_error)
6361 __Pyx_GOTREF(__pyx_t_8);
6362 __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_7;
6363 __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8);
6364 __Pyx_GIVEREF(__pyx_t_8);
6365 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_8);
6366 __pyx_t_8 = 0;
6367 __Pyx_INCREF(__pyx_kp_u_is_not_present);
6368 __pyx_t_6 += 15;
6369 __Pyx_GIVEREF(__pyx_kp_u_is_not_present);
6370 PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_is_not_present);
6371 __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 616, __pyx_L1_error)
6372 __Pyx_GOTREF(__pyx_t_8);
6373 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6374 __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 616, __pyx_L1_error)
6375 __Pyx_GOTREF(__pyx_t_5);
6376 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6377 __Pyx_Raise(__pyx_t_5, 0, 0, 0);
6378 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6379 __PYX_ERR(0, 616, __pyx_L1_error)
6380
6381 /* "breezy/bzr/_btree_serializer_pyx.pyx":615
6382 * elif _key_to_sha1(key, sha1):
6383 * record = self._lookup_record(sha1)
6384 * if record == NULL: # <<<<<<<<<<<<<<
6385 * raise KeyError('key %r is not present' % (key,))
6386 * return self._record_to_value_and_refs(record)
6387 */
6388 }
6389
6390 /* "breezy/bzr/_btree_serializer_pyx.pyx":617
6391 * if record == NULL:
6392 * raise KeyError('key %r is not present' % (key,))
6393 * return self._record_to_value_and_refs(record) # <<<<<<<<<<<<<<
6394 *
6395 * def __len__(self):
6396 */
6397 __Pyx_XDECREF(__pyx_r);
6398 __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_6breezy_3bzr_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_5)) __PYX_ERR(0, 617, __pyx_L1_error)
6399 __Pyx_GOTREF(__pyx_t_5);
6400 __pyx_r = __pyx_t_5;
6401 __pyx_t_5 = 0;
6402 goto __pyx_L0;
6403
6404 /* "breezy/bzr/_btree_serializer_pyx.pyx":607
6405 * return False
6406 *
6407 * def __getitem__(self, key): # <<<<<<<<<<<<<<
6408 * cdef char sha1[20]
6409 * cdef gc_chk_sha1_record *record
6410 */
6411
6412 /* function exit code */
6413 __pyx_L1_error:;
6414 __Pyx_XDECREF(__pyx_t_5);
6415 __Pyx_XDECREF(__pyx_t_8);
6416 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
6417 __pyx_r = NULL;
6418 __pyx_L0:;
6419 __Pyx_XGIVEREF(__pyx_r);
6420 __Pyx_RefNannyFinishContext();
6421 return __pyx_r;
6422 }
6423
6424 /* "breezy/bzr/_btree_serializer_pyx.pyx":619
6425 * return self._record_to_value_and_refs(record)
6426 *
6427 * def __len__(self): # <<<<<<<<<<<<<<
6428 * return self.num_records
6429 *
6430 */
6431
6432 /* Python wrapper */
6433 static Py_ssize_t __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11__len__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11__len__(PyObject * __pyx_v_self)6434 static Py_ssize_t __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11__len__(PyObject *__pyx_v_self) {
6435 Py_ssize_t __pyx_r;
6436 __Pyx_RefNannyDeclarations
6437 __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
6438 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_10__len__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
6439
6440 /* function exit code */
6441 __Pyx_RefNannyFinishContext();
6442 return __pyx_r;
6443 }
6444
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_10__len__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)6445 static Py_ssize_t __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_10__len__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
6446 Py_ssize_t __pyx_r;
6447 __Pyx_RefNannyDeclarations
6448 __Pyx_RefNannySetupContext("__len__", 0);
6449
6450 /* "breezy/bzr/_btree_serializer_pyx.pyx":620
6451 *
6452 * def __len__(self):
6453 * return self.num_records # <<<<<<<<<<<<<<
6454 *
6455 * def all_keys(self):
6456 */
6457 __pyx_r = __pyx_v_self->num_records;
6458 goto __pyx_L0;
6459
6460 /* "breezy/bzr/_btree_serializer_pyx.pyx":619
6461 * return self._record_to_value_and_refs(record)
6462 *
6463 * def __len__(self): # <<<<<<<<<<<<<<
6464 * return self.num_records
6465 *
6466 */
6467
6468 /* function exit code */
6469 __pyx_L0:;
6470 __Pyx_RefNannyFinishContext();
6471 return __pyx_r;
6472 }
6473
6474 /* "breezy/bzr/_btree_serializer_pyx.pyx":622
6475 * return self.num_records
6476 *
6477 * def all_keys(self): # <<<<<<<<<<<<<<
6478 * cdef int i
6479 * result = []
6480 */
6481
6482 /* Python wrapper */
6483 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_13all_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_13all_keys(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)6484 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_13all_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
6485 PyObject *__pyx_r = 0;
6486 __Pyx_RefNannyDeclarations
6487 __Pyx_RefNannySetupContext("all_keys (wrapper)", 0);
6488 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12all_keys(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
6489
6490 /* function exit code */
6491 __Pyx_RefNannyFinishContext();
6492 return __pyx_r;
6493 }
6494
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12all_keys(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)6495 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12all_keys(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
6496 int __pyx_v_i;
6497 PyObject *__pyx_v_result = NULL;
6498 PyObject *__pyx_r = NULL;
6499 __Pyx_RefNannyDeclarations
6500 PyObject *__pyx_t_1 = NULL;
6501 int __pyx_t_2;
6502 int __pyx_t_3;
6503 int __pyx_lineno = 0;
6504 const char *__pyx_filename = NULL;
6505 int __pyx_clineno = 0;
6506 __Pyx_RefNannySetupContext("all_keys", 0);
6507
6508 /* "breezy/bzr/_btree_serializer_pyx.pyx":624
6509 * def all_keys(self):
6510 * cdef int i
6511 * result = [] # <<<<<<<<<<<<<<
6512 * for i from 0 <= i < self.num_records:
6513 * PyList_Append(result, _sha1_to_key(self.records[i].sha1))
6514 */
6515 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 624, __pyx_L1_error)
6516 __Pyx_GOTREF(__pyx_t_1);
6517 __pyx_v_result = ((PyObject*)__pyx_t_1);
6518 __pyx_t_1 = 0;
6519
6520 /* "breezy/bzr/_btree_serializer_pyx.pyx":625
6521 * cdef int i
6522 * result = []
6523 * for i from 0 <= i < self.num_records: # <<<<<<<<<<<<<<
6524 * PyList_Append(result, _sha1_to_key(self.records[i].sha1))
6525 * return result
6526 */
6527 __pyx_t_2 = __pyx_v_self->num_records;
6528 for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
6529
6530 /* "breezy/bzr/_btree_serializer_pyx.pyx":626
6531 * result = []
6532 * for i from 0 <= i < self.num_records:
6533 * PyList_Append(result, _sha1_to_key(self.records[i].sha1)) # <<<<<<<<<<<<<<
6534 * return result
6535 *
6536 */
6537 __pyx_t_1 = ((PyObject *)__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_key((__pyx_v_self->records[__pyx_v_i]).sha1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L1_error)
6538 __Pyx_GOTREF(__pyx_t_1);
6539 __pyx_t_3 = PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 626, __pyx_L1_error)
6540 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6541 }
6542
6543 /* "breezy/bzr/_btree_serializer_pyx.pyx":627
6544 * for i from 0 <= i < self.num_records:
6545 * PyList_Append(result, _sha1_to_key(self.records[i].sha1))
6546 * return result # <<<<<<<<<<<<<<
6547 *
6548 * def all_items(self):
6549 */
6550 __Pyx_XDECREF(__pyx_r);
6551 __Pyx_INCREF(__pyx_v_result);
6552 __pyx_r = __pyx_v_result;
6553 goto __pyx_L0;
6554
6555 /* "breezy/bzr/_btree_serializer_pyx.pyx":622
6556 * return self.num_records
6557 *
6558 * def all_keys(self): # <<<<<<<<<<<<<<
6559 * cdef int i
6560 * result = []
6561 */
6562
6563 /* function exit code */
6564 __pyx_L1_error:;
6565 __Pyx_XDECREF(__pyx_t_1);
6566 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.all_keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
6567 __pyx_r = NULL;
6568 __pyx_L0:;
6569 __Pyx_XDECREF(__pyx_v_result);
6570 __Pyx_XGIVEREF(__pyx_r);
6571 __Pyx_RefNannyFinishContext();
6572 return __pyx_r;
6573 }
6574
6575 /* "breezy/bzr/_btree_serializer_pyx.pyx":629
6576 * return result
6577 *
6578 * def all_items(self): # <<<<<<<<<<<<<<
6579 * cdef int i
6580 * result = []
6581 */
6582
6583 /* Python wrapper */
6584 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_15all_items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_15all_items(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)6585 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_15all_items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
6586 PyObject *__pyx_r = 0;
6587 __Pyx_RefNannyDeclarations
6588 __Pyx_RefNannySetupContext("all_items (wrapper)", 0);
6589 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_14all_items(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
6590
6591 /* function exit code */
6592 __Pyx_RefNannyFinishContext();
6593 return __pyx_r;
6594 }
6595
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_14all_items(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)6596 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_14all_items(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
6597 int __pyx_v_i;
6598 PyObject *__pyx_v_result = NULL;
6599 StaticTuple *__pyx_v_item = NULL;
6600 PyObject *__pyx_r = NULL;
6601 __Pyx_RefNannyDeclarations
6602 PyObject *__pyx_t_1 = NULL;
6603 int __pyx_t_2;
6604 int __pyx_t_3;
6605 int __pyx_lineno = 0;
6606 const char *__pyx_filename = NULL;
6607 int __pyx_clineno = 0;
6608 __Pyx_RefNannySetupContext("all_items", 0);
6609
6610 /* "breezy/bzr/_btree_serializer_pyx.pyx":631
6611 * def all_items(self):
6612 * cdef int i
6613 * result = [] # <<<<<<<<<<<<<<
6614 * for i from 0 <= i < self.num_records:
6615 * item = self._record_to_item(&self.records[i])
6616 */
6617 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error)
6618 __Pyx_GOTREF(__pyx_t_1);
6619 __pyx_v_result = ((PyObject*)__pyx_t_1);
6620 __pyx_t_1 = 0;
6621
6622 /* "breezy/bzr/_btree_serializer_pyx.pyx":632
6623 * cdef int i
6624 * result = []
6625 * for i from 0 <= i < self.num_records: # <<<<<<<<<<<<<<
6626 * item = self._record_to_item(&self.records[i])
6627 * PyList_Append(result, item)
6628 */
6629 __pyx_t_2 = __pyx_v_self->num_records;
6630 for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
6631
6632 /* "breezy/bzr/_btree_serializer_pyx.pyx":633
6633 * result = []
6634 * for i from 0 <= i < self.num_records:
6635 * item = self._record_to_item(&self.records[i]) # <<<<<<<<<<<<<<
6636 * PyList_Append(result, item)
6637 * return result
6638 */
6639 __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_record_to_item(__pyx_v_self, (&(__pyx_v_self->records[__pyx_v_i])))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
6640 __Pyx_GOTREF(__pyx_t_1);
6641 __Pyx_XDECREF_SET(__pyx_v_item, ((StaticTuple *)__pyx_t_1));
6642 __pyx_t_1 = 0;
6643
6644 /* "breezy/bzr/_btree_serializer_pyx.pyx":634
6645 * for i from 0 <= i < self.num_records:
6646 * item = self._record_to_item(&self.records[i])
6647 * PyList_Append(result, item) # <<<<<<<<<<<<<<
6648 * return result
6649 *
6650 */
6651 __pyx_t_3 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_v_item)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 634, __pyx_L1_error)
6652 }
6653
6654 /* "breezy/bzr/_btree_serializer_pyx.pyx":635
6655 * item = self._record_to_item(&self.records[i])
6656 * PyList_Append(result, item)
6657 * return result # <<<<<<<<<<<<<<
6658 *
6659 * cdef int _count_records(self, char *c_content, char *c_end): # cannot_raise
6660 */
6661 __Pyx_XDECREF(__pyx_r);
6662 __Pyx_INCREF(__pyx_v_result);
6663 __pyx_r = __pyx_v_result;
6664 goto __pyx_L0;
6665
6666 /* "breezy/bzr/_btree_serializer_pyx.pyx":629
6667 * return result
6668 *
6669 * def all_items(self): # <<<<<<<<<<<<<<
6670 * cdef int i
6671 * result = []
6672 */
6673
6674 /* function exit code */
6675 __pyx_L1_error:;
6676 __Pyx_XDECREF(__pyx_t_1);
6677 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.all_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
6678 __pyx_r = NULL;
6679 __pyx_L0:;
6680 __Pyx_XDECREF(__pyx_v_result);
6681 __Pyx_XDECREF((PyObject *)__pyx_v_item);
6682 __Pyx_XGIVEREF(__pyx_r);
6683 __Pyx_RefNannyFinishContext();
6684 return __pyx_r;
6685 }
6686
6687 /* "breezy/bzr/_btree_serializer_pyx.pyx":637
6688 * return result
6689 *
6690 * cdef int _count_records(self, char *c_content, char *c_end): # cannot_raise # <<<<<<<<<<<<<<
6691 * """Count how many records are in this section."""
6692 * cdef char *c_cur
6693 */
6694
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__count_records(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,char * __pyx_v_c_content,char * __pyx_v_c_end)6695 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__count_records(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_c_content, char *__pyx_v_c_end) {
6696 char *__pyx_v_c_cur;
6697 int __pyx_v_num_records;
6698 int __pyx_r;
6699 __Pyx_RefNannyDeclarations
6700 int __pyx_t_1;
6701 int __pyx_t_2;
6702 __Pyx_RefNannySetupContext("_count_records", 0);
6703
6704 /* "breezy/bzr/_btree_serializer_pyx.pyx":642
6705 * cdef int num_records
6706 *
6707 * c_cur = c_content # <<<<<<<<<<<<<<
6708 * num_records = 0
6709 * while c_cur != NULL and c_cur < c_end:
6710 */
6711 __pyx_v_c_cur = __pyx_v_c_content;
6712
6713 /* "breezy/bzr/_btree_serializer_pyx.pyx":643
6714 *
6715 * c_cur = c_content
6716 * num_records = 0 # <<<<<<<<<<<<<<
6717 * while c_cur != NULL and c_cur < c_end:
6718 * c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur);
6719 */
6720 __pyx_v_num_records = 0;
6721
6722 /* "breezy/bzr/_btree_serializer_pyx.pyx":644
6723 * c_cur = c_content
6724 * num_records = 0
6725 * while c_cur != NULL and c_cur < c_end: # <<<<<<<<<<<<<<
6726 * c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur);
6727 * if c_cur == NULL:
6728 */
6729 while (1) {
6730 __pyx_t_2 = ((__pyx_v_c_cur != NULL) != 0);
6731 if (__pyx_t_2) {
6732 } else {
6733 __pyx_t_1 = __pyx_t_2;
6734 goto __pyx_L5_bool_binop_done;
6735 }
6736 __pyx_t_2 = ((__pyx_v_c_cur < __pyx_v_c_end) != 0);
6737 __pyx_t_1 = __pyx_t_2;
6738 __pyx_L5_bool_binop_done:;
6739 if (!__pyx_t_1) break;
6740
6741 /* "breezy/bzr/_btree_serializer_pyx.pyx":645
6742 * num_records = 0
6743 * while c_cur != NULL and c_cur < c_end:
6744 * c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur); # <<<<<<<<<<<<<<
6745 * if c_cur == NULL:
6746 * break
6747 */
6748 __pyx_v_c_cur = ((char *)memchr(__pyx_v_c_cur, '\n', (__pyx_v_c_end - __pyx_v_c_cur)));
6749
6750 /* "breezy/bzr/_btree_serializer_pyx.pyx":646
6751 * while c_cur != NULL and c_cur < c_end:
6752 * c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur);
6753 * if c_cur == NULL: # <<<<<<<<<<<<<<
6754 * break
6755 * c_cur = c_cur + 1
6756 */
6757 __pyx_t_1 = ((__pyx_v_c_cur == NULL) != 0);
6758 if (__pyx_t_1) {
6759
6760 /* "breezy/bzr/_btree_serializer_pyx.pyx":647
6761 * c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur);
6762 * if c_cur == NULL:
6763 * break # <<<<<<<<<<<<<<
6764 * c_cur = c_cur + 1
6765 * num_records = num_records + 1
6766 */
6767 goto __pyx_L4_break;
6768
6769 /* "breezy/bzr/_btree_serializer_pyx.pyx":646
6770 * while c_cur != NULL and c_cur < c_end:
6771 * c_cur = <char *>memchr(c_cur, c'\n', c_end - c_cur);
6772 * if c_cur == NULL: # <<<<<<<<<<<<<<
6773 * break
6774 * c_cur = c_cur + 1
6775 */
6776 }
6777
6778 /* "breezy/bzr/_btree_serializer_pyx.pyx":648
6779 * if c_cur == NULL:
6780 * break
6781 * c_cur = c_cur + 1 # <<<<<<<<<<<<<<
6782 * num_records = num_records + 1
6783 * return num_records
6784 */
6785 __pyx_v_c_cur = (__pyx_v_c_cur + 1);
6786
6787 /* "breezy/bzr/_btree_serializer_pyx.pyx":649
6788 * break
6789 * c_cur = c_cur + 1
6790 * num_records = num_records + 1 # <<<<<<<<<<<<<<
6791 * return num_records
6792 *
6793 */
6794 __pyx_v_num_records = (__pyx_v_num_records + 1);
6795 }
6796 __pyx_L4_break:;
6797
6798 /* "breezy/bzr/_btree_serializer_pyx.pyx":650
6799 * c_cur = c_cur + 1
6800 * num_records = num_records + 1
6801 * return num_records # <<<<<<<<<<<<<<
6802 *
6803 * cdef _parse_bytes(self, data):
6804 */
6805 __pyx_r = __pyx_v_num_records;
6806 goto __pyx_L0;
6807
6808 /* "breezy/bzr/_btree_serializer_pyx.pyx":637
6809 * return result
6810 *
6811 * cdef int _count_records(self, char *c_content, char *c_end): # cannot_raise # <<<<<<<<<<<<<<
6812 * """Count how many records are in this section."""
6813 * cdef char *c_cur
6814 */
6815
6816 /* function exit code */
6817 __pyx_L0:;
6818 __Pyx_RefNannyFinishContext();
6819 return __pyx_r;
6820 }
6821
6822 /* "breezy/bzr/_btree_serializer_pyx.pyx":652
6823 * return num_records
6824 *
6825 * cdef _parse_bytes(self, data): # <<<<<<<<<<<<<<
6826 * """Parse the bytes 'data' into content."""
6827 * cdef char *c_bytes
6828 */
6829
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_bytes(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,PyObject * __pyx_v_data)6830 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_bytes(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_data) {
6831 char *__pyx_v_c_bytes;
6832 char *__pyx_v_c_cur;
6833 char *__pyx_v_c_end;
6834 Py_ssize_t __pyx_v_n_bytes;
6835 int __pyx_v_num_records;
6836 int __pyx_v_entry;
6837 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_cur_record;
6838 PyObject *__pyx_r = NULL;
6839 __Pyx_RefNannyDeclarations
6840 int __pyx_t_1;
6841 PyObject *__pyx_t_2 = NULL;
6842 PyObject *__pyx_t_3 = NULL;
6843 __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_t_4;
6844 int __pyx_t_5;
6845 char *__pyx_t_6;
6846 int __pyx_lineno = 0;
6847 const char *__pyx_filename = NULL;
6848 int __pyx_clineno = 0;
6849 __Pyx_RefNannySetupContext("_parse_bytes", 0);
6850
6851 /* "breezy/bzr/_btree_serializer_pyx.pyx":662
6852 * cdef gc_chk_sha1_record *cur_record
6853 *
6854 * if not PyBytes_CheckExact(data): # <<<<<<<<<<<<<<
6855 * raise TypeError('We only support parsing byte strings.')
6856 * # Pass 1, count how many records there will be
6857 */
6858 __pyx_t_1 = ((!(PyBytes_CheckExact(__pyx_v_data) != 0)) != 0);
6859 if (unlikely(__pyx_t_1)) {
6860
6861 /* "breezy/bzr/_btree_serializer_pyx.pyx":663
6862 *
6863 * if not PyBytes_CheckExact(data):
6864 * raise TypeError('We only support parsing byte strings.') # <<<<<<<<<<<<<<
6865 * # Pass 1, count how many records there will be
6866 * n_bytes = PyBytes_GET_SIZE(data)
6867 */
6868 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 663, __pyx_L1_error)
6869 __Pyx_GOTREF(__pyx_t_2);
6870 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
6871 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6872 __PYX_ERR(0, 663, __pyx_L1_error)
6873
6874 /* "breezy/bzr/_btree_serializer_pyx.pyx":662
6875 * cdef gc_chk_sha1_record *cur_record
6876 *
6877 * if not PyBytes_CheckExact(data): # <<<<<<<<<<<<<<
6878 * raise TypeError('We only support parsing byte strings.')
6879 * # Pass 1, count how many records there will be
6880 */
6881 }
6882
6883 /* "breezy/bzr/_btree_serializer_pyx.pyx":665
6884 * raise TypeError('We only support parsing byte strings.')
6885 * # Pass 1, count how many records there will be
6886 * n_bytes = PyBytes_GET_SIZE(data) # <<<<<<<<<<<<<<
6887 * c_bytes = PyBytes_AS_STRING(data)
6888 * c_end = c_bytes + n_bytes
6889 */
6890 __pyx_v_n_bytes = PyBytes_GET_SIZE(__pyx_v_data);
6891
6892 /* "breezy/bzr/_btree_serializer_pyx.pyx":666
6893 * # Pass 1, count how many records there will be
6894 * n_bytes = PyBytes_GET_SIZE(data)
6895 * c_bytes = PyBytes_AS_STRING(data) # <<<<<<<<<<<<<<
6896 * c_end = c_bytes + n_bytes
6897 * if strncmp(c_bytes, b'type=leaf\n', 10):
6898 */
6899 __pyx_v_c_bytes = PyBytes_AS_STRING(__pyx_v_data);
6900
6901 /* "breezy/bzr/_btree_serializer_pyx.pyx":667
6902 * n_bytes = PyBytes_GET_SIZE(data)
6903 * c_bytes = PyBytes_AS_STRING(data)
6904 * c_end = c_bytes + n_bytes # <<<<<<<<<<<<<<
6905 * if strncmp(c_bytes, b'type=leaf\n', 10):
6906 * raise ValueError("bytes did not start with 'type=leaf\\n': %r"
6907 */
6908 __pyx_v_c_end = (__pyx_v_c_bytes + __pyx_v_n_bytes);
6909
6910 /* "breezy/bzr/_btree_serializer_pyx.pyx":668
6911 * c_bytes = PyBytes_AS_STRING(data)
6912 * c_end = c_bytes + n_bytes
6913 * if strncmp(c_bytes, b'type=leaf\n', 10): # <<<<<<<<<<<<<<
6914 * raise ValueError("bytes did not start with 'type=leaf\\n': %r"
6915 * % (data[:10],))
6916 */
6917 __pyx_t_1 = (strncmp(__pyx_v_c_bytes, ((char const *)"type=leaf\n"), 10) != 0);
6918 if (unlikely(__pyx_t_1)) {
6919
6920 /* "breezy/bzr/_btree_serializer_pyx.pyx":670
6921 * if strncmp(c_bytes, b'type=leaf\n', 10):
6922 * raise ValueError("bytes did not start with 'type=leaf\\n': %r"
6923 * % (data[:10],)) # <<<<<<<<<<<<<<
6924 * c_cur = c_bytes + 10
6925 * num_records = self._count_records(c_cur, c_end)
6926 */
6927 __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_data, 0, 10, NULL, NULL, &__pyx_slice__10, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 670, __pyx_L1_error)
6928 __Pyx_GOTREF(__pyx_t_2);
6929 __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 670, __pyx_L1_error)
6930 __Pyx_GOTREF(__pyx_t_3);
6931 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6932
6933 /* "breezy/bzr/_btree_serializer_pyx.pyx":669
6934 * c_end = c_bytes + n_bytes
6935 * if strncmp(c_bytes, b'type=leaf\n', 10):
6936 * raise ValueError("bytes did not start with 'type=leaf\\n': %r" # <<<<<<<<<<<<<<
6937 * % (data[:10],))
6938 * c_cur = c_bytes + 10
6939 */
6940 __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_bytes_did_not_start_with_type_le, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error)
6941 __Pyx_GOTREF(__pyx_t_2);
6942 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6943 __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 669, __pyx_L1_error)
6944 __Pyx_GOTREF(__pyx_t_3);
6945 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6946 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
6947 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6948 __PYX_ERR(0, 669, __pyx_L1_error)
6949
6950 /* "breezy/bzr/_btree_serializer_pyx.pyx":668
6951 * c_bytes = PyBytes_AS_STRING(data)
6952 * c_end = c_bytes + n_bytes
6953 * if strncmp(c_bytes, b'type=leaf\n', 10): # <<<<<<<<<<<<<<
6954 * raise ValueError("bytes did not start with 'type=leaf\\n': %r"
6955 * % (data[:10],))
6956 */
6957 }
6958
6959 /* "breezy/bzr/_btree_serializer_pyx.pyx":671
6960 * raise ValueError("bytes did not start with 'type=leaf\\n': %r"
6961 * % (data[:10],))
6962 * c_cur = c_bytes + 10 # <<<<<<<<<<<<<<
6963 * num_records = self._count_records(c_cur, c_end)
6964 * # Now allocate the memory for these items, and go to town
6965 */
6966 __pyx_v_c_cur = (__pyx_v_c_bytes + 10);
6967
6968 /* "breezy/bzr/_btree_serializer_pyx.pyx":672
6969 * % (data[:10],))
6970 * c_cur = c_bytes + 10
6971 * num_records = self._count_records(c_cur, c_end) # <<<<<<<<<<<<<<
6972 * # Now allocate the memory for these items, and go to town
6973 * self.records = <gc_chk_sha1_record*>PyMem_Malloc(num_records *
6974 */
6975 __pyx_v_num_records = ((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_count_records(__pyx_v_self, __pyx_v_c_cur, __pyx_v_c_end);
6976
6977 /* "breezy/bzr/_btree_serializer_pyx.pyx":674
6978 * num_records = self._count_records(c_cur, c_end)
6979 * # Now allocate the memory for these items, and go to town
6980 * self.records = <gc_chk_sha1_record*>PyMem_Malloc(num_records * # <<<<<<<<<<<<<<
6981 * (sizeof(unsigned short) + sizeof(gc_chk_sha1_record)))
6982 * self.num_records = num_records
6983 */
6984 __pyx_v_self->records = ((__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *)PyMem_Malloc((__pyx_v_num_records * ((sizeof(unsigned short)) + (sizeof(__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record))))));
6985
6986 /* "breezy/bzr/_btree_serializer_pyx.pyx":676
6987 * self.records = <gc_chk_sha1_record*>PyMem_Malloc(num_records *
6988 * (sizeof(unsigned short) + sizeof(gc_chk_sha1_record)))
6989 * self.num_records = num_records # <<<<<<<<<<<<<<
6990 * cur_record = self.records
6991 * entry = 0
6992 */
6993 __pyx_v_self->num_records = __pyx_v_num_records;
6994
6995 /* "breezy/bzr/_btree_serializer_pyx.pyx":677
6996 * (sizeof(unsigned short) + sizeof(gc_chk_sha1_record)))
6997 * self.num_records = num_records
6998 * cur_record = self.records # <<<<<<<<<<<<<<
6999 * entry = 0
7000 * while c_cur != NULL and c_cur < c_end and entry < num_records:
7001 */
7002 __pyx_t_4 = __pyx_v_self->records;
7003 __pyx_v_cur_record = __pyx_t_4;
7004
7005 /* "breezy/bzr/_btree_serializer_pyx.pyx":678
7006 * self.num_records = num_records
7007 * cur_record = self.records
7008 * entry = 0 # <<<<<<<<<<<<<<
7009 * while c_cur != NULL and c_cur < c_end and entry < num_records:
7010 * c_cur = self._parse_one_entry(c_cur, c_end, cur_record)
7011 */
7012 __pyx_v_entry = 0;
7013
7014 /* "breezy/bzr/_btree_serializer_pyx.pyx":679
7015 * cur_record = self.records
7016 * entry = 0
7017 * while c_cur != NULL and c_cur < c_end and entry < num_records: # <<<<<<<<<<<<<<
7018 * c_cur = self._parse_one_entry(c_cur, c_end, cur_record)
7019 * cur_record = cur_record + 1
7020 */
7021 while (1) {
7022 __pyx_t_5 = ((__pyx_v_c_cur != NULL) != 0);
7023 if (__pyx_t_5) {
7024 } else {
7025 __pyx_t_1 = __pyx_t_5;
7026 goto __pyx_L7_bool_binop_done;
7027 }
7028 __pyx_t_5 = ((__pyx_v_c_cur < __pyx_v_c_end) != 0);
7029 if (__pyx_t_5) {
7030 } else {
7031 __pyx_t_1 = __pyx_t_5;
7032 goto __pyx_L7_bool_binop_done;
7033 }
7034 __pyx_t_5 = ((__pyx_v_entry < __pyx_v_num_records) != 0);
7035 __pyx_t_1 = __pyx_t_5;
7036 __pyx_L7_bool_binop_done:;
7037 if (!__pyx_t_1) break;
7038
7039 /* "breezy/bzr/_btree_serializer_pyx.pyx":680
7040 * entry = 0
7041 * while c_cur != NULL and c_cur < c_end and entry < num_records:
7042 * c_cur = self._parse_one_entry(c_cur, c_end, cur_record) # <<<<<<<<<<<<<<
7043 * cur_record = cur_record + 1
7044 * entry = entry + 1
7045 */
7046 __pyx_t_6 = ((struct __pyx_vtabstruct_6breezy_3bzr_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_6 == ((char *)NULL))) __PYX_ERR(0, 680, __pyx_L1_error)
7047 __pyx_v_c_cur = __pyx_t_6;
7048
7049 /* "breezy/bzr/_btree_serializer_pyx.pyx":681
7050 * while c_cur != NULL and c_cur < c_end and entry < num_records:
7051 * c_cur = self._parse_one_entry(c_cur, c_end, cur_record)
7052 * cur_record = cur_record + 1 # <<<<<<<<<<<<<<
7053 * entry = entry + 1
7054 * if (entry != self.num_records
7055 */
7056 __pyx_v_cur_record = (__pyx_v_cur_record + 1);
7057
7058 /* "breezy/bzr/_btree_serializer_pyx.pyx":682
7059 * c_cur = self._parse_one_entry(c_cur, c_end, cur_record)
7060 * cur_record = cur_record + 1
7061 * entry = entry + 1 # <<<<<<<<<<<<<<
7062 * if (entry != self.num_records
7063 * or c_cur != c_end
7064 */
7065 __pyx_v_entry = (__pyx_v_entry + 1);
7066 }
7067
7068 /* "breezy/bzr/_btree_serializer_pyx.pyx":683
7069 * cur_record = cur_record + 1
7070 * entry = entry + 1
7071 * if (entry != self.num_records # <<<<<<<<<<<<<<
7072 * or c_cur != c_end
7073 * or cur_record != self.records + self.num_records):
7074 */
7075 __pyx_t_5 = ((__pyx_v_entry != __pyx_v_self->num_records) != 0);
7076 if (!__pyx_t_5) {
7077 } else {
7078 __pyx_t_1 = __pyx_t_5;
7079 goto __pyx_L11_bool_binop_done;
7080 }
7081
7082 /* "breezy/bzr/_btree_serializer_pyx.pyx":684
7083 * entry = entry + 1
7084 * if (entry != self.num_records
7085 * or c_cur != c_end # <<<<<<<<<<<<<<
7086 * or cur_record != self.records + self.num_records):
7087 * raise ValueError('Something went wrong while parsing.')
7088 */
7089 __pyx_t_5 = ((__pyx_v_c_cur != __pyx_v_c_end) != 0);
7090 if (!__pyx_t_5) {
7091 } else {
7092 __pyx_t_1 = __pyx_t_5;
7093 goto __pyx_L11_bool_binop_done;
7094 }
7095
7096 /* "breezy/bzr/_btree_serializer_pyx.pyx":685
7097 * if (entry != self.num_records
7098 * or c_cur != c_end
7099 * or cur_record != self.records + self.num_records): # <<<<<<<<<<<<<<
7100 * raise ValueError('Something went wrong while parsing.')
7101 * # Pass 3: build the offset map
7102 */
7103 __pyx_t_5 = ((__pyx_v_cur_record != (__pyx_v_self->records + __pyx_v_self->num_records)) != 0);
7104 __pyx_t_1 = __pyx_t_5;
7105 __pyx_L11_bool_binop_done:;
7106
7107 /* "breezy/bzr/_btree_serializer_pyx.pyx":683
7108 * cur_record = cur_record + 1
7109 * entry = entry + 1
7110 * if (entry != self.num_records # <<<<<<<<<<<<<<
7111 * or c_cur != c_end
7112 * or cur_record != self.records + self.num_records):
7113 */
7114 if (unlikely(__pyx_t_1)) {
7115
7116 /* "breezy/bzr/_btree_serializer_pyx.pyx":686
7117 * or c_cur != c_end
7118 * or cur_record != self.records + self.num_records):
7119 * raise ValueError('Something went wrong while parsing.') # <<<<<<<<<<<<<<
7120 * # Pass 3: build the offset map
7121 * self._compute_common()
7122 */
7123 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 686, __pyx_L1_error)
7124 __Pyx_GOTREF(__pyx_t_3);
7125 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7126 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7127 __PYX_ERR(0, 686, __pyx_L1_error)
7128
7129 /* "breezy/bzr/_btree_serializer_pyx.pyx":683
7130 * cur_record = cur_record + 1
7131 * entry = entry + 1
7132 * if (entry != self.num_records # <<<<<<<<<<<<<<
7133 * or c_cur != c_end
7134 * or cur_record != self.records + self.num_records):
7135 */
7136 }
7137
7138 /* "breezy/bzr/_btree_serializer_pyx.pyx":688
7139 * raise ValueError('Something went wrong while parsing.')
7140 * # Pass 3: build the offset map
7141 * self._compute_common() # <<<<<<<<<<<<<<
7142 *
7143 * cdef char *_parse_one_entry(self, char *c_cur, char *c_end,
7144 */
7145 __pyx_t_3 = ((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_compute_common(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 688, __pyx_L1_error)
7146 __Pyx_GOTREF(__pyx_t_3);
7147 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7148
7149 /* "breezy/bzr/_btree_serializer_pyx.pyx":652
7150 * return num_records
7151 *
7152 * cdef _parse_bytes(self, data): # <<<<<<<<<<<<<<
7153 * """Parse the bytes 'data' into content."""
7154 * cdef char *c_bytes
7155 */
7156
7157 /* function exit code */
7158 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7159 goto __pyx_L0;
7160 __pyx_L1_error:;
7161 __Pyx_XDECREF(__pyx_t_2);
7162 __Pyx_XDECREF(__pyx_t_3);
7163 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode._parse_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
7164 __pyx_r = 0;
7165 __pyx_L0:;
7166 __Pyx_XGIVEREF(__pyx_r);
7167 __Pyx_RefNannyFinishContext();
7168 return __pyx_r;
7169 }
7170
7171 /* "breezy/bzr/_btree_serializer_pyx.pyx":690
7172 * self._compute_common()
7173 *
7174 * cdef char *_parse_one_entry(self, char *c_cur, char *c_end, # <<<<<<<<<<<<<<
7175 * gc_chk_sha1_record *cur_record) except NULL:
7176 * """Read a single sha record from the bytes.
7177 */
7178
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_one_entry(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,char * __pyx_v_c_cur,char * __pyx_v_c_end,__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record * __pyx_v_cur_record)7179 static char *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_one_entry(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_c_cur, char *__pyx_v_c_end, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *__pyx_v_cur_record) {
7180 char *__pyx_v_c_next;
7181 char *__pyx_r;
7182 __Pyx_RefNannyDeclarations
7183 int __pyx_t_1;
7184 PyObject *__pyx_t_2 = NULL;
7185 PyObject *__pyx_t_3 = NULL;
7186 int __pyx_t_4;
7187 int __pyx_lineno = 0;
7188 const char *__pyx_filename = NULL;
7189 int __pyx_clineno = 0;
7190 __Pyx_RefNannySetupContext("_parse_one_entry", 0);
7191
7192 /* "breezy/bzr/_btree_serializer_pyx.pyx":698
7193 * """
7194 * cdef char *c_next
7195 * if strncmp(c_cur, 'sha1:', 5): # <<<<<<<<<<<<<<
7196 * raise ValueError('line did not start with sha1: %r'
7197 * % (safe_string_from_size(c_cur, 10),))
7198 */
7199 __pyx_t_1 = (strncmp(__pyx_v_c_cur, ((char const *)"sha1:"), 5) != 0);
7200 if (unlikely(__pyx_t_1)) {
7201
7202 /* "breezy/bzr/_btree_serializer_pyx.pyx":700
7203 * if strncmp(c_cur, 'sha1:', 5):
7204 * raise ValueError('line did not start with sha1: %r'
7205 * % (safe_string_from_size(c_cur, 10),)) # <<<<<<<<<<<<<<
7206 * c_cur = c_cur + 5
7207 * c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
7208 */
7209 __pyx_t_2 = __pyx_f_6breezy_3bzr_12_str_helpers_safe_string_from_size(__pyx_v_c_cur, 10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 700, __pyx_L1_error)
7210 __Pyx_GOTREF(__pyx_t_2);
7211 __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 700, __pyx_L1_error)
7212 __Pyx_GOTREF(__pyx_t_3);
7213 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7214
7215 /* "breezy/bzr/_btree_serializer_pyx.pyx":699
7216 * cdef char *c_next
7217 * if strncmp(c_cur, 'sha1:', 5):
7218 * raise ValueError('line did not start with sha1: %r' # <<<<<<<<<<<<<<
7219 * % (safe_string_from_size(c_cur, 10),))
7220 * c_cur = c_cur + 5
7221 */
7222 __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_line_did_not_start_with_sha1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 699, __pyx_L1_error)
7223 __Pyx_GOTREF(__pyx_t_2);
7224 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7225 __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 699, __pyx_L1_error)
7226 __Pyx_GOTREF(__pyx_t_3);
7227 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7228 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7229 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7230 __PYX_ERR(0, 699, __pyx_L1_error)
7231
7232 /* "breezy/bzr/_btree_serializer_pyx.pyx":698
7233 * """
7234 * cdef char *c_next
7235 * if strncmp(c_cur, 'sha1:', 5): # <<<<<<<<<<<<<<
7236 * raise ValueError('line did not start with sha1: %r'
7237 * % (safe_string_from_size(c_cur, 10),))
7238 */
7239 }
7240
7241 /* "breezy/bzr/_btree_serializer_pyx.pyx":701
7242 * raise ValueError('line did not start with sha1: %r'
7243 * % (safe_string_from_size(c_cur, 10),))
7244 * c_cur = c_cur + 5 # <<<<<<<<<<<<<<
7245 * c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
7246 * if c_next == NULL or (c_next - c_cur != 40):
7247 */
7248 __pyx_v_c_cur = (__pyx_v_c_cur + 5);
7249
7250 /* "breezy/bzr/_btree_serializer_pyx.pyx":702
7251 * % (safe_string_from_size(c_cur, 10),))
7252 * c_cur = c_cur + 5
7253 * c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur) # <<<<<<<<<<<<<<
7254 * if c_next == NULL or (c_next - c_cur != 40):
7255 * raise ValueError('Line did not contain 40 hex bytes')
7256 */
7257 __pyx_v_c_next = ((char *)memchr(__pyx_v_c_cur, '\x00', (__pyx_v_c_end - __pyx_v_c_cur)));
7258
7259 /* "breezy/bzr/_btree_serializer_pyx.pyx":703
7260 * c_cur = c_cur + 5
7261 * c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
7262 * if c_next == NULL or (c_next - c_cur != 40): # <<<<<<<<<<<<<<
7263 * raise ValueError('Line did not contain 40 hex bytes')
7264 * if not _unhexlify_sha1(c_cur, cur_record.sha1):
7265 */
7266 __pyx_t_4 = ((__pyx_v_c_next == NULL) != 0);
7267 if (!__pyx_t_4) {
7268 } else {
7269 __pyx_t_1 = __pyx_t_4;
7270 goto __pyx_L5_bool_binop_done;
7271 }
7272 __pyx_t_4 = (((__pyx_v_c_next - __pyx_v_c_cur) != 40) != 0);
7273 __pyx_t_1 = __pyx_t_4;
7274 __pyx_L5_bool_binop_done:;
7275 if (unlikely(__pyx_t_1)) {
7276
7277 /* "breezy/bzr/_btree_serializer_pyx.pyx":704
7278 * c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
7279 * if c_next == NULL or (c_next - c_cur != 40):
7280 * raise ValueError('Line did not contain 40 hex bytes') # <<<<<<<<<<<<<<
7281 * if not _unhexlify_sha1(c_cur, cur_record.sha1):
7282 * raise ValueError('We failed to unhexlify')
7283 */
7284 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 704, __pyx_L1_error)
7285 __Pyx_GOTREF(__pyx_t_3);
7286 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7287 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7288 __PYX_ERR(0, 704, __pyx_L1_error)
7289
7290 /* "breezy/bzr/_btree_serializer_pyx.pyx":703
7291 * c_cur = c_cur + 5
7292 * c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
7293 * if c_next == NULL or (c_next - c_cur != 40): # <<<<<<<<<<<<<<
7294 * raise ValueError('Line did not contain 40 hex bytes')
7295 * if not _unhexlify_sha1(c_cur, cur_record.sha1):
7296 */
7297 }
7298
7299 /* "breezy/bzr/_btree_serializer_pyx.pyx":705
7300 * if c_next == NULL or (c_next - c_cur != 40):
7301 * raise ValueError('Line did not contain 40 hex bytes')
7302 * if not _unhexlify_sha1(c_cur, cur_record.sha1): # <<<<<<<<<<<<<<
7303 * raise ValueError('We failed to unhexlify')
7304 * c_cur = c_next + 1
7305 */
7306 __pyx_t_1 = ((!(__pyx_f_6breezy_3bzr_21_btree_serializer_pyx__unhexlify_sha1(__pyx_v_c_cur, __pyx_v_cur_record->sha1) != 0)) != 0);
7307 if (unlikely(__pyx_t_1)) {
7308
7309 /* "breezy/bzr/_btree_serializer_pyx.pyx":706
7310 * raise ValueError('Line did not contain 40 hex bytes')
7311 * if not _unhexlify_sha1(c_cur, cur_record.sha1):
7312 * raise ValueError('We failed to unhexlify') # <<<<<<<<<<<<<<
7313 * c_cur = c_next + 1
7314 * if c_cur[0] != c'\0':
7315 */
7316 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 706, __pyx_L1_error)
7317 __Pyx_GOTREF(__pyx_t_3);
7318 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7319 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7320 __PYX_ERR(0, 706, __pyx_L1_error)
7321
7322 /* "breezy/bzr/_btree_serializer_pyx.pyx":705
7323 * if c_next == NULL or (c_next - c_cur != 40):
7324 * raise ValueError('Line did not contain 40 hex bytes')
7325 * if not _unhexlify_sha1(c_cur, cur_record.sha1): # <<<<<<<<<<<<<<
7326 * raise ValueError('We failed to unhexlify')
7327 * c_cur = c_next + 1
7328 */
7329 }
7330
7331 /* "breezy/bzr/_btree_serializer_pyx.pyx":707
7332 * if not _unhexlify_sha1(c_cur, cur_record.sha1):
7333 * raise ValueError('We failed to unhexlify')
7334 * c_cur = c_next + 1 # <<<<<<<<<<<<<<
7335 * if c_cur[0] != c'\0':
7336 * raise ValueError('only 1 null, not 2 as expected')
7337 */
7338 __pyx_v_c_cur = (__pyx_v_c_next + 1);
7339
7340 /* "breezy/bzr/_btree_serializer_pyx.pyx":708
7341 * raise ValueError('We failed to unhexlify')
7342 * c_cur = c_next + 1
7343 * if c_cur[0] != c'\0': # <<<<<<<<<<<<<<
7344 * raise ValueError('only 1 null, not 2 as expected')
7345 * c_cur = c_cur + 1
7346 */
7347 __pyx_t_1 = (((__pyx_v_c_cur[0]) != '\x00') != 0);
7348 if (unlikely(__pyx_t_1)) {
7349
7350 /* "breezy/bzr/_btree_serializer_pyx.pyx":709
7351 * c_cur = c_next + 1
7352 * if c_cur[0] != c'\0':
7353 * raise ValueError('only 1 null, not 2 as expected') # <<<<<<<<<<<<<<
7354 * c_cur = c_cur + 1
7355 * cur_record.block_offset = strtoull(c_cur, &c_next, 10)
7356 */
7357 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 709, __pyx_L1_error)
7358 __Pyx_GOTREF(__pyx_t_3);
7359 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7360 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7361 __PYX_ERR(0, 709, __pyx_L1_error)
7362
7363 /* "breezy/bzr/_btree_serializer_pyx.pyx":708
7364 * raise ValueError('We failed to unhexlify')
7365 * c_cur = c_next + 1
7366 * if c_cur[0] != c'\0': # <<<<<<<<<<<<<<
7367 * raise ValueError('only 1 null, not 2 as expected')
7368 * c_cur = c_cur + 1
7369 */
7370 }
7371
7372 /* "breezy/bzr/_btree_serializer_pyx.pyx":710
7373 * if c_cur[0] != c'\0':
7374 * raise ValueError('only 1 null, not 2 as expected')
7375 * c_cur = c_cur + 1 # <<<<<<<<<<<<<<
7376 * cur_record.block_offset = strtoull(c_cur, &c_next, 10)
7377 * if c_cur == c_next or c_next[0] != c' ':
7378 */
7379 __pyx_v_c_cur = (__pyx_v_c_cur + 1);
7380
7381 /* "breezy/bzr/_btree_serializer_pyx.pyx":711
7382 * raise ValueError('only 1 null, not 2 as expected')
7383 * c_cur = c_cur + 1
7384 * cur_record.block_offset = strtoull(c_cur, &c_next, 10) # <<<<<<<<<<<<<<
7385 * if c_cur == c_next or c_next[0] != c' ':
7386 * raise ValueError('Failed to parse block offset')
7387 */
7388 __pyx_v_cur_record->block_offset = strtoull(__pyx_v_c_cur, (&__pyx_v_c_next), 10);
7389
7390 /* "breezy/bzr/_btree_serializer_pyx.pyx":712
7391 * c_cur = c_cur + 1
7392 * cur_record.block_offset = strtoull(c_cur, &c_next, 10)
7393 * if c_cur == c_next or c_next[0] != c' ': # <<<<<<<<<<<<<<
7394 * raise ValueError('Failed to parse block offset')
7395 * c_cur = c_next + 1
7396 */
7397 __pyx_t_4 = ((__pyx_v_c_cur == __pyx_v_c_next) != 0);
7398 if (!__pyx_t_4) {
7399 } else {
7400 __pyx_t_1 = __pyx_t_4;
7401 goto __pyx_L10_bool_binop_done;
7402 }
7403 __pyx_t_4 = (((__pyx_v_c_next[0]) != ' ') != 0);
7404 __pyx_t_1 = __pyx_t_4;
7405 __pyx_L10_bool_binop_done:;
7406 if (unlikely(__pyx_t_1)) {
7407
7408 /* "breezy/bzr/_btree_serializer_pyx.pyx":713
7409 * cur_record.block_offset = strtoull(c_cur, &c_next, 10)
7410 * if c_cur == c_next or c_next[0] != c' ':
7411 * raise ValueError('Failed to parse block offset') # <<<<<<<<<<<<<<
7412 * c_cur = c_next + 1
7413 * cur_record.block_length = strtoul(c_cur, &c_next, 10)
7414 */
7415 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 713, __pyx_L1_error)
7416 __Pyx_GOTREF(__pyx_t_3);
7417 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7418 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7419 __PYX_ERR(0, 713, __pyx_L1_error)
7420
7421 /* "breezy/bzr/_btree_serializer_pyx.pyx":712
7422 * c_cur = c_cur + 1
7423 * cur_record.block_offset = strtoull(c_cur, &c_next, 10)
7424 * if c_cur == c_next or c_next[0] != c' ': # <<<<<<<<<<<<<<
7425 * raise ValueError('Failed to parse block offset')
7426 * c_cur = c_next + 1
7427 */
7428 }
7429
7430 /* "breezy/bzr/_btree_serializer_pyx.pyx":714
7431 * if c_cur == c_next or c_next[0] != c' ':
7432 * raise ValueError('Failed to parse block offset')
7433 * c_cur = c_next + 1 # <<<<<<<<<<<<<<
7434 * cur_record.block_length = strtoul(c_cur, &c_next, 10)
7435 * if c_cur == c_next or c_next[0] != c' ':
7436 */
7437 __pyx_v_c_cur = (__pyx_v_c_next + 1);
7438
7439 /* "breezy/bzr/_btree_serializer_pyx.pyx":715
7440 * raise ValueError('Failed to parse block offset')
7441 * c_cur = c_next + 1
7442 * cur_record.block_length = strtoul(c_cur, &c_next, 10) # <<<<<<<<<<<<<<
7443 * if c_cur == c_next or c_next[0] != c' ':
7444 * raise ValueError('Failed to parse block length')
7445 */
7446 __pyx_v_cur_record->block_length = strtoul(__pyx_v_c_cur, (&__pyx_v_c_next), 10);
7447
7448 /* "breezy/bzr/_btree_serializer_pyx.pyx":716
7449 * c_cur = c_next + 1
7450 * cur_record.block_length = strtoul(c_cur, &c_next, 10)
7451 * if c_cur == c_next or c_next[0] != c' ': # <<<<<<<<<<<<<<
7452 * raise ValueError('Failed to parse block length')
7453 * c_cur = c_next + 1
7454 */
7455 __pyx_t_4 = ((__pyx_v_c_cur == __pyx_v_c_next) != 0);
7456 if (!__pyx_t_4) {
7457 } else {
7458 __pyx_t_1 = __pyx_t_4;
7459 goto __pyx_L13_bool_binop_done;
7460 }
7461 __pyx_t_4 = (((__pyx_v_c_next[0]) != ' ') != 0);
7462 __pyx_t_1 = __pyx_t_4;
7463 __pyx_L13_bool_binop_done:;
7464 if (unlikely(__pyx_t_1)) {
7465
7466 /* "breezy/bzr/_btree_serializer_pyx.pyx":717
7467 * cur_record.block_length = strtoul(c_cur, &c_next, 10)
7468 * if c_cur == c_next or c_next[0] != c' ':
7469 * raise ValueError('Failed to parse block length') # <<<<<<<<<<<<<<
7470 * c_cur = c_next + 1
7471 * cur_record.record_start = strtoul(c_cur, &c_next, 10)
7472 */
7473 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 717, __pyx_L1_error)
7474 __Pyx_GOTREF(__pyx_t_3);
7475 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7476 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7477 __PYX_ERR(0, 717, __pyx_L1_error)
7478
7479 /* "breezy/bzr/_btree_serializer_pyx.pyx":716
7480 * c_cur = c_next + 1
7481 * cur_record.block_length = strtoul(c_cur, &c_next, 10)
7482 * if c_cur == c_next or c_next[0] != c' ': # <<<<<<<<<<<<<<
7483 * raise ValueError('Failed to parse block length')
7484 * c_cur = c_next + 1
7485 */
7486 }
7487
7488 /* "breezy/bzr/_btree_serializer_pyx.pyx":718
7489 * if c_cur == c_next or c_next[0] != c' ':
7490 * raise ValueError('Failed to parse block length')
7491 * c_cur = c_next + 1 # <<<<<<<<<<<<<<
7492 * cur_record.record_start = strtoul(c_cur, &c_next, 10)
7493 * if c_cur == c_next or c_next[0] != c' ':
7494 */
7495 __pyx_v_c_cur = (__pyx_v_c_next + 1);
7496
7497 /* "breezy/bzr/_btree_serializer_pyx.pyx":719
7498 * raise ValueError('Failed to parse block length')
7499 * c_cur = c_next + 1
7500 * cur_record.record_start = strtoul(c_cur, &c_next, 10) # <<<<<<<<<<<<<<
7501 * if c_cur == c_next or c_next[0] != c' ':
7502 * raise ValueError('Failed to parse block length')
7503 */
7504 __pyx_v_cur_record->record_start = strtoul(__pyx_v_c_cur, (&__pyx_v_c_next), 10);
7505
7506 /* "breezy/bzr/_btree_serializer_pyx.pyx":720
7507 * c_cur = c_next + 1
7508 * cur_record.record_start = strtoul(c_cur, &c_next, 10)
7509 * if c_cur == c_next or c_next[0] != c' ': # <<<<<<<<<<<<<<
7510 * raise ValueError('Failed to parse block length')
7511 * c_cur = c_next + 1
7512 */
7513 __pyx_t_4 = ((__pyx_v_c_cur == __pyx_v_c_next) != 0);
7514 if (!__pyx_t_4) {
7515 } else {
7516 __pyx_t_1 = __pyx_t_4;
7517 goto __pyx_L16_bool_binop_done;
7518 }
7519 __pyx_t_4 = (((__pyx_v_c_next[0]) != ' ') != 0);
7520 __pyx_t_1 = __pyx_t_4;
7521 __pyx_L16_bool_binop_done:;
7522 if (unlikely(__pyx_t_1)) {
7523
7524 /* "breezy/bzr/_btree_serializer_pyx.pyx":721
7525 * cur_record.record_start = strtoul(c_cur, &c_next, 10)
7526 * if c_cur == c_next or c_next[0] != c' ':
7527 * raise ValueError('Failed to parse block length') # <<<<<<<<<<<<<<
7528 * c_cur = c_next + 1
7529 * cur_record.record_end = strtoul(c_cur, &c_next, 10)
7530 */
7531 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 721, __pyx_L1_error)
7532 __Pyx_GOTREF(__pyx_t_3);
7533 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7534 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7535 __PYX_ERR(0, 721, __pyx_L1_error)
7536
7537 /* "breezy/bzr/_btree_serializer_pyx.pyx":720
7538 * c_cur = c_next + 1
7539 * cur_record.record_start = strtoul(c_cur, &c_next, 10)
7540 * if c_cur == c_next or c_next[0] != c' ': # <<<<<<<<<<<<<<
7541 * raise ValueError('Failed to parse block length')
7542 * c_cur = c_next + 1
7543 */
7544 }
7545
7546 /* "breezy/bzr/_btree_serializer_pyx.pyx":722
7547 * if c_cur == c_next or c_next[0] != c' ':
7548 * raise ValueError('Failed to parse block length')
7549 * c_cur = c_next + 1 # <<<<<<<<<<<<<<
7550 * cur_record.record_end = strtoul(c_cur, &c_next, 10)
7551 * if c_cur == c_next or c_next[0] != c'\n':
7552 */
7553 __pyx_v_c_cur = (__pyx_v_c_next + 1);
7554
7555 /* "breezy/bzr/_btree_serializer_pyx.pyx":723
7556 * raise ValueError('Failed to parse block length')
7557 * c_cur = c_next + 1
7558 * cur_record.record_end = strtoul(c_cur, &c_next, 10) # <<<<<<<<<<<<<<
7559 * if c_cur == c_next or c_next[0] != c'\n':
7560 * raise ValueError('Failed to parse record end')
7561 */
7562 __pyx_v_cur_record->record_end = strtoul(__pyx_v_c_cur, (&__pyx_v_c_next), 10);
7563
7564 /* "breezy/bzr/_btree_serializer_pyx.pyx":724
7565 * c_cur = c_next + 1
7566 * cur_record.record_end = strtoul(c_cur, &c_next, 10)
7567 * if c_cur == c_next or c_next[0] != c'\n': # <<<<<<<<<<<<<<
7568 * raise ValueError('Failed to parse record end')
7569 * c_cur = c_next + 1
7570 */
7571 __pyx_t_4 = ((__pyx_v_c_cur == __pyx_v_c_next) != 0);
7572 if (!__pyx_t_4) {
7573 } else {
7574 __pyx_t_1 = __pyx_t_4;
7575 goto __pyx_L19_bool_binop_done;
7576 }
7577 __pyx_t_4 = (((__pyx_v_c_next[0]) != '\n') != 0);
7578 __pyx_t_1 = __pyx_t_4;
7579 __pyx_L19_bool_binop_done:;
7580 if (unlikely(__pyx_t_1)) {
7581
7582 /* "breezy/bzr/_btree_serializer_pyx.pyx":725
7583 * cur_record.record_end = strtoul(c_cur, &c_next, 10)
7584 * if c_cur == c_next or c_next[0] != c'\n':
7585 * raise ValueError('Failed to parse record end') # <<<<<<<<<<<<<<
7586 * c_cur = c_next + 1
7587 * return c_cur
7588 */
7589 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 725, __pyx_L1_error)
7590 __Pyx_GOTREF(__pyx_t_3);
7591 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
7592 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7593 __PYX_ERR(0, 725, __pyx_L1_error)
7594
7595 /* "breezy/bzr/_btree_serializer_pyx.pyx":724
7596 * c_cur = c_next + 1
7597 * cur_record.record_end = strtoul(c_cur, &c_next, 10)
7598 * if c_cur == c_next or c_next[0] != c'\n': # <<<<<<<<<<<<<<
7599 * raise ValueError('Failed to parse record end')
7600 * c_cur = c_next + 1
7601 */
7602 }
7603
7604 /* "breezy/bzr/_btree_serializer_pyx.pyx":726
7605 * if c_cur == c_next or c_next[0] != c'\n':
7606 * raise ValueError('Failed to parse record end')
7607 * c_cur = c_next + 1 # <<<<<<<<<<<<<<
7608 * return c_cur
7609 *
7610 */
7611 __pyx_v_c_cur = (__pyx_v_c_next + 1);
7612
7613 /* "breezy/bzr/_btree_serializer_pyx.pyx":727
7614 * raise ValueError('Failed to parse record end')
7615 * c_cur = c_next + 1
7616 * return c_cur # <<<<<<<<<<<<<<
7617 *
7618 * cdef int _offset_for_sha1(self, char *sha1) except -1:
7619 */
7620 __pyx_r = __pyx_v_c_cur;
7621 goto __pyx_L0;
7622
7623 /* "breezy/bzr/_btree_serializer_pyx.pyx":690
7624 * self._compute_common()
7625 *
7626 * cdef char *_parse_one_entry(self, char *c_cur, char *c_end, # <<<<<<<<<<<<<<
7627 * gc_chk_sha1_record *cur_record) except NULL:
7628 * """Read a single sha record from the bytes.
7629 */
7630
7631 /* function exit code */
7632 __pyx_L1_error:;
7633 __Pyx_XDECREF(__pyx_t_2);
7634 __Pyx_XDECREF(__pyx_t_3);
7635 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode._parse_one_entry", __pyx_clineno, __pyx_lineno, __pyx_filename);
7636 __pyx_r = NULL;
7637 __pyx_L0:;
7638 __Pyx_RefNannyFinishContext();
7639 return __pyx_r;
7640 }
7641
7642 /* "breezy/bzr/_btree_serializer_pyx.pyx":729
7643 * return c_cur
7644 *
7645 * cdef int _offset_for_sha1(self, char *sha1) except -1: # <<<<<<<<<<<<<<
7646 * """Find the first interesting 8-bits of this sha1."""
7647 * cdef int this_offset
7648 */
7649
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__offset_for_sha1(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,char * __pyx_v_sha1)7650 static int __pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__offset_for_sha1(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, char *__pyx_v_sha1) {
7651 int __pyx_v_this_offset;
7652 unsigned int __pyx_v_as_uint;
7653 int __pyx_r;
7654 __Pyx_RefNannyDeclarations
7655 __Pyx_RefNannySetupContext("_offset_for_sha1", 0);
7656
7657 /* "breezy/bzr/_btree_serializer_pyx.pyx":733
7658 * cdef int this_offset
7659 * cdef unsigned int as_uint
7660 * as_uint = _sha1_to_uint(sha1) # <<<<<<<<<<<<<<
7661 * this_offset = (as_uint >> self.common_shift) & 0xFF
7662 * return this_offset
7663 */
7664 __pyx_v_as_uint = __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_uint(__pyx_v_sha1);
7665
7666 /* "breezy/bzr/_btree_serializer_pyx.pyx":734
7667 * cdef unsigned int as_uint
7668 * as_uint = _sha1_to_uint(sha1)
7669 * this_offset = (as_uint >> self.common_shift) & 0xFF # <<<<<<<<<<<<<<
7670 * return this_offset
7671 *
7672 */
7673 __pyx_v_this_offset = ((__pyx_v_as_uint >> __pyx_v_self->common_shift) & 0xFF);
7674
7675 /* "breezy/bzr/_btree_serializer_pyx.pyx":735
7676 * as_uint = _sha1_to_uint(sha1)
7677 * this_offset = (as_uint >> self.common_shift) & 0xFF
7678 * return this_offset # <<<<<<<<<<<<<<
7679 *
7680 * def _get_offset_for_sha1(self, sha1):
7681 */
7682 __pyx_r = __pyx_v_this_offset;
7683 goto __pyx_L0;
7684
7685 /* "breezy/bzr/_btree_serializer_pyx.pyx":729
7686 * return c_cur
7687 *
7688 * cdef int _offset_for_sha1(self, char *sha1) except -1: # <<<<<<<<<<<<<<
7689 * """Find the first interesting 8-bits of this sha1."""
7690 * cdef int this_offset
7691 */
7692
7693 /* function exit code */
7694 __pyx_L0:;
7695 __Pyx_RefNannyFinishContext();
7696 return __pyx_r;
7697 }
7698
7699 /* "breezy/bzr/_btree_serializer_pyx.pyx":737
7700 * return this_offset
7701 *
7702 * def _get_offset_for_sha1(self, sha1): # <<<<<<<<<<<<<<
7703 * return self._offset_for_sha1(PyBytes_AS_STRING(sha1))
7704 *
7705 */
7706
7707 /* Python wrapper */
7708 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_17_get_offset_for_sha1(PyObject *__pyx_v_self, PyObject *__pyx_v_sha1); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_17_get_offset_for_sha1(PyObject * __pyx_v_self,PyObject * __pyx_v_sha1)7709 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_17_get_offset_for_sha1(PyObject *__pyx_v_self, PyObject *__pyx_v_sha1) {
7710 PyObject *__pyx_r = 0;
7711 __Pyx_RefNannyDeclarations
7712 __Pyx_RefNannySetupContext("_get_offset_for_sha1 (wrapper)", 0);
7713 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_16_get_offset_for_sha1(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), ((PyObject *)__pyx_v_sha1));
7714
7715 /* function exit code */
7716 __Pyx_RefNannyFinishContext();
7717 return __pyx_r;
7718 }
7719
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_16_get_offset_for_sha1(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,PyObject * __pyx_v_sha1)7720 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_16_get_offset_for_sha1(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_sha1) {
7721 PyObject *__pyx_r = NULL;
7722 __Pyx_RefNannyDeclarations
7723 int __pyx_t_1;
7724 PyObject *__pyx_t_2 = NULL;
7725 int __pyx_lineno = 0;
7726 const char *__pyx_filename = NULL;
7727 int __pyx_clineno = 0;
7728 __Pyx_RefNannySetupContext("_get_offset_for_sha1", 0);
7729
7730 /* "breezy/bzr/_btree_serializer_pyx.pyx":738
7731 *
7732 * def _get_offset_for_sha1(self, sha1):
7733 * return self._offset_for_sha1(PyBytes_AS_STRING(sha1)) # <<<<<<<<<<<<<<
7734 *
7735 * cdef _compute_common(self):
7736 */
7737 __Pyx_XDECREF(__pyx_r);
7738 __pyx_t_1 = ((struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self->__pyx_vtab)->_offset_for_sha1(__pyx_v_self, PyBytes_AS_STRING(__pyx_v_sha1)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 738, __pyx_L1_error)
7739 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 738, __pyx_L1_error)
7740 __Pyx_GOTREF(__pyx_t_2);
7741 __pyx_r = __pyx_t_2;
7742 __pyx_t_2 = 0;
7743 goto __pyx_L0;
7744
7745 /* "breezy/bzr/_btree_serializer_pyx.pyx":737
7746 * return this_offset
7747 *
7748 * def _get_offset_for_sha1(self, sha1): # <<<<<<<<<<<<<<
7749 * return self._offset_for_sha1(PyBytes_AS_STRING(sha1))
7750 *
7751 */
7752
7753 /* function exit code */
7754 __pyx_L1_error:;
7755 __Pyx_XDECREF(__pyx_t_2);
7756 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode._get_offset_for_sha1", __pyx_clineno, __pyx_lineno, __pyx_filename);
7757 __pyx_r = NULL;
7758 __pyx_L0:;
7759 __Pyx_XGIVEREF(__pyx_r);
7760 __Pyx_RefNannyFinishContext();
7761 return __pyx_r;
7762 }
7763
7764 /* "breezy/bzr/_btree_serializer_pyx.pyx":740
7765 * return self._offset_for_sha1(PyBytes_AS_STRING(sha1))
7766 *
7767 * cdef _compute_common(self): # <<<<<<<<<<<<<<
7768 * cdef unsigned int first
7769 * cdef unsigned int this
7770 */
7771
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__compute_common(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)7772 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__compute_common(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
7773 unsigned int __pyx_v_first;
7774 unsigned int __pyx_v_this;
7775 unsigned int __pyx_v_common_mask;
7776 unsigned char __pyx_v_common_shift;
7777 int __pyx_v_i;
7778 int __pyx_v_offset;
7779 int __pyx_v_this_offset;
7780 int __pyx_v_max_offset;
7781 PyObject *__pyx_r = NULL;
7782 __Pyx_RefNannyDeclarations
7783 int __pyx_t_1;
7784 int __pyx_t_2;
7785 PyObject *__pyx_t_3 = NULL;
7786 PyObject *__pyx_t_4 = NULL;
7787 int __pyx_t_5;
7788 int __pyx_t_6;
7789 int __pyx_lineno = 0;
7790 const char *__pyx_filename = NULL;
7791 int __pyx_clineno = 0;
7792 __Pyx_RefNannySetupContext("_compute_common", 0);
7793
7794 /* "breezy/bzr/_btree_serializer_pyx.pyx":754
7795 * # By XORing the records together, we can determine what bits are set in
7796 * # all of them
7797 * if self.num_records < 2: # <<<<<<<<<<<<<<
7798 * # Everything is in common if you have 0 or 1 leaves
7799 * # So we'll always just shift to the first byte
7800 */
7801 __pyx_t_1 = ((__pyx_v_self->num_records < 2) != 0);
7802 if (__pyx_t_1) {
7803
7804 /* "breezy/bzr/_btree_serializer_pyx.pyx":757
7805 * # Everything is in common if you have 0 or 1 leaves
7806 * # So we'll always just shift to the first byte
7807 * self.common_shift = 24 # <<<<<<<<<<<<<<
7808 * else:
7809 * common_mask = 0xFFFFFFFF
7810 */
7811 __pyx_v_self->common_shift = 24;
7812
7813 /* "breezy/bzr/_btree_serializer_pyx.pyx":754
7814 * # By XORing the records together, we can determine what bits are set in
7815 * # all of them
7816 * if self.num_records < 2: # <<<<<<<<<<<<<<
7817 * # Everything is in common if you have 0 or 1 leaves
7818 * # So we'll always just shift to the first byte
7819 */
7820 goto __pyx_L3;
7821 }
7822
7823 /* "breezy/bzr/_btree_serializer_pyx.pyx":759
7824 * self.common_shift = 24
7825 * else:
7826 * common_mask = 0xFFFFFFFF # <<<<<<<<<<<<<<
7827 * first = _sha1_to_uint(self.records[0].sha1)
7828 * for i from 0 < i < self.num_records:
7829 */
7830 /*else*/ {
7831 __pyx_v_common_mask = 0xFFFFFFFF;
7832
7833 /* "breezy/bzr/_btree_serializer_pyx.pyx":760
7834 * else:
7835 * common_mask = 0xFFFFFFFF
7836 * first = _sha1_to_uint(self.records[0].sha1) # <<<<<<<<<<<<<<
7837 * for i from 0 < i < self.num_records:
7838 * this = _sha1_to_uint(self.records[i].sha1)
7839 */
7840 __pyx_v_first = __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_uint((__pyx_v_self->records[0]).sha1);
7841
7842 /* "breezy/bzr/_btree_serializer_pyx.pyx":761
7843 * common_mask = 0xFFFFFFFF
7844 * first = _sha1_to_uint(self.records[0].sha1)
7845 * for i from 0 < i < self.num_records: # <<<<<<<<<<<<<<
7846 * this = _sha1_to_uint(self.records[i].sha1)
7847 * common_mask = (~(first ^ this)) & common_mask
7848 */
7849 __pyx_t_2 = __pyx_v_self->num_records;
7850 for (__pyx_v_i = 0+1; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
7851
7852 /* "breezy/bzr/_btree_serializer_pyx.pyx":762
7853 * first = _sha1_to_uint(self.records[0].sha1)
7854 * for i from 0 < i < self.num_records:
7855 * this = _sha1_to_uint(self.records[i].sha1) # <<<<<<<<<<<<<<
7856 * common_mask = (~(first ^ this)) & common_mask
7857 * common_shift = 24
7858 */
7859 __pyx_v_this = __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__sha1_to_uint((__pyx_v_self->records[__pyx_v_i]).sha1);
7860
7861 /* "breezy/bzr/_btree_serializer_pyx.pyx":763
7862 * for i from 0 < i < self.num_records:
7863 * this = _sha1_to_uint(self.records[i].sha1)
7864 * common_mask = (~(first ^ this)) & common_mask # <<<<<<<<<<<<<<
7865 * common_shift = 24
7866 * while common_mask & 0x80000000 and common_shift > 0:
7867 */
7868 __pyx_v_common_mask = ((~(__pyx_v_first ^ __pyx_v_this)) & __pyx_v_common_mask);
7869 }
7870
7871 /* "breezy/bzr/_btree_serializer_pyx.pyx":764
7872 * this = _sha1_to_uint(self.records[i].sha1)
7873 * common_mask = (~(first ^ this)) & common_mask
7874 * common_shift = 24 # <<<<<<<<<<<<<<
7875 * while common_mask & 0x80000000 and common_shift > 0:
7876 * common_mask = common_mask << 1
7877 */
7878 __pyx_v_common_shift = 24;
7879
7880 /* "breezy/bzr/_btree_serializer_pyx.pyx":765
7881 * common_mask = (~(first ^ this)) & common_mask
7882 * common_shift = 24
7883 * while common_mask & 0x80000000 and common_shift > 0: # <<<<<<<<<<<<<<
7884 * common_mask = common_mask << 1
7885 * common_shift = common_shift - 1
7886 */
7887 while (1) {
7888 __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_common_mask); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 765, __pyx_L1_error)
7889 __Pyx_GOTREF(__pyx_t_3);
7890 __pyx_t_4 = PyNumber_And(__pyx_t_3, __pyx_int_2147483648); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 765, __pyx_L1_error)
7891 __Pyx_GOTREF(__pyx_t_4);
7892 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7893 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 765, __pyx_L1_error)
7894 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7895 if (__pyx_t_5) {
7896 } else {
7897 __pyx_t_1 = __pyx_t_5;
7898 goto __pyx_L8_bool_binop_done;
7899 }
7900 __pyx_t_5 = ((__pyx_v_common_shift > 0) != 0);
7901 __pyx_t_1 = __pyx_t_5;
7902 __pyx_L8_bool_binop_done:;
7903 if (!__pyx_t_1) break;
7904
7905 /* "breezy/bzr/_btree_serializer_pyx.pyx":766
7906 * common_shift = 24
7907 * while common_mask & 0x80000000 and common_shift > 0:
7908 * common_mask = common_mask << 1 # <<<<<<<<<<<<<<
7909 * common_shift = common_shift - 1
7910 * self.common_shift = common_shift
7911 */
7912 __pyx_v_common_mask = (__pyx_v_common_mask << 1);
7913
7914 /* "breezy/bzr/_btree_serializer_pyx.pyx":767
7915 * while common_mask & 0x80000000 and common_shift > 0:
7916 * common_mask = common_mask << 1
7917 * common_shift = common_shift - 1 # <<<<<<<<<<<<<<
7918 * self.common_shift = common_shift
7919 * offset = 0
7920 */
7921 __pyx_v_common_shift = (__pyx_v_common_shift - 1);
7922 }
7923
7924 /* "breezy/bzr/_btree_serializer_pyx.pyx":768
7925 * common_mask = common_mask << 1
7926 * common_shift = common_shift - 1
7927 * self.common_shift = common_shift # <<<<<<<<<<<<<<
7928 * offset = 0
7929 * max_offset = self.num_records
7930 */
7931 __pyx_v_self->common_shift = __pyx_v_common_shift;
7932 }
7933 __pyx_L3:;
7934
7935 /* "breezy/bzr/_btree_serializer_pyx.pyx":769
7936 * common_shift = common_shift - 1
7937 * self.common_shift = common_shift
7938 * offset = 0 # <<<<<<<<<<<<<<
7939 * max_offset = self.num_records
7940 * # We cap this loop at 254 records. All the other offsets just get
7941 */
7942 __pyx_v_offset = 0;
7943
7944 /* "breezy/bzr/_btree_serializer_pyx.pyx":770
7945 * self.common_shift = common_shift
7946 * offset = 0
7947 * max_offset = self.num_records # <<<<<<<<<<<<<<
7948 * # We cap this loop at 254 records. All the other offsets just get
7949 * # filled with 0xff as the singleton saying 'too many'.
7950 */
7951 __pyx_t_2 = __pyx_v_self->num_records;
7952 __pyx_v_max_offset = __pyx_t_2;
7953
7954 /* "breezy/bzr/_btree_serializer_pyx.pyx":775
7955 * # It means that if we have >255 records we have to bisect the second
7956 * # half of the list, but this is going to be very rare in practice.
7957 * if max_offset > 255: # <<<<<<<<<<<<<<
7958 * max_offset = 255
7959 * for i from 0 <= i < max_offset:
7960 */
7961 __pyx_t_1 = ((__pyx_v_max_offset > 0xFF) != 0);
7962 if (__pyx_t_1) {
7963
7964 /* "breezy/bzr/_btree_serializer_pyx.pyx":776
7965 * # half of the list, but this is going to be very rare in practice.
7966 * if max_offset > 255:
7967 * max_offset = 255 # <<<<<<<<<<<<<<
7968 * for i from 0 <= i < max_offset:
7969 * this_offset = self._offset_for_sha1(self.records[i].sha1)
7970 */
7971 __pyx_v_max_offset = 0xFF;
7972
7973 /* "breezy/bzr/_btree_serializer_pyx.pyx":775
7974 * # It means that if we have >255 records we have to bisect the second
7975 * # half of the list, but this is going to be very rare in practice.
7976 * if max_offset > 255: # <<<<<<<<<<<<<<
7977 * max_offset = 255
7978 * for i from 0 <= i < max_offset:
7979 */
7980 }
7981
7982 /* "breezy/bzr/_btree_serializer_pyx.pyx":777
7983 * if max_offset > 255:
7984 * max_offset = 255
7985 * for i from 0 <= i < max_offset: # <<<<<<<<<<<<<<
7986 * this_offset = self._offset_for_sha1(self.records[i].sha1)
7987 * while offset <= this_offset:
7988 */
7989 __pyx_t_2 = __pyx_v_max_offset;
7990 for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {
7991
7992 /* "breezy/bzr/_btree_serializer_pyx.pyx":778
7993 * max_offset = 255
7994 * for i from 0 <= i < max_offset:
7995 * this_offset = self._offset_for_sha1(self.records[i].sha1) # <<<<<<<<<<<<<<
7996 * while offset <= this_offset:
7997 * self.offsets[offset] = i
7998 */
7999 __pyx_t_6 = ((struct __pyx_vtabstruct_6breezy_3bzr_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_6 == ((int)-1))) __PYX_ERR(0, 778, __pyx_L1_error)
8000 __pyx_v_this_offset = __pyx_t_6;
8001
8002 /* "breezy/bzr/_btree_serializer_pyx.pyx":779
8003 * for i from 0 <= i < max_offset:
8004 * this_offset = self._offset_for_sha1(self.records[i].sha1)
8005 * while offset <= this_offset: # <<<<<<<<<<<<<<
8006 * self.offsets[offset] = i
8007 * offset = offset + 1
8008 */
8009 while (1) {
8010 __pyx_t_1 = ((__pyx_v_offset <= __pyx_v_this_offset) != 0);
8011 if (!__pyx_t_1) break;
8012
8013 /* "breezy/bzr/_btree_serializer_pyx.pyx":780
8014 * this_offset = self._offset_for_sha1(self.records[i].sha1)
8015 * while offset <= this_offset:
8016 * self.offsets[offset] = i # <<<<<<<<<<<<<<
8017 * offset = offset + 1
8018 * while offset < 257:
8019 */
8020 (__pyx_v_self->offsets[__pyx_v_offset]) = __pyx_v_i;
8021
8022 /* "breezy/bzr/_btree_serializer_pyx.pyx":781
8023 * while offset <= this_offset:
8024 * self.offsets[offset] = i
8025 * offset = offset + 1 # <<<<<<<<<<<<<<
8026 * while offset < 257:
8027 * self.offsets[offset] = max_offset
8028 */
8029 __pyx_v_offset = (__pyx_v_offset + 1);
8030 }
8031 }
8032
8033 /* "breezy/bzr/_btree_serializer_pyx.pyx":782
8034 * self.offsets[offset] = i
8035 * offset = offset + 1
8036 * while offset < 257: # <<<<<<<<<<<<<<
8037 * self.offsets[offset] = max_offset
8038 * offset = offset + 1
8039 */
8040 while (1) {
8041 __pyx_t_1 = ((__pyx_v_offset < 0x101) != 0);
8042 if (!__pyx_t_1) break;
8043
8044 /* "breezy/bzr/_btree_serializer_pyx.pyx":783
8045 * offset = offset + 1
8046 * while offset < 257:
8047 * self.offsets[offset] = max_offset # <<<<<<<<<<<<<<
8048 * offset = offset + 1
8049 *
8050 */
8051 (__pyx_v_self->offsets[__pyx_v_offset]) = __pyx_v_max_offset;
8052
8053 /* "breezy/bzr/_btree_serializer_pyx.pyx":784
8054 * while offset < 257:
8055 * self.offsets[offset] = max_offset
8056 * offset = offset + 1 # <<<<<<<<<<<<<<
8057 *
8058 * def _get_offsets(self):
8059 */
8060 __pyx_v_offset = (__pyx_v_offset + 1);
8061 }
8062
8063 /* "breezy/bzr/_btree_serializer_pyx.pyx":740
8064 * return self._offset_for_sha1(PyBytes_AS_STRING(sha1))
8065 *
8066 * cdef _compute_common(self): # <<<<<<<<<<<<<<
8067 * cdef unsigned int first
8068 * cdef unsigned int this
8069 */
8070
8071 /* function exit code */
8072 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8073 goto __pyx_L0;
8074 __pyx_L1_error:;
8075 __Pyx_XDECREF(__pyx_t_3);
8076 __Pyx_XDECREF(__pyx_t_4);
8077 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode._compute_common", __pyx_clineno, __pyx_lineno, __pyx_filename);
8078 __pyx_r = 0;
8079 __pyx_L0:;
8080 __Pyx_XGIVEREF(__pyx_r);
8081 __Pyx_RefNannyFinishContext();
8082 return __pyx_r;
8083 }
8084
8085 /* "breezy/bzr/_btree_serializer_pyx.pyx":786
8086 * offset = offset + 1
8087 *
8088 * def _get_offsets(self): # <<<<<<<<<<<<<<
8089 * cdef int i
8090 * result = []
8091 */
8092
8093 /* Python wrapper */
8094 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_19_get_offsets(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_19_get_offsets(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)8095 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_19_get_offsets(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
8096 PyObject *__pyx_r = 0;
8097 __Pyx_RefNannyDeclarations
8098 __Pyx_RefNannySetupContext("_get_offsets (wrapper)", 0);
8099 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_18_get_offsets(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
8100
8101 /* function exit code */
8102 __Pyx_RefNannyFinishContext();
8103 return __pyx_r;
8104 }
8105
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_18_get_offsets(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)8106 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_18_get_offsets(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
8107 int __pyx_v_i;
8108 PyObject *__pyx_v_result = NULL;
8109 PyObject *__pyx_r = NULL;
8110 __Pyx_RefNannyDeclarations
8111 PyObject *__pyx_t_1 = NULL;
8112 int __pyx_t_2;
8113 int __pyx_lineno = 0;
8114 const char *__pyx_filename = NULL;
8115 int __pyx_clineno = 0;
8116 __Pyx_RefNannySetupContext("_get_offsets", 0);
8117
8118 /* "breezy/bzr/_btree_serializer_pyx.pyx":788
8119 * def _get_offsets(self):
8120 * cdef int i
8121 * result = [] # <<<<<<<<<<<<<<
8122 * for i from 0 <= i < 257:
8123 * PyList_Append(result, self.offsets[i])
8124 */
8125 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 788, __pyx_L1_error)
8126 __Pyx_GOTREF(__pyx_t_1);
8127 __pyx_v_result = ((PyObject*)__pyx_t_1);
8128 __pyx_t_1 = 0;
8129
8130 /* "breezy/bzr/_btree_serializer_pyx.pyx":789
8131 * cdef int i
8132 * result = []
8133 * for i from 0 <= i < 257: # <<<<<<<<<<<<<<
8134 * PyList_Append(result, self.offsets[i])
8135 * return result
8136 */
8137 for (__pyx_v_i = 0; __pyx_v_i < 0x101; __pyx_v_i++) {
8138
8139 /* "breezy/bzr/_btree_serializer_pyx.pyx":790
8140 * result = []
8141 * for i from 0 <= i < 257:
8142 * PyList_Append(result, self.offsets[i]) # <<<<<<<<<<<<<<
8143 * return result
8144 *
8145 */
8146 __pyx_t_1 = __Pyx_PyInt_From_unsigned_char((__pyx_v_self->offsets[__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 790, __pyx_L1_error)
8147 __Pyx_GOTREF(__pyx_t_1);
8148 __pyx_t_2 = PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 790, __pyx_L1_error)
8149 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8150 }
8151
8152 /* "breezy/bzr/_btree_serializer_pyx.pyx":791
8153 * for i from 0 <= i < 257:
8154 * PyList_Append(result, self.offsets[i])
8155 * return result # <<<<<<<<<<<<<<
8156 *
8157 *
8158 */
8159 __Pyx_XDECREF(__pyx_r);
8160 __Pyx_INCREF(__pyx_v_result);
8161 __pyx_r = __pyx_v_result;
8162 goto __pyx_L0;
8163
8164 /* "breezy/bzr/_btree_serializer_pyx.pyx":786
8165 * offset = offset + 1
8166 *
8167 * def _get_offsets(self): # <<<<<<<<<<<<<<
8168 * cdef int i
8169 * result = []
8170 */
8171
8172 /* function exit code */
8173 __pyx_L1_error:;
8174 __Pyx_XDECREF(__pyx_t_1);
8175 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode._get_offsets", __pyx_clineno, __pyx_lineno, __pyx_filename);
8176 __pyx_r = NULL;
8177 __pyx_L0:;
8178 __Pyx_XDECREF(__pyx_v_result);
8179 __Pyx_XGIVEREF(__pyx_r);
8180 __Pyx_RefNannyFinishContext();
8181 return __pyx_r;
8182 }
8183
8184 /* "breezy/bzr/_btree_serializer_pyx.pyx":488
8185 *
8186 * cdef gc_chk_sha1_record *records
8187 * cdef public object last_key # <<<<<<<<<<<<<<
8188 * cdef gc_chk_sha1_record *last_record
8189 * cdef public int num_records
8190 */
8191
8192 /* Python wrapper */
8193 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_1__get__(PyObject * __pyx_v_self)8194 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_1__get__(PyObject *__pyx_v_self) {
8195 PyObject *__pyx_r = 0;
8196 __Pyx_RefNannyDeclarations
8197 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
8198 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key___get__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
8199
8200 /* function exit code */
8201 __Pyx_RefNannyFinishContext();
8202 return __pyx_r;
8203 }
8204
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)8205 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
8206 PyObject *__pyx_r = NULL;
8207 __Pyx_RefNannyDeclarations
8208 __Pyx_RefNannySetupContext("__get__", 0);
8209 __Pyx_XDECREF(__pyx_r);
8210 __Pyx_INCREF(__pyx_v_self->last_key);
8211 __pyx_r = __pyx_v_self->last_key;
8212 goto __pyx_L0;
8213
8214 /* function exit code */
8215 __pyx_L0:;
8216 __Pyx_XGIVEREF(__pyx_r);
8217 __Pyx_RefNannyFinishContext();
8218 return __pyx_r;
8219 }
8220
8221 /* Python wrapper */
8222 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_3__set__(PyObject * __pyx_v_self,PyObject * __pyx_v_value)8223 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
8224 int __pyx_r;
8225 __Pyx_RefNannyDeclarations
8226 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
8227 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_2__set__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), ((PyObject *)__pyx_v_value));
8228
8229 /* function exit code */
8230 __Pyx_RefNannyFinishContext();
8231 return __pyx_r;
8232 }
8233
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_2__set__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,PyObject * __pyx_v_value)8234 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_2__set__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_value) {
8235 int __pyx_r;
8236 __Pyx_RefNannyDeclarations
8237 __Pyx_RefNannySetupContext("__set__", 0);
8238 __Pyx_INCREF(__pyx_v_value);
8239 __Pyx_GIVEREF(__pyx_v_value);
8240 __Pyx_GOTREF(__pyx_v_self->last_key);
8241 __Pyx_DECREF(__pyx_v_self->last_key);
8242 __pyx_v_self->last_key = __pyx_v_value;
8243
8244 /* function exit code */
8245 __pyx_r = 0;
8246 __Pyx_RefNannyFinishContext();
8247 return __pyx_r;
8248 }
8249
8250 /* Python wrapper */
8251 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_5__del__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_5__del__(PyObject * __pyx_v_self)8252 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_5__del__(PyObject *__pyx_v_self) {
8253 int __pyx_r;
8254 __Pyx_RefNannyDeclarations
8255 __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
8256 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_4__del__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
8257
8258 /* function exit code */
8259 __Pyx_RefNannyFinishContext();
8260 return __pyx_r;
8261 }
8262
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_4__del__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)8263 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_4__del__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
8264 int __pyx_r;
8265 __Pyx_RefNannyDeclarations
8266 __Pyx_RefNannySetupContext("__del__", 0);
8267 __Pyx_INCREF(Py_None);
8268 __Pyx_GIVEREF(Py_None);
8269 __Pyx_GOTREF(__pyx_v_self->last_key);
8270 __Pyx_DECREF(__pyx_v_self->last_key);
8271 __pyx_v_self->last_key = Py_None;
8272
8273 /* function exit code */
8274 __pyx_r = 0;
8275 __Pyx_RefNannyFinishContext();
8276 return __pyx_r;
8277 }
8278
8279 /* "breezy/bzr/_btree_serializer_pyx.pyx":490
8280 * cdef public object last_key
8281 * cdef gc_chk_sha1_record *last_record
8282 * cdef public int num_records # <<<<<<<<<<<<<<
8283 * # This is the number of bits to shift to get to the interesting byte. A
8284 * # value of 24 means that the very first byte changes across all keys.
8285 */
8286
8287 /* Python wrapper */
8288 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_1__get__(PyObject * __pyx_v_self)8289 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_1__get__(PyObject *__pyx_v_self) {
8290 PyObject *__pyx_r = 0;
8291 __Pyx_RefNannyDeclarations
8292 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
8293 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records___get__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
8294
8295 /* function exit code */
8296 __Pyx_RefNannyFinishContext();
8297 return __pyx_r;
8298 }
8299
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)8300 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
8301 PyObject *__pyx_r = NULL;
8302 __Pyx_RefNannyDeclarations
8303 PyObject *__pyx_t_1 = NULL;
8304 int __pyx_lineno = 0;
8305 const char *__pyx_filename = NULL;
8306 int __pyx_clineno = 0;
8307 __Pyx_RefNannySetupContext("__get__", 0);
8308 __Pyx_XDECREF(__pyx_r);
8309 __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->num_records); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __pyx_L1_error)
8310 __Pyx_GOTREF(__pyx_t_1);
8311 __pyx_r = __pyx_t_1;
8312 __pyx_t_1 = 0;
8313 goto __pyx_L0;
8314
8315 /* function exit code */
8316 __pyx_L1_error:;
8317 __Pyx_XDECREF(__pyx_t_1);
8318 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.num_records.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8319 __pyx_r = NULL;
8320 __pyx_L0:;
8321 __Pyx_XGIVEREF(__pyx_r);
8322 __Pyx_RefNannyFinishContext();
8323 return __pyx_r;
8324 }
8325
8326 /* Python wrapper */
8327 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_3__set__(PyObject * __pyx_v_self,PyObject * __pyx_v_value)8328 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
8329 int __pyx_r;
8330 __Pyx_RefNannyDeclarations
8331 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
8332 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_2__set__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), ((PyObject *)__pyx_v_value));
8333
8334 /* function exit code */
8335 __Pyx_RefNannyFinishContext();
8336 return __pyx_r;
8337 }
8338
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_2__set__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,PyObject * __pyx_v_value)8339 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_2__set__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_value) {
8340 int __pyx_r;
8341 __Pyx_RefNannyDeclarations
8342 int __pyx_t_1;
8343 int __pyx_lineno = 0;
8344 const char *__pyx_filename = NULL;
8345 int __pyx_clineno = 0;
8346 __Pyx_RefNannySetupContext("__set__", 0);
8347 __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 490, __pyx_L1_error)
8348 __pyx_v_self->num_records = __pyx_t_1;
8349
8350 /* function exit code */
8351 __pyx_r = 0;
8352 goto __pyx_L0;
8353 __pyx_L1_error:;
8354 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.num_records.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8355 __pyx_r = -1;
8356 __pyx_L0:;
8357 __Pyx_RefNannyFinishContext();
8358 return __pyx_r;
8359 }
8360
8361 /* "breezy/bzr/_btree_serializer_pyx.pyx":496
8362 * # ignore. 0 means that at least the first 3 bytes are identical, though
8363 * # that is going to be very rare
8364 * cdef public unsigned char common_shift # <<<<<<<<<<<<<<
8365 * # This maps an interesting byte to the first record that matches.
8366 * # Equivalent to bisect.bisect_left(self.records, sha1), though only taking
8367 */
8368
8369 /* Python wrapper */
8370 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_1__get__(PyObject * __pyx_v_self)8371 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_1__get__(PyObject *__pyx_v_self) {
8372 PyObject *__pyx_r = 0;
8373 __Pyx_RefNannyDeclarations
8374 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
8375 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift___get__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
8376
8377 /* function exit code */
8378 __Pyx_RefNannyFinishContext();
8379 return __pyx_r;
8380 }
8381
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)8382 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift___get__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
8383 PyObject *__pyx_r = NULL;
8384 __Pyx_RefNannyDeclarations
8385 PyObject *__pyx_t_1 = NULL;
8386 int __pyx_lineno = 0;
8387 const char *__pyx_filename = NULL;
8388 int __pyx_clineno = 0;
8389 __Pyx_RefNannySetupContext("__get__", 0);
8390 __Pyx_XDECREF(__pyx_r);
8391 __pyx_t_1 = __Pyx_PyInt_From_unsigned_char(__pyx_v_self->common_shift); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error)
8392 __Pyx_GOTREF(__pyx_t_1);
8393 __pyx_r = __pyx_t_1;
8394 __pyx_t_1 = 0;
8395 goto __pyx_L0;
8396
8397 /* function exit code */
8398 __pyx_L1_error:;
8399 __Pyx_XDECREF(__pyx_t_1);
8400 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.common_shift.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8401 __pyx_r = NULL;
8402 __pyx_L0:;
8403 __Pyx_XGIVEREF(__pyx_r);
8404 __Pyx_RefNannyFinishContext();
8405 return __pyx_r;
8406 }
8407
8408 /* Python wrapper */
8409 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_3__set__(PyObject * __pyx_v_self,PyObject * __pyx_v_value)8410 static int __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
8411 int __pyx_r;
8412 __Pyx_RefNannyDeclarations
8413 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
8414 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_2__set__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), ((PyObject *)__pyx_v_value));
8415
8416 /* function exit code */
8417 __Pyx_RefNannyFinishContext();
8418 return __pyx_r;
8419 }
8420
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_2__set__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,PyObject * __pyx_v_value)8421 static int __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_2__set__(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, PyObject *__pyx_v_value) {
8422 int __pyx_r;
8423 __Pyx_RefNannyDeclarations
8424 unsigned char __pyx_t_1;
8425 int __pyx_lineno = 0;
8426 const char *__pyx_filename = NULL;
8427 int __pyx_clineno = 0;
8428 __Pyx_RefNannySetupContext("__set__", 0);
8429 __pyx_t_1 = __Pyx_PyInt_As_unsigned_char(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 496, __pyx_L1_error)
8430 __pyx_v_self->common_shift = __pyx_t_1;
8431
8432 /* function exit code */
8433 __pyx_r = 0;
8434 goto __pyx_L0;
8435 __pyx_L1_error:;
8436 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.common_shift.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8437 __pyx_r = -1;
8438 __pyx_L0:;
8439 __Pyx_RefNannyFinishContext();
8440 return __pyx_r;
8441 }
8442
8443 /* "(tree fragment)":1
8444 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
8445 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
8446 * def __setstate_cython__(self, __pyx_state):
8447 */
8448
8449 /* Python wrapper */
8450 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_21__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)8451 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
8452 PyObject *__pyx_r = 0;
8453 __Pyx_RefNannyDeclarations
8454 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
8455 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_20__reduce_cython__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self));
8456
8457 /* function exit code */
8458 __Pyx_RefNannyFinishContext();
8459 return __pyx_r;
8460 }
8461
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self)8462 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self) {
8463 PyObject *__pyx_r = NULL;
8464 __Pyx_RefNannyDeclarations
8465 PyObject *__pyx_t_1 = NULL;
8466 int __pyx_lineno = 0;
8467 const char *__pyx_filename = NULL;
8468 int __pyx_clineno = 0;
8469 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
8470
8471 /* "(tree fragment)":2
8472 * def __reduce_cython__(self):
8473 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
8474 * def __setstate_cython__(self, __pyx_state):
8475 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
8476 */
8477 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
8478 __Pyx_GOTREF(__pyx_t_1);
8479 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
8480 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8481 __PYX_ERR(1, 2, __pyx_L1_error)
8482
8483 /* "(tree fragment)":1
8484 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
8485 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
8486 * def __setstate_cython__(self, __pyx_state):
8487 */
8488
8489 /* function exit code */
8490 __pyx_L1_error:;
8491 __Pyx_XDECREF(__pyx_t_1);
8492 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8493 __pyx_r = NULL;
8494 __Pyx_XGIVEREF(__pyx_r);
8495 __Pyx_RefNannyFinishContext();
8496 return __pyx_r;
8497 }
8498
8499 /* "(tree fragment)":3
8500 * def __reduce_cython__(self):
8501 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
8502 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
8503 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
8504 */
8505
8506 /* Python wrapper */
8507 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_23__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)8508 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
8509 PyObject *__pyx_r = 0;
8510 __Pyx_RefNannyDeclarations
8511 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
8512 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_22__setstate_cython__(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
8513
8514 /* function exit code */
8515 __Pyx_RefNannyFinishContext();
8516 return __pyx_r;
8517 }
8518
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)8519 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
8520 PyObject *__pyx_r = NULL;
8521 __Pyx_RefNannyDeclarations
8522 PyObject *__pyx_t_1 = NULL;
8523 int __pyx_lineno = 0;
8524 const char *__pyx_filename = NULL;
8525 int __pyx_clineno = 0;
8526 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
8527
8528 /* "(tree fragment)":4
8529 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
8530 * def __setstate_cython__(self, __pyx_state):
8531 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
8532 */
8533 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
8534 __Pyx_GOTREF(__pyx_t_1);
8535 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
8536 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8537 __PYX_ERR(1, 4, __pyx_L1_error)
8538
8539 /* "(tree fragment)":3
8540 * def __reduce_cython__(self):
8541 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
8542 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
8543 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
8544 */
8545
8546 /* function exit code */
8547 __pyx_L1_error:;
8548 __Pyx_XDECREF(__pyx_t_1);
8549 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8550 __pyx_r = NULL;
8551 __Pyx_XGIVEREF(__pyx_r);
8552 __Pyx_RefNannyFinishContext();
8553 return __pyx_r;
8554 }
8555
8556 /* "breezy/bzr/_btree_serializer_pyx.pyx":794
8557 *
8558 *
8559 * def _parse_into_chk(bytes, key_length, ref_list_length): # <<<<<<<<<<<<<<
8560 * """Parse into a format optimized for chk records."""
8561 * assert key_length == 1
8562 */
8563
8564 /* Python wrapper */
8565 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_11_parse_into_chk(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8566 static char __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_10_parse_into_chk[] = "Parse into a format optimized for chk records.";
8567 static PyMethodDef __pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_11_parse_into_chk = {"_parse_into_chk", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_11_parse_into_chk, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_10_parse_into_chk};
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_11_parse_into_chk(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)8568 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_11_parse_into_chk(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8569 PyObject *__pyx_v_bytes = 0;
8570 PyObject *__pyx_v_key_length = 0;
8571 PyObject *__pyx_v_ref_list_length = 0;
8572 int __pyx_lineno = 0;
8573 const char *__pyx_filename = NULL;
8574 int __pyx_clineno = 0;
8575 PyObject *__pyx_r = 0;
8576 __Pyx_RefNannyDeclarations
8577 __Pyx_RefNannySetupContext("_parse_into_chk (wrapper)", 0);
8578 {
8579 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bytes,&__pyx_n_s_key_length,&__pyx_n_s_ref_list_length,0};
8580 PyObject* values[3] = {0,0,0};
8581 if (unlikely(__pyx_kwds)) {
8582 Py_ssize_t kw_args;
8583 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8584 switch (pos_args) {
8585 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8586 CYTHON_FALLTHROUGH;
8587 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8588 CYTHON_FALLTHROUGH;
8589 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8590 CYTHON_FALLTHROUGH;
8591 case 0: break;
8592 default: goto __pyx_L5_argtuple_error;
8593 }
8594 kw_args = PyDict_Size(__pyx_kwds);
8595 switch (pos_args) {
8596 case 0:
8597 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bytes)) != 0)) kw_args--;
8598 else goto __pyx_L5_argtuple_error;
8599 CYTHON_FALLTHROUGH;
8600 case 1:
8601 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key_length)) != 0)) kw_args--;
8602 else {
8603 __Pyx_RaiseArgtupleInvalid("_parse_into_chk", 1, 3, 3, 1); __PYX_ERR(0, 794, __pyx_L3_error)
8604 }
8605 CYTHON_FALLTHROUGH;
8606 case 2:
8607 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ref_list_length)) != 0)) kw_args--;
8608 else {
8609 __Pyx_RaiseArgtupleInvalid("_parse_into_chk", 1, 3, 3, 2); __PYX_ERR(0, 794, __pyx_L3_error)
8610 }
8611 }
8612 if (unlikely(kw_args > 0)) {
8613 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse_into_chk") < 0)) __PYX_ERR(0, 794, __pyx_L3_error)
8614 }
8615 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
8616 goto __pyx_L5_argtuple_error;
8617 } else {
8618 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8619 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8620 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8621 }
8622 __pyx_v_bytes = values[0];
8623 __pyx_v_key_length = values[1];
8624 __pyx_v_ref_list_length = values[2];
8625 }
8626 goto __pyx_L4_argument_unpacking_done;
8627 __pyx_L5_argtuple_error:;
8628 __Pyx_RaiseArgtupleInvalid("_parse_into_chk", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 794, __pyx_L3_error)
8629 __pyx_L3_error:;
8630 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._parse_into_chk", __pyx_clineno, __pyx_lineno, __pyx_filename);
8631 __Pyx_RefNannyFinishContext();
8632 return NULL;
8633 __pyx_L4_argument_unpacking_done:;
8634 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_10_parse_into_chk(__pyx_self, __pyx_v_bytes, __pyx_v_key_length, __pyx_v_ref_list_length);
8635
8636 /* function exit code */
8637 __Pyx_RefNannyFinishContext();
8638 return __pyx_r;
8639 }
8640
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_10_parse_into_chk(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_bytes,PyObject * __pyx_v_key_length,PyObject * __pyx_v_ref_list_length)8641 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_10_parse_into_chk(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_bytes, PyObject *__pyx_v_key_length, PyObject *__pyx_v_ref_list_length) {
8642 PyObject *__pyx_r = NULL;
8643 __Pyx_RefNannyDeclarations
8644 PyObject *__pyx_t_1 = NULL;
8645 int __pyx_t_2;
8646 int __pyx_lineno = 0;
8647 const char *__pyx_filename = NULL;
8648 int __pyx_clineno = 0;
8649 __Pyx_RefNannySetupContext("_parse_into_chk", 0);
8650
8651 /* "breezy/bzr/_btree_serializer_pyx.pyx":796
8652 * def _parse_into_chk(bytes, key_length, ref_list_length):
8653 * """Parse into a format optimized for chk records."""
8654 * assert key_length == 1 # <<<<<<<<<<<<<<
8655 * assert ref_list_length == 0
8656 * return GCCHKSHA1LeafNode(bytes)
8657 */
8658 #ifndef CYTHON_WITHOUT_ASSERTIONS
8659 if (unlikely(!Py_OptimizeFlag)) {
8660 __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_key_length, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 796, __pyx_L1_error)
8661 __Pyx_GOTREF(__pyx_t_1);
8662 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 796, __pyx_L1_error)
8663 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8664 if (unlikely(!__pyx_t_2)) {
8665 PyErr_SetNone(PyExc_AssertionError);
8666 __PYX_ERR(0, 796, __pyx_L1_error)
8667 }
8668 }
8669 #endif
8670
8671 /* "breezy/bzr/_btree_serializer_pyx.pyx":797
8672 * """Parse into a format optimized for chk records."""
8673 * assert key_length == 1
8674 * assert ref_list_length == 0 # <<<<<<<<<<<<<<
8675 * return GCCHKSHA1LeafNode(bytes)
8676 *
8677 */
8678 #ifndef CYTHON_WITHOUT_ASSERTIONS
8679 if (unlikely(!Py_OptimizeFlag)) {
8680 __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_ref_list_length, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 797, __pyx_L1_error)
8681 __Pyx_GOTREF(__pyx_t_1);
8682 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 797, __pyx_L1_error)
8683 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8684 if (unlikely(!__pyx_t_2)) {
8685 PyErr_SetNone(PyExc_AssertionError);
8686 __PYX_ERR(0, 797, __pyx_L1_error)
8687 }
8688 }
8689 #endif
8690
8691 /* "breezy/bzr/_btree_serializer_pyx.pyx":798
8692 * assert key_length == 1
8693 * assert ref_list_length == 0
8694 * return GCCHKSHA1LeafNode(bytes) # <<<<<<<<<<<<<<
8695 *
8696 *
8697 */
8698 __Pyx_XDECREF(__pyx_r);
8699 __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode), __pyx_v_bytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 798, __pyx_L1_error)
8700 __Pyx_GOTREF(__pyx_t_1);
8701 __pyx_r = __pyx_t_1;
8702 __pyx_t_1 = 0;
8703 goto __pyx_L0;
8704
8705 /* "breezy/bzr/_btree_serializer_pyx.pyx":794
8706 *
8707 *
8708 * def _parse_into_chk(bytes, key_length, ref_list_length): # <<<<<<<<<<<<<<
8709 * """Parse into a format optimized for chk records."""
8710 * assert key_length == 1
8711 */
8712
8713 /* function exit code */
8714 __pyx_L1_error:;
8715 __Pyx_XDECREF(__pyx_t_1);
8716 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._parse_into_chk", __pyx_clineno, __pyx_lineno, __pyx_filename);
8717 __pyx_r = NULL;
8718 __pyx_L0:;
8719 __Pyx_XGIVEREF(__pyx_r);
8720 __Pyx_RefNannyFinishContext();
8721 return __pyx_r;
8722 }
8723
8724 /* "breezy/bzr/_btree_serializer_pyx.pyx":801
8725 *
8726 *
8727 * def _flatten_node(node, reference_lists): # <<<<<<<<<<<<<<
8728 * """Convert a node into the serialized form.
8729 *
8730 */
8731
8732 /* Python wrapper */
8733 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_13_flatten_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8734 static char __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_12_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 ";
8735 static PyMethodDef __pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_13_flatten_node = {"_flatten_node", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_13_flatten_node, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6breezy_3bzr_21_btree_serializer_pyx_12_flatten_node};
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_13_flatten_node(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)8736 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_13_flatten_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8737 PyObject *__pyx_v_node = 0;
8738 PyObject *__pyx_v_reference_lists = 0;
8739 int __pyx_lineno = 0;
8740 const char *__pyx_filename = NULL;
8741 int __pyx_clineno = 0;
8742 PyObject *__pyx_r = 0;
8743 __Pyx_RefNannyDeclarations
8744 __Pyx_RefNannySetupContext("_flatten_node (wrapper)", 0);
8745 {
8746 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_node,&__pyx_n_s_reference_lists,0};
8747 PyObject* values[2] = {0,0};
8748 if (unlikely(__pyx_kwds)) {
8749 Py_ssize_t kw_args;
8750 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8751 switch (pos_args) {
8752 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8753 CYTHON_FALLTHROUGH;
8754 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8755 CYTHON_FALLTHROUGH;
8756 case 0: break;
8757 default: goto __pyx_L5_argtuple_error;
8758 }
8759 kw_args = PyDict_Size(__pyx_kwds);
8760 switch (pos_args) {
8761 case 0:
8762 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_node)) != 0)) kw_args--;
8763 else goto __pyx_L5_argtuple_error;
8764 CYTHON_FALLTHROUGH;
8765 case 1:
8766 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reference_lists)) != 0)) kw_args--;
8767 else {
8768 __Pyx_RaiseArgtupleInvalid("_flatten_node", 1, 2, 2, 1); __PYX_ERR(0, 801, __pyx_L3_error)
8769 }
8770 }
8771 if (unlikely(kw_args > 0)) {
8772 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_flatten_node") < 0)) __PYX_ERR(0, 801, __pyx_L3_error)
8773 }
8774 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
8775 goto __pyx_L5_argtuple_error;
8776 } else {
8777 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8778 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8779 }
8780 __pyx_v_node = values[0];
8781 __pyx_v_reference_lists = values[1];
8782 }
8783 goto __pyx_L4_argument_unpacking_done;
8784 __pyx_L5_argtuple_error:;
8785 __Pyx_RaiseArgtupleInvalid("_flatten_node", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 801, __pyx_L3_error)
8786 __pyx_L3_error:;
8787 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._flatten_node", __pyx_clineno, __pyx_lineno, __pyx_filename);
8788 __Pyx_RefNannyFinishContext();
8789 return NULL;
8790 __pyx_L4_argument_unpacking_done:;
8791 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_12_flatten_node(__pyx_self, __pyx_v_node, __pyx_v_reference_lists);
8792
8793 /* function exit code */
8794 __Pyx_RefNannyFinishContext();
8795 return __pyx_r;
8796 }
8797
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_12_flatten_node(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_node,PyObject * __pyx_v_reference_lists)8798 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_12_flatten_node(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_node, PyObject *__pyx_v_reference_lists) {
8799 int __pyx_v_have_reference_lists;
8800 Py_ssize_t __pyx_v_flat_len;
8801 Py_ssize_t __pyx_v_key_len;
8802 Py_ssize_t __pyx_v_node_len;
8803 char *__pyx_v_value;
8804 Py_ssize_t __pyx_v_value_len;
8805 char *__pyx_v_out;
8806 Py_ssize_t __pyx_v_refs_len;
8807 Py_ssize_t __pyx_v_next_len;
8808 int __pyx_v_first_ref_list;
8809 int __pyx_v_first_reference;
8810 int __pyx_v_i;
8811 Py_ssize_t __pyx_v_ref_bit_len;
8812 PyObject *__pyx_v_string_key = NULL;
8813 PyObject *__pyx_v_ref_lists = NULL;
8814 PyObject *__pyx_v_ref_list = NULL;
8815 PyObject *__pyx_v_reference = NULL;
8816 PyObject *__pyx_v_ref_bit = NULL;
8817 PyObject *__pyx_v_val = NULL;
8818 PyObject *__pyx_v_line = NULL;
8819 PyObject *__pyx_r = NULL;
8820 __Pyx_RefNannyDeclarations
8821 int __pyx_t_1;
8822 int __pyx_t_2;
8823 PyObject *__pyx_t_3 = NULL;
8824 PyObject *__pyx_t_4 = NULL;
8825 Py_ssize_t __pyx_t_5;
8826 int __pyx_t_6;
8827 PyObject *(*__pyx_t_7)(PyObject *);
8828 Py_ssize_t __pyx_t_8;
8829 PyObject *(*__pyx_t_9)(PyObject *);
8830 PyObject *__pyx_t_10 = NULL;
8831 PyObject *__pyx_t_11 = NULL;
8832 Py_ssize_t __pyx_t_12;
8833 PyObject *(*__pyx_t_13)(PyObject *);
8834 PyObject *__pyx_t_14 = NULL;
8835 char *__pyx_t_15;
8836 int __pyx_lineno = 0;
8837 const char *__pyx_filename = NULL;
8838 int __pyx_clineno = 0;
8839 __Pyx_RefNannySetupContext("_flatten_node", 0);
8840
8841 /* "breezy/bzr/_btree_serializer_pyx.pyx":825
8842 * cdef Py_ssize_t ref_bit_len
8843 *
8844 * if not PyTuple_CheckExact(node) and not StaticTuple_CheckExact(node): # <<<<<<<<<<<<<<
8845 * raise TypeError('We expected a tuple() or StaticTuple() for node not: %s'
8846 * % type(node))
8847 */
8848 __pyx_t_2 = ((!(PyTuple_CheckExact(__pyx_v_node) != 0)) != 0);
8849 if (__pyx_t_2) {
8850 } else {
8851 __pyx_t_1 = __pyx_t_2;
8852 goto __pyx_L4_bool_binop_done;
8853 }
8854 __pyx_t_2 = ((!(StaticTuple_CheckExact(__pyx_v_node) != 0)) != 0);
8855 __pyx_t_1 = __pyx_t_2;
8856 __pyx_L4_bool_binop_done:;
8857 if (unlikely(__pyx_t_1)) {
8858
8859 /* "breezy/bzr/_btree_serializer_pyx.pyx":827
8860 * if not PyTuple_CheckExact(node) and not StaticTuple_CheckExact(node):
8861 * raise TypeError('We expected a tuple() or StaticTuple() for node not: %s'
8862 * % type(node)) # <<<<<<<<<<<<<<
8863 * node_len = len(node)
8864 * have_reference_lists = reference_lists
8865 */
8866 __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_We_expected_a_tuple_or_StaticTup, ((PyObject *)Py_TYPE(__pyx_v_node))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 827, __pyx_L1_error)
8867 __Pyx_GOTREF(__pyx_t_3);
8868
8869 /* "breezy/bzr/_btree_serializer_pyx.pyx":826
8870 *
8871 * if not PyTuple_CheckExact(node) and not StaticTuple_CheckExact(node):
8872 * raise TypeError('We expected a tuple() or StaticTuple() for node not: %s' # <<<<<<<<<<<<<<
8873 * % type(node))
8874 * node_len = len(node)
8875 */
8876 __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 826, __pyx_L1_error)
8877 __Pyx_GOTREF(__pyx_t_4);
8878 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8879 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
8880 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8881 __PYX_ERR(0, 826, __pyx_L1_error)
8882
8883 /* "breezy/bzr/_btree_serializer_pyx.pyx":825
8884 * cdef Py_ssize_t ref_bit_len
8885 *
8886 * if not PyTuple_CheckExact(node) and not StaticTuple_CheckExact(node): # <<<<<<<<<<<<<<
8887 * raise TypeError('We expected a tuple() or StaticTuple() for node not: %s'
8888 * % type(node))
8889 */
8890 }
8891
8892 /* "breezy/bzr/_btree_serializer_pyx.pyx":828
8893 * raise TypeError('We expected a tuple() or StaticTuple() for node not: %s'
8894 * % type(node))
8895 * node_len = len(node) # <<<<<<<<<<<<<<
8896 * have_reference_lists = reference_lists
8897 * if have_reference_lists:
8898 */
8899 __pyx_t_5 = PyObject_Length(__pyx_v_node); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 828, __pyx_L1_error)
8900 __pyx_v_node_len = __pyx_t_5;
8901
8902 /* "breezy/bzr/_btree_serializer_pyx.pyx":829
8903 * % type(node))
8904 * node_len = len(node)
8905 * have_reference_lists = reference_lists # <<<<<<<<<<<<<<
8906 * if have_reference_lists:
8907 * if node_len != 4:
8908 */
8909 __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_reference_lists); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 829, __pyx_L1_error)
8910 __pyx_v_have_reference_lists = __pyx_t_6;
8911
8912 /* "breezy/bzr/_btree_serializer_pyx.pyx":830
8913 * node_len = len(node)
8914 * have_reference_lists = reference_lists
8915 * if have_reference_lists: # <<<<<<<<<<<<<<
8916 * if node_len != 4:
8917 * raise ValueError('With ref_lists, we expected 4 entries not: %s'
8918 */
8919 __pyx_t_1 = (__pyx_v_have_reference_lists != 0);
8920 if (__pyx_t_1) {
8921
8922 /* "breezy/bzr/_btree_serializer_pyx.pyx":831
8923 * have_reference_lists = reference_lists
8924 * if have_reference_lists:
8925 * if node_len != 4: # <<<<<<<<<<<<<<
8926 * raise ValueError('With ref_lists, we expected 4 entries not: %s'
8927 * % len(node))
8928 */
8929 __pyx_t_1 = ((__pyx_v_node_len != 4) != 0);
8930 if (unlikely(__pyx_t_1)) {
8931
8932 /* "breezy/bzr/_btree_serializer_pyx.pyx":833
8933 * if node_len != 4:
8934 * raise ValueError('With ref_lists, we expected 4 entries not: %s'
8935 * % len(node)) # <<<<<<<<<<<<<<
8936 * elif node_len < 3:
8937 * raise ValueError('Without ref_lists, we need at least 3 entries not: %s'
8938 */
8939 __pyx_t_5 = PyObject_Length(__pyx_v_node); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 833, __pyx_L1_error)
8940 __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 833, __pyx_L1_error)
8941 __Pyx_GOTREF(__pyx_t_4);
8942 __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_With_ref_lists_we_expected_4_ent, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 833, __pyx_L1_error)
8943 __Pyx_GOTREF(__pyx_t_3);
8944 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8945
8946 /* "breezy/bzr/_btree_serializer_pyx.pyx":832
8947 * if have_reference_lists:
8948 * if node_len != 4:
8949 * raise ValueError('With ref_lists, we expected 4 entries not: %s' # <<<<<<<<<<<<<<
8950 * % len(node))
8951 * elif node_len < 3:
8952 */
8953 __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 832, __pyx_L1_error)
8954 __Pyx_GOTREF(__pyx_t_4);
8955 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8956 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
8957 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8958 __PYX_ERR(0, 832, __pyx_L1_error)
8959
8960 /* "breezy/bzr/_btree_serializer_pyx.pyx":831
8961 * have_reference_lists = reference_lists
8962 * if have_reference_lists:
8963 * if node_len != 4: # <<<<<<<<<<<<<<
8964 * raise ValueError('With ref_lists, we expected 4 entries not: %s'
8965 * % len(node))
8966 */
8967 }
8968
8969 /* "breezy/bzr/_btree_serializer_pyx.pyx":830
8970 * node_len = len(node)
8971 * have_reference_lists = reference_lists
8972 * if have_reference_lists: # <<<<<<<<<<<<<<
8973 * if node_len != 4:
8974 * raise ValueError('With ref_lists, we expected 4 entries not: %s'
8975 */
8976 goto __pyx_L6;
8977 }
8978
8979 /* "breezy/bzr/_btree_serializer_pyx.pyx":834
8980 * raise ValueError('With ref_lists, we expected 4 entries not: %s'
8981 * % len(node))
8982 * elif node_len < 3: # <<<<<<<<<<<<<<
8983 * raise ValueError('Without ref_lists, we need at least 3 entries not: %s'
8984 * % len(node))
8985 */
8986 __pyx_t_1 = ((__pyx_v_node_len < 3) != 0);
8987 if (unlikely(__pyx_t_1)) {
8988
8989 /* "breezy/bzr/_btree_serializer_pyx.pyx":836
8990 * elif node_len < 3:
8991 * raise ValueError('Without ref_lists, we need at least 3 entries not: %s'
8992 * % len(node)) # <<<<<<<<<<<<<<
8993 * # TODO: We can probably do better than string.join(), namely
8994 * # when key has only 1 item, we can just grab that string
8995 */
8996 __pyx_t_5 = PyObject_Length(__pyx_v_node); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 836, __pyx_L1_error)
8997 __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 836, __pyx_L1_error)
8998 __Pyx_GOTREF(__pyx_t_4);
8999 __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_Without_ref_lists_we_need_at_lea, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 836, __pyx_L1_error)
9000 __Pyx_GOTREF(__pyx_t_3);
9001 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9002
9003 /* "breezy/bzr/_btree_serializer_pyx.pyx":835
9004 * % len(node))
9005 * elif node_len < 3:
9006 * raise ValueError('Without ref_lists, we need at least 3 entries not: %s' # <<<<<<<<<<<<<<
9007 * % len(node))
9008 * # TODO: We can probably do better than string.join(), namely
9009 */
9010 __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 835, __pyx_L1_error)
9011 __Pyx_GOTREF(__pyx_t_4);
9012 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9013 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
9014 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9015 __PYX_ERR(0, 835, __pyx_L1_error)
9016
9017 /* "breezy/bzr/_btree_serializer_pyx.pyx":834
9018 * raise ValueError('With ref_lists, we expected 4 entries not: %s'
9019 * % len(node))
9020 * elif node_len < 3: # <<<<<<<<<<<<<<
9021 * raise ValueError('Without ref_lists, we need at least 3 entries not: %s'
9022 * % len(node))
9023 */
9024 }
9025 __pyx_L6:;
9026
9027 /* "breezy/bzr/_btree_serializer_pyx.pyx":847
9028 * # We *could* do more work on our own, and grab the actual items
9029 * # lists. For now, just ask people to use a better compiler. :)
9030 * string_key = b'\0'.join(node[1]) # <<<<<<<<<<<<<<
9031 *
9032 * # TODO: instead of using string joins, precompute the final string length,
9033 */
9034 __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_node, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 847, __pyx_L1_error)
9035 __Pyx_GOTREF(__pyx_t_4);
9036 __pyx_t_3 = __Pyx_PyBytes_Join(__pyx_kp_b__20, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 847, __pyx_L1_error)
9037 __Pyx_GOTREF(__pyx_t_3);
9038 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9039 __pyx_v_string_key = __pyx_t_3;
9040 __pyx_t_3 = 0;
9041
9042 /* "breezy/bzr/_btree_serializer_pyx.pyx":861
9043 * # ref := BYTES (NULL BYTES)*
9044 * # value := BYTES
9045 * refs_len = 0 # <<<<<<<<<<<<<<
9046 * if have_reference_lists:
9047 * # Figure out how many bytes it will take to store the references
9048 */
9049 __pyx_v_refs_len = 0;
9050
9051 /* "breezy/bzr/_btree_serializer_pyx.pyx":862
9052 * # value := BYTES
9053 * refs_len = 0
9054 * if have_reference_lists: # <<<<<<<<<<<<<<
9055 * # Figure out how many bytes it will take to store the references
9056 * ref_lists = node[3]
9057 */
9058 __pyx_t_1 = (__pyx_v_have_reference_lists != 0);
9059 if (__pyx_t_1) {
9060
9061 /* "breezy/bzr/_btree_serializer_pyx.pyx":864
9062 * if have_reference_lists:
9063 * # Figure out how many bytes it will take to store the references
9064 * ref_lists = node[3] # <<<<<<<<<<<<<<
9065 * next_len = len(ref_lists) # TODO: use a Py function
9066 * if next_len > 0:
9067 */
9068 __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_node, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 864, __pyx_L1_error)
9069 __Pyx_GOTREF(__pyx_t_3);
9070 __pyx_v_ref_lists = __pyx_t_3;
9071 __pyx_t_3 = 0;
9072
9073 /* "breezy/bzr/_btree_serializer_pyx.pyx":865
9074 * # Figure out how many bytes it will take to store the references
9075 * ref_lists = node[3]
9076 * next_len = len(ref_lists) # TODO: use a Py function # <<<<<<<<<<<<<<
9077 * if next_len > 0:
9078 * # If there are no nodes, we don't need to do any work
9079 */
9080 __pyx_t_5 = PyObject_Length(__pyx_v_ref_lists); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 865, __pyx_L1_error)
9081 __pyx_v_next_len = __pyx_t_5;
9082
9083 /* "breezy/bzr/_btree_serializer_pyx.pyx":866
9084 * ref_lists = node[3]
9085 * next_len = len(ref_lists) # TODO: use a Py function
9086 * if next_len > 0: # <<<<<<<<<<<<<<
9087 * # If there are no nodes, we don't need to do any work
9088 * # Otherwise we will need (len - 1) '\t' characters to separate
9089 */
9090 __pyx_t_1 = ((__pyx_v_next_len > 0) != 0);
9091 if (__pyx_t_1) {
9092
9093 /* "breezy/bzr/_btree_serializer_pyx.pyx":870
9094 * # Otherwise we will need (len - 1) '\t' characters to separate
9095 * # the reference lists
9096 * refs_len = refs_len + (next_len - 1) # <<<<<<<<<<<<<<
9097 * for ref_list in ref_lists:
9098 * next_len = len(ref_list)
9099 */
9100 __pyx_v_refs_len = (__pyx_v_refs_len + (__pyx_v_next_len - 1));
9101
9102 /* "breezy/bzr/_btree_serializer_pyx.pyx":871
9103 * # the reference lists
9104 * refs_len = refs_len + (next_len - 1)
9105 * for ref_list in ref_lists: # <<<<<<<<<<<<<<
9106 * next_len = len(ref_list)
9107 * if next_len > 0:
9108 */
9109 if (likely(PyList_CheckExact(__pyx_v_ref_lists)) || PyTuple_CheckExact(__pyx_v_ref_lists)) {
9110 __pyx_t_3 = __pyx_v_ref_lists; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
9111 __pyx_t_7 = NULL;
9112 } else {
9113 __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_ref_lists); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 871, __pyx_L1_error)
9114 __Pyx_GOTREF(__pyx_t_3);
9115 __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 871, __pyx_L1_error)
9116 }
9117 for (;;) {
9118 if (likely(!__pyx_t_7)) {
9119 if (likely(PyList_CheckExact(__pyx_t_3))) {
9120 if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
9121 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9122 __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 871, __pyx_L1_error)
9123 #else
9124 __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 871, __pyx_L1_error)
9125 __Pyx_GOTREF(__pyx_t_4);
9126 #endif
9127 } else {
9128 if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
9129 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9130 __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 871, __pyx_L1_error)
9131 #else
9132 __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 871, __pyx_L1_error)
9133 __Pyx_GOTREF(__pyx_t_4);
9134 #endif
9135 }
9136 } else {
9137 __pyx_t_4 = __pyx_t_7(__pyx_t_3);
9138 if (unlikely(!__pyx_t_4)) {
9139 PyObject* exc_type = PyErr_Occurred();
9140 if (exc_type) {
9141 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
9142 else __PYX_ERR(0, 871, __pyx_L1_error)
9143 }
9144 break;
9145 }
9146 __Pyx_GOTREF(__pyx_t_4);
9147 }
9148 __Pyx_XDECREF_SET(__pyx_v_ref_list, __pyx_t_4);
9149 __pyx_t_4 = 0;
9150
9151 /* "breezy/bzr/_btree_serializer_pyx.pyx":872
9152 * refs_len = refs_len + (next_len - 1)
9153 * for ref_list in ref_lists:
9154 * next_len = len(ref_list) # <<<<<<<<<<<<<<
9155 * if next_len > 0:
9156 * # We will need (len - 1) '\r' characters to separate the
9157 */
9158 __pyx_t_8 = PyObject_Length(__pyx_v_ref_list); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 872, __pyx_L1_error)
9159 __pyx_v_next_len = __pyx_t_8;
9160
9161 /* "breezy/bzr/_btree_serializer_pyx.pyx":873
9162 * for ref_list in ref_lists:
9163 * next_len = len(ref_list)
9164 * if next_len > 0: # <<<<<<<<<<<<<<
9165 * # We will need (len - 1) '\r' characters to separate the
9166 * # references
9167 */
9168 __pyx_t_1 = ((__pyx_v_next_len > 0) != 0);
9169 if (__pyx_t_1) {
9170
9171 /* "breezy/bzr/_btree_serializer_pyx.pyx":876
9172 * # We will need (len - 1) '\r' characters to separate the
9173 * # references
9174 * refs_len = refs_len + (next_len - 1) # <<<<<<<<<<<<<<
9175 * for reference in ref_list:
9176 * if (not PyTuple_CheckExact(reference)
9177 */
9178 __pyx_v_refs_len = (__pyx_v_refs_len + (__pyx_v_next_len - 1));
9179
9180 /* "breezy/bzr/_btree_serializer_pyx.pyx":877
9181 * # references
9182 * refs_len = refs_len + (next_len - 1)
9183 * for reference in ref_list: # <<<<<<<<<<<<<<
9184 * if (not PyTuple_CheckExact(reference)
9185 * and not StaticTuple_CheckExact(reference)):
9186 */
9187 if (likely(PyList_CheckExact(__pyx_v_ref_list)) || PyTuple_CheckExact(__pyx_v_ref_list)) {
9188 __pyx_t_4 = __pyx_v_ref_list; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
9189 __pyx_t_9 = NULL;
9190 } else {
9191 __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_ref_list); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 877, __pyx_L1_error)
9192 __Pyx_GOTREF(__pyx_t_4);
9193 __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 877, __pyx_L1_error)
9194 }
9195 for (;;) {
9196 if (likely(!__pyx_t_9)) {
9197 if (likely(PyList_CheckExact(__pyx_t_4))) {
9198 if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
9199 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9200 __pyx_t_10 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 877, __pyx_L1_error)
9201 #else
9202 __pyx_t_10 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 877, __pyx_L1_error)
9203 __Pyx_GOTREF(__pyx_t_10);
9204 #endif
9205 } else {
9206 if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
9207 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9208 __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 877, __pyx_L1_error)
9209 #else
9210 __pyx_t_10 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 877, __pyx_L1_error)
9211 __Pyx_GOTREF(__pyx_t_10);
9212 #endif
9213 }
9214 } else {
9215 __pyx_t_10 = __pyx_t_9(__pyx_t_4);
9216 if (unlikely(!__pyx_t_10)) {
9217 PyObject* exc_type = PyErr_Occurred();
9218 if (exc_type) {
9219 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
9220 else __PYX_ERR(0, 877, __pyx_L1_error)
9221 }
9222 break;
9223 }
9224 __Pyx_GOTREF(__pyx_t_10);
9225 }
9226 __Pyx_XDECREF_SET(__pyx_v_reference, __pyx_t_10);
9227 __pyx_t_10 = 0;
9228
9229 /* "breezy/bzr/_btree_serializer_pyx.pyx":878
9230 * refs_len = refs_len + (next_len - 1)
9231 * for reference in ref_list:
9232 * if (not PyTuple_CheckExact(reference) # <<<<<<<<<<<<<<
9233 * and not StaticTuple_CheckExact(reference)):
9234 * raise TypeError(
9235 */
9236 __pyx_t_2 = ((!(PyTuple_CheckExact(__pyx_v_reference) != 0)) != 0);
9237 if (__pyx_t_2) {
9238 } else {
9239 __pyx_t_1 = __pyx_t_2;
9240 goto __pyx_L16_bool_binop_done;
9241 }
9242
9243 /* "breezy/bzr/_btree_serializer_pyx.pyx":879
9244 * for reference in ref_list:
9245 * if (not PyTuple_CheckExact(reference)
9246 * and not StaticTuple_CheckExact(reference)): # <<<<<<<<<<<<<<
9247 * raise TypeError(
9248 * 'We expect references to be tuples not: %r'
9249 */
9250 __pyx_t_2 = ((!(StaticTuple_CheckExact(__pyx_v_reference) != 0)) != 0);
9251 __pyx_t_1 = __pyx_t_2;
9252 __pyx_L16_bool_binop_done:;
9253
9254 /* "breezy/bzr/_btree_serializer_pyx.pyx":878
9255 * refs_len = refs_len + (next_len - 1)
9256 * for reference in ref_list:
9257 * if (not PyTuple_CheckExact(reference) # <<<<<<<<<<<<<<
9258 * and not StaticTuple_CheckExact(reference)):
9259 * raise TypeError(
9260 */
9261 if (unlikely(__pyx_t_1)) {
9262
9263 /* "breezy/bzr/_btree_serializer_pyx.pyx":882
9264 * raise TypeError(
9265 * 'We expect references to be tuples not: %r'
9266 * % type(reference)) # <<<<<<<<<<<<<<
9267 * next_len = len(reference)
9268 * if next_len > 0:
9269 */
9270 __pyx_t_10 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_We_expect_references_to_be_tuple, ((PyObject *)Py_TYPE(__pyx_v_reference))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 882, __pyx_L1_error)
9271 __Pyx_GOTREF(__pyx_t_10);
9272
9273 /* "breezy/bzr/_btree_serializer_pyx.pyx":880
9274 * if (not PyTuple_CheckExact(reference)
9275 * and not StaticTuple_CheckExact(reference)):
9276 * raise TypeError( # <<<<<<<<<<<<<<
9277 * 'We expect references to be tuples not: %r'
9278 * % type(reference))
9279 */
9280 __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 880, __pyx_L1_error)
9281 __Pyx_GOTREF(__pyx_t_11);
9282 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
9283 __Pyx_Raise(__pyx_t_11, 0, 0, 0);
9284 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
9285 __PYX_ERR(0, 880, __pyx_L1_error)
9286
9287 /* "breezy/bzr/_btree_serializer_pyx.pyx":878
9288 * refs_len = refs_len + (next_len - 1)
9289 * for reference in ref_list:
9290 * if (not PyTuple_CheckExact(reference) # <<<<<<<<<<<<<<
9291 * and not StaticTuple_CheckExact(reference)):
9292 * raise TypeError(
9293 */
9294 }
9295
9296 /* "breezy/bzr/_btree_serializer_pyx.pyx":883
9297 * 'We expect references to be tuples not: %r'
9298 * % type(reference))
9299 * next_len = len(reference) # <<<<<<<<<<<<<<
9300 * if next_len > 0:
9301 * # We will need (len - 1) '\x00' characters to
9302 */
9303 __pyx_t_12 = PyObject_Length(__pyx_v_reference); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 883, __pyx_L1_error)
9304 __pyx_v_next_len = __pyx_t_12;
9305
9306 /* "breezy/bzr/_btree_serializer_pyx.pyx":884
9307 * % type(reference))
9308 * next_len = len(reference)
9309 * if next_len > 0: # <<<<<<<<<<<<<<
9310 * # We will need (len - 1) '\x00' characters to
9311 * # separate the reference key
9312 */
9313 __pyx_t_1 = ((__pyx_v_next_len > 0) != 0);
9314 if (__pyx_t_1) {
9315
9316 /* "breezy/bzr/_btree_serializer_pyx.pyx":887
9317 * # We will need (len - 1) '\x00' characters to
9318 * # separate the reference key
9319 * refs_len = refs_len + (next_len - 1) # <<<<<<<<<<<<<<
9320 * for ref_bit in reference:
9321 * if not PyBytes_CheckExact(ref_bit):
9322 */
9323 __pyx_v_refs_len = (__pyx_v_refs_len + (__pyx_v_next_len - 1));
9324
9325 /* "breezy/bzr/_btree_serializer_pyx.pyx":888
9326 * # separate the reference key
9327 * refs_len = refs_len + (next_len - 1)
9328 * for ref_bit in reference: # <<<<<<<<<<<<<<
9329 * if not PyBytes_CheckExact(ref_bit):
9330 * raise TypeError(
9331 */
9332 if (likely(PyList_CheckExact(__pyx_v_reference)) || PyTuple_CheckExact(__pyx_v_reference)) {
9333 __pyx_t_11 = __pyx_v_reference; __Pyx_INCREF(__pyx_t_11); __pyx_t_12 = 0;
9334 __pyx_t_13 = NULL;
9335 } else {
9336 __pyx_t_12 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_v_reference); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 888, __pyx_L1_error)
9337 __Pyx_GOTREF(__pyx_t_11);
9338 __pyx_t_13 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 888, __pyx_L1_error)
9339 }
9340 for (;;) {
9341 if (likely(!__pyx_t_13)) {
9342 if (likely(PyList_CheckExact(__pyx_t_11))) {
9343 if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_11)) break;
9344 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9345 __pyx_t_10 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 888, __pyx_L1_error)
9346 #else
9347 __pyx_t_10 = PySequence_ITEM(__pyx_t_11, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 888, __pyx_L1_error)
9348 __Pyx_GOTREF(__pyx_t_10);
9349 #endif
9350 } else {
9351 if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
9352 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9353 __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 888, __pyx_L1_error)
9354 #else
9355 __pyx_t_10 = PySequence_ITEM(__pyx_t_11, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 888, __pyx_L1_error)
9356 __Pyx_GOTREF(__pyx_t_10);
9357 #endif
9358 }
9359 } else {
9360 __pyx_t_10 = __pyx_t_13(__pyx_t_11);
9361 if (unlikely(!__pyx_t_10)) {
9362 PyObject* exc_type = PyErr_Occurred();
9363 if (exc_type) {
9364 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
9365 else __PYX_ERR(0, 888, __pyx_L1_error)
9366 }
9367 break;
9368 }
9369 __Pyx_GOTREF(__pyx_t_10);
9370 }
9371 __Pyx_XDECREF_SET(__pyx_v_ref_bit, __pyx_t_10);
9372 __pyx_t_10 = 0;
9373
9374 /* "breezy/bzr/_btree_serializer_pyx.pyx":889
9375 * refs_len = refs_len + (next_len - 1)
9376 * for ref_bit in reference:
9377 * if not PyBytes_CheckExact(ref_bit): # <<<<<<<<<<<<<<
9378 * raise TypeError(
9379 * 'We expect reference bits to be bytes'
9380 */
9381 __pyx_t_1 = ((!(PyBytes_CheckExact(__pyx_v_ref_bit) != 0)) != 0);
9382 if (unlikely(__pyx_t_1)) {
9383
9384 /* "breezy/bzr/_btree_serializer_pyx.pyx":892
9385 * raise TypeError(
9386 * 'We expect reference bits to be bytes'
9387 * ' not: %r' % type(ref_bit)) # <<<<<<<<<<<<<<
9388 * refs_len = refs_len + PyBytes_GET_SIZE(ref_bit)
9389 *
9390 */
9391 __pyx_t_10 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_We_expect_reference_bits_to_be_b, ((PyObject *)Py_TYPE(__pyx_v_ref_bit))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 892, __pyx_L1_error)
9392 __Pyx_GOTREF(__pyx_t_10);
9393
9394 /* "breezy/bzr/_btree_serializer_pyx.pyx":890
9395 * for ref_bit in reference:
9396 * if not PyBytes_CheckExact(ref_bit):
9397 * raise TypeError( # <<<<<<<<<<<<<<
9398 * 'We expect reference bits to be bytes'
9399 * ' not: %r' % type(ref_bit))
9400 */
9401 __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 890, __pyx_L1_error)
9402 __Pyx_GOTREF(__pyx_t_14);
9403 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
9404 __Pyx_Raise(__pyx_t_14, 0, 0, 0);
9405 __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
9406 __PYX_ERR(0, 890, __pyx_L1_error)
9407
9408 /* "breezy/bzr/_btree_serializer_pyx.pyx":889
9409 * refs_len = refs_len + (next_len - 1)
9410 * for ref_bit in reference:
9411 * if not PyBytes_CheckExact(ref_bit): # <<<<<<<<<<<<<<
9412 * raise TypeError(
9413 * 'We expect reference bits to be bytes'
9414 */
9415 }
9416
9417 /* "breezy/bzr/_btree_serializer_pyx.pyx":893
9418 * 'We expect reference bits to be bytes'
9419 * ' not: %r' % type(ref_bit))
9420 * refs_len = refs_len + PyBytes_GET_SIZE(ref_bit) # <<<<<<<<<<<<<<
9421 *
9422 * # So we have the (key NULL refs NULL value LF)
9423 */
9424 __pyx_v_refs_len = (__pyx_v_refs_len + PyBytes_GET_SIZE(__pyx_v_ref_bit));
9425
9426 /* "breezy/bzr/_btree_serializer_pyx.pyx":888
9427 * # separate the reference key
9428 * refs_len = refs_len + (next_len - 1)
9429 * for ref_bit in reference: # <<<<<<<<<<<<<<
9430 * if not PyBytes_CheckExact(ref_bit):
9431 * raise TypeError(
9432 */
9433 }
9434 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
9435
9436 /* "breezy/bzr/_btree_serializer_pyx.pyx":884
9437 * % type(reference))
9438 * next_len = len(reference)
9439 * if next_len > 0: # <<<<<<<<<<<<<<
9440 * # We will need (len - 1) '\x00' characters to
9441 * # separate the reference key
9442 */
9443 }
9444
9445 /* "breezy/bzr/_btree_serializer_pyx.pyx":877
9446 * # references
9447 * refs_len = refs_len + (next_len - 1)
9448 * for reference in ref_list: # <<<<<<<<<<<<<<
9449 * if (not PyTuple_CheckExact(reference)
9450 * and not StaticTuple_CheckExact(reference)):
9451 */
9452 }
9453 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9454
9455 /* "breezy/bzr/_btree_serializer_pyx.pyx":873
9456 * for ref_list in ref_lists:
9457 * next_len = len(ref_list)
9458 * if next_len > 0: # <<<<<<<<<<<<<<
9459 * # We will need (len - 1) '\r' characters to separate the
9460 * # references
9461 */
9462 }
9463
9464 /* "breezy/bzr/_btree_serializer_pyx.pyx":871
9465 * # the reference lists
9466 * refs_len = refs_len + (next_len - 1)
9467 * for ref_list in ref_lists: # <<<<<<<<<<<<<<
9468 * next_len = len(ref_list)
9469 * if next_len > 0:
9470 */
9471 }
9472 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9473
9474 /* "breezy/bzr/_btree_serializer_pyx.pyx":866
9475 * ref_lists = node[3]
9476 * next_len = len(ref_lists) # TODO: use a Py function
9477 * if next_len > 0: # <<<<<<<<<<<<<<
9478 * # If there are no nodes, we don't need to do any work
9479 * # Otherwise we will need (len - 1) '\t' characters to separate
9480 */
9481 }
9482
9483 /* "breezy/bzr/_btree_serializer_pyx.pyx":862
9484 * # value := BYTES
9485 * refs_len = 0
9486 * if have_reference_lists: # <<<<<<<<<<<<<<
9487 * # Figure out how many bytes it will take to store the references
9488 * ref_lists = node[3]
9489 */
9490 }
9491
9492 /* "breezy/bzr/_btree_serializer_pyx.pyx":896
9493 *
9494 * # So we have the (key NULL refs NULL value LF)
9495 * key_len = PyBytes_Size(string_key) # <<<<<<<<<<<<<<
9496 * val = node[2]
9497 * if not PyBytes_CheckExact(val):
9498 */
9499 __pyx_t_5 = PyBytes_Size(__pyx_v_string_key); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1L))) __PYX_ERR(0, 896, __pyx_L1_error)
9500 __pyx_v_key_len = __pyx_t_5;
9501
9502 /* "breezy/bzr/_btree_serializer_pyx.pyx":897
9503 * # So we have the (key NULL refs NULL value LF)
9504 * key_len = PyBytes_Size(string_key)
9505 * val = node[2] # <<<<<<<<<<<<<<
9506 * if not PyBytes_CheckExact(val):
9507 * raise TypeError('Expected bytes for value not: %r' % type(val))
9508 */
9509 __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_node, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 897, __pyx_L1_error)
9510 __Pyx_GOTREF(__pyx_t_3);
9511 __pyx_v_val = __pyx_t_3;
9512 __pyx_t_3 = 0;
9513
9514 /* "breezy/bzr/_btree_serializer_pyx.pyx":898
9515 * key_len = PyBytes_Size(string_key)
9516 * val = node[2]
9517 * if not PyBytes_CheckExact(val): # <<<<<<<<<<<<<<
9518 * raise TypeError('Expected bytes for value not: %r' % type(val))
9519 * value = PyBytes_AS_STRING(val)
9520 */
9521 __pyx_t_1 = ((!(PyBytes_CheckExact(__pyx_v_val) != 0)) != 0);
9522 if (unlikely(__pyx_t_1)) {
9523
9524 /* "breezy/bzr/_btree_serializer_pyx.pyx":899
9525 * val = node[2]
9526 * if not PyBytes_CheckExact(val):
9527 * raise TypeError('Expected bytes for value not: %r' % type(val)) # <<<<<<<<<<<<<<
9528 * value = PyBytes_AS_STRING(val)
9529 * value_len = PyBytes_GET_SIZE(val)
9530 */
9531 __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Expected_bytes_for_value_not_r, ((PyObject *)Py_TYPE(__pyx_v_val))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 899, __pyx_L1_error)
9532 __Pyx_GOTREF(__pyx_t_3);
9533 __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 899, __pyx_L1_error)
9534 __Pyx_GOTREF(__pyx_t_4);
9535 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9536 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
9537 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9538 __PYX_ERR(0, 899, __pyx_L1_error)
9539
9540 /* "breezy/bzr/_btree_serializer_pyx.pyx":898
9541 * key_len = PyBytes_Size(string_key)
9542 * val = node[2]
9543 * if not PyBytes_CheckExact(val): # <<<<<<<<<<<<<<
9544 * raise TypeError('Expected bytes for value not: %r' % type(val))
9545 * value = PyBytes_AS_STRING(val)
9546 */
9547 }
9548
9549 /* "breezy/bzr/_btree_serializer_pyx.pyx":900
9550 * if not PyBytes_CheckExact(val):
9551 * raise TypeError('Expected bytes for value not: %r' % type(val))
9552 * value = PyBytes_AS_STRING(val) # <<<<<<<<<<<<<<
9553 * value_len = PyBytes_GET_SIZE(val)
9554 * flat_len = (key_len + 1 + refs_len + 1 + value_len + 1)
9555 */
9556 __pyx_v_value = PyBytes_AS_STRING(__pyx_v_val);
9557
9558 /* "breezy/bzr/_btree_serializer_pyx.pyx":901
9559 * raise TypeError('Expected bytes for value not: %r' % type(val))
9560 * value = PyBytes_AS_STRING(val)
9561 * value_len = PyBytes_GET_SIZE(val) # <<<<<<<<<<<<<<
9562 * flat_len = (key_len + 1 + refs_len + 1 + value_len + 1)
9563 * line = PyBytes_FromStringAndSize(NULL, flat_len)
9564 */
9565 __pyx_v_value_len = PyBytes_GET_SIZE(__pyx_v_val);
9566
9567 /* "breezy/bzr/_btree_serializer_pyx.pyx":902
9568 * value = PyBytes_AS_STRING(val)
9569 * value_len = PyBytes_GET_SIZE(val)
9570 * flat_len = (key_len + 1 + refs_len + 1 + value_len + 1) # <<<<<<<<<<<<<<
9571 * line = PyBytes_FromStringAndSize(NULL, flat_len)
9572 * # Get a pointer to the new buffer
9573 */
9574 __pyx_v_flat_len = (((((__pyx_v_key_len + 1) + __pyx_v_refs_len) + 1) + __pyx_v_value_len) + 1);
9575
9576 /* "breezy/bzr/_btree_serializer_pyx.pyx":903
9577 * value_len = PyBytes_GET_SIZE(val)
9578 * flat_len = (key_len + 1 + refs_len + 1 + value_len + 1)
9579 * line = PyBytes_FromStringAndSize(NULL, flat_len) # <<<<<<<<<<<<<<
9580 * # Get a pointer to the new buffer
9581 * out = PyBytes_AsString(line)
9582 */
9583 __pyx_t_4 = PyBytes_FromStringAndSize(NULL, __pyx_v_flat_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 903, __pyx_L1_error)
9584 __Pyx_GOTREF(__pyx_t_4);
9585 __pyx_v_line = ((PyObject*)__pyx_t_4);
9586 __pyx_t_4 = 0;
9587
9588 /* "breezy/bzr/_btree_serializer_pyx.pyx":905
9589 * line = PyBytes_FromStringAndSize(NULL, flat_len)
9590 * # Get a pointer to the new buffer
9591 * out = PyBytes_AsString(line) # <<<<<<<<<<<<<<
9592 * memcpy(out, PyBytes_AsString(string_key), key_len)
9593 * out = out + key_len
9594 */
9595 __pyx_t_15 = PyBytes_AsString(__pyx_v_line); if (unlikely(__pyx_t_15 == ((char *)NULL))) __PYX_ERR(0, 905, __pyx_L1_error)
9596 __pyx_v_out = __pyx_t_15;
9597
9598 /* "breezy/bzr/_btree_serializer_pyx.pyx":906
9599 * # Get a pointer to the new buffer
9600 * out = PyBytes_AsString(line)
9601 * memcpy(out, PyBytes_AsString(string_key), key_len) # <<<<<<<<<<<<<<
9602 * out = out + key_len
9603 * out[0] = c'\0'
9604 */
9605 __pyx_t_15 = PyBytes_AsString(__pyx_v_string_key); if (unlikely(__pyx_t_15 == ((char *)NULL))) __PYX_ERR(0, 906, __pyx_L1_error)
9606 (void)(memcpy(__pyx_v_out, __pyx_t_15, __pyx_v_key_len));
9607
9608 /* "breezy/bzr/_btree_serializer_pyx.pyx":907
9609 * out = PyBytes_AsString(line)
9610 * memcpy(out, PyBytes_AsString(string_key), key_len)
9611 * out = out + key_len # <<<<<<<<<<<<<<
9612 * out[0] = c'\0'
9613 * out = out + 1
9614 */
9615 __pyx_v_out = (__pyx_v_out + __pyx_v_key_len);
9616
9617 /* "breezy/bzr/_btree_serializer_pyx.pyx":908
9618 * memcpy(out, PyBytes_AsString(string_key), key_len)
9619 * out = out + key_len
9620 * out[0] = c'\0' # <<<<<<<<<<<<<<
9621 * out = out + 1
9622 * if refs_len > 0:
9623 */
9624 (__pyx_v_out[0]) = '\x00';
9625
9626 /* "breezy/bzr/_btree_serializer_pyx.pyx":909
9627 * out = out + key_len
9628 * out[0] = c'\0'
9629 * out = out + 1 # <<<<<<<<<<<<<<
9630 * if refs_len > 0:
9631 * first_ref_list = 1
9632 */
9633 __pyx_v_out = (__pyx_v_out + 1);
9634
9635 /* "breezy/bzr/_btree_serializer_pyx.pyx":910
9636 * out[0] = c'\0'
9637 * out = out + 1
9638 * if refs_len > 0: # <<<<<<<<<<<<<<
9639 * first_ref_list = 1
9640 * for ref_list in ref_lists:
9641 */
9642 __pyx_t_1 = ((__pyx_v_refs_len > 0) != 0);
9643 if (__pyx_t_1) {
9644
9645 /* "breezy/bzr/_btree_serializer_pyx.pyx":911
9646 * out = out + 1
9647 * if refs_len > 0:
9648 * first_ref_list = 1 # <<<<<<<<<<<<<<
9649 * for ref_list in ref_lists:
9650 * if first_ref_list == 0:
9651 */
9652 __pyx_v_first_ref_list = 1;
9653
9654 /* "breezy/bzr/_btree_serializer_pyx.pyx":912
9655 * if refs_len > 0:
9656 * first_ref_list = 1
9657 * for ref_list in ref_lists: # <<<<<<<<<<<<<<
9658 * if first_ref_list == 0:
9659 * out[0] = c'\t'
9660 */
9661 if (unlikely(!__pyx_v_ref_lists)) { __Pyx_RaiseUnboundLocalError("ref_lists"); __PYX_ERR(0, 912, __pyx_L1_error) }
9662 if (likely(PyList_CheckExact(__pyx_v_ref_lists)) || PyTuple_CheckExact(__pyx_v_ref_lists)) {
9663 __pyx_t_4 = __pyx_v_ref_lists; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
9664 __pyx_t_7 = NULL;
9665 } else {
9666 __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_ref_lists); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 912, __pyx_L1_error)
9667 __Pyx_GOTREF(__pyx_t_4);
9668 __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 912, __pyx_L1_error)
9669 }
9670 for (;;) {
9671 if (likely(!__pyx_t_7)) {
9672 if (likely(PyList_CheckExact(__pyx_t_4))) {
9673 if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
9674 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9675 __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 912, __pyx_L1_error)
9676 #else
9677 __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 912, __pyx_L1_error)
9678 __Pyx_GOTREF(__pyx_t_3);
9679 #endif
9680 } else {
9681 if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
9682 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9683 __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 912, __pyx_L1_error)
9684 #else
9685 __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 912, __pyx_L1_error)
9686 __Pyx_GOTREF(__pyx_t_3);
9687 #endif
9688 }
9689 } else {
9690 __pyx_t_3 = __pyx_t_7(__pyx_t_4);
9691 if (unlikely(!__pyx_t_3)) {
9692 PyObject* exc_type = PyErr_Occurred();
9693 if (exc_type) {
9694 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
9695 else __PYX_ERR(0, 912, __pyx_L1_error)
9696 }
9697 break;
9698 }
9699 __Pyx_GOTREF(__pyx_t_3);
9700 }
9701 __Pyx_XDECREF_SET(__pyx_v_ref_list, __pyx_t_3);
9702 __pyx_t_3 = 0;
9703
9704 /* "breezy/bzr/_btree_serializer_pyx.pyx":913
9705 * first_ref_list = 1
9706 * for ref_list in ref_lists:
9707 * if first_ref_list == 0: # <<<<<<<<<<<<<<
9708 * out[0] = c'\t'
9709 * out = out + 1
9710 */
9711 __pyx_t_1 = ((__pyx_v_first_ref_list == 0) != 0);
9712 if (__pyx_t_1) {
9713
9714 /* "breezy/bzr/_btree_serializer_pyx.pyx":914
9715 * for ref_list in ref_lists:
9716 * if first_ref_list == 0:
9717 * out[0] = c'\t' # <<<<<<<<<<<<<<
9718 * out = out + 1
9719 * first_ref_list = 0
9720 */
9721 (__pyx_v_out[0]) = '\t';
9722
9723 /* "breezy/bzr/_btree_serializer_pyx.pyx":915
9724 * if first_ref_list == 0:
9725 * out[0] = c'\t'
9726 * out = out + 1 # <<<<<<<<<<<<<<
9727 * first_ref_list = 0
9728 * first_reference = 1
9729 */
9730 __pyx_v_out = (__pyx_v_out + 1);
9731
9732 /* "breezy/bzr/_btree_serializer_pyx.pyx":913
9733 * first_ref_list = 1
9734 * for ref_list in ref_lists:
9735 * if first_ref_list == 0: # <<<<<<<<<<<<<<
9736 * out[0] = c'\t'
9737 * out = out + 1
9738 */
9739 }
9740
9741 /* "breezy/bzr/_btree_serializer_pyx.pyx":916
9742 * out[0] = c'\t'
9743 * out = out + 1
9744 * first_ref_list = 0 # <<<<<<<<<<<<<<
9745 * first_reference = 1
9746 * for reference in ref_list:
9747 */
9748 __pyx_v_first_ref_list = 0;
9749
9750 /* "breezy/bzr/_btree_serializer_pyx.pyx":917
9751 * out = out + 1
9752 * first_ref_list = 0
9753 * first_reference = 1 # <<<<<<<<<<<<<<
9754 * for reference in ref_list:
9755 * if first_reference == 0:
9756 */
9757 __pyx_v_first_reference = 1;
9758
9759 /* "breezy/bzr/_btree_serializer_pyx.pyx":918
9760 * first_ref_list = 0
9761 * first_reference = 1
9762 * for reference in ref_list: # <<<<<<<<<<<<<<
9763 * if first_reference == 0:
9764 * out[0] = c'\r'
9765 */
9766 if (likely(PyList_CheckExact(__pyx_v_ref_list)) || PyTuple_CheckExact(__pyx_v_ref_list)) {
9767 __pyx_t_3 = __pyx_v_ref_list; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
9768 __pyx_t_9 = NULL;
9769 } else {
9770 __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_ref_list); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 918, __pyx_L1_error)
9771 __Pyx_GOTREF(__pyx_t_3);
9772 __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 918, __pyx_L1_error)
9773 }
9774 for (;;) {
9775 if (likely(!__pyx_t_9)) {
9776 if (likely(PyList_CheckExact(__pyx_t_3))) {
9777 if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
9778 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9779 __pyx_t_11 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_11); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 918, __pyx_L1_error)
9780 #else
9781 __pyx_t_11 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 918, __pyx_L1_error)
9782 __Pyx_GOTREF(__pyx_t_11);
9783 #endif
9784 } else {
9785 if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
9786 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9787 __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_11); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 918, __pyx_L1_error)
9788 #else
9789 __pyx_t_11 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 918, __pyx_L1_error)
9790 __Pyx_GOTREF(__pyx_t_11);
9791 #endif
9792 }
9793 } else {
9794 __pyx_t_11 = __pyx_t_9(__pyx_t_3);
9795 if (unlikely(!__pyx_t_11)) {
9796 PyObject* exc_type = PyErr_Occurred();
9797 if (exc_type) {
9798 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
9799 else __PYX_ERR(0, 918, __pyx_L1_error)
9800 }
9801 break;
9802 }
9803 __Pyx_GOTREF(__pyx_t_11);
9804 }
9805 __Pyx_XDECREF_SET(__pyx_v_reference, __pyx_t_11);
9806 __pyx_t_11 = 0;
9807
9808 /* "breezy/bzr/_btree_serializer_pyx.pyx":919
9809 * first_reference = 1
9810 * for reference in ref_list:
9811 * if first_reference == 0: # <<<<<<<<<<<<<<
9812 * out[0] = c'\r'
9813 * out = out + 1
9814 */
9815 __pyx_t_1 = ((__pyx_v_first_reference == 0) != 0);
9816 if (__pyx_t_1) {
9817
9818 /* "breezy/bzr/_btree_serializer_pyx.pyx":920
9819 * for reference in ref_list:
9820 * if first_reference == 0:
9821 * out[0] = c'\r' # <<<<<<<<<<<<<<
9822 * out = out + 1
9823 * first_reference = 0
9824 */
9825 (__pyx_v_out[0]) = '\r';
9826
9827 /* "breezy/bzr/_btree_serializer_pyx.pyx":921
9828 * if first_reference == 0:
9829 * out[0] = c'\r'
9830 * out = out + 1 # <<<<<<<<<<<<<<
9831 * first_reference = 0
9832 * next_len = len(reference)
9833 */
9834 __pyx_v_out = (__pyx_v_out + 1);
9835
9836 /* "breezy/bzr/_btree_serializer_pyx.pyx":919
9837 * first_reference = 1
9838 * for reference in ref_list:
9839 * if first_reference == 0: # <<<<<<<<<<<<<<
9840 * out[0] = c'\r'
9841 * out = out + 1
9842 */
9843 }
9844
9845 /* "breezy/bzr/_btree_serializer_pyx.pyx":922
9846 * out[0] = c'\r'
9847 * out = out + 1
9848 * first_reference = 0 # <<<<<<<<<<<<<<
9849 * next_len = len(reference)
9850 * for i from 0 <= i < next_len:
9851 */
9852 __pyx_v_first_reference = 0;
9853
9854 /* "breezy/bzr/_btree_serializer_pyx.pyx":923
9855 * out = out + 1
9856 * first_reference = 0
9857 * next_len = len(reference) # <<<<<<<<<<<<<<
9858 * for i from 0 <= i < next_len:
9859 * if i != 0:
9860 */
9861 __pyx_t_12 = PyObject_Length(__pyx_v_reference); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 923, __pyx_L1_error)
9862 __pyx_v_next_len = __pyx_t_12;
9863
9864 /* "breezy/bzr/_btree_serializer_pyx.pyx":924
9865 * first_reference = 0
9866 * next_len = len(reference)
9867 * for i from 0 <= i < next_len: # <<<<<<<<<<<<<<
9868 * if i != 0:
9869 * out[0] = c'\x00'
9870 */
9871 __pyx_t_12 = __pyx_v_next_len;
9872 for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_12; __pyx_v_i++) {
9873
9874 /* "breezy/bzr/_btree_serializer_pyx.pyx":925
9875 * next_len = len(reference)
9876 * for i from 0 <= i < next_len:
9877 * if i != 0: # <<<<<<<<<<<<<<
9878 * out[0] = c'\x00'
9879 * out = out + 1
9880 */
9881 __pyx_t_1 = ((__pyx_v_i != 0) != 0);
9882 if (__pyx_t_1) {
9883
9884 /* "breezy/bzr/_btree_serializer_pyx.pyx":926
9885 * for i from 0 <= i < next_len:
9886 * if i != 0:
9887 * out[0] = c'\x00' # <<<<<<<<<<<<<<
9888 * out = out + 1
9889 * ref_bit = reference[i]
9890 */
9891 (__pyx_v_out[0]) = '\x00';
9892
9893 /* "breezy/bzr/_btree_serializer_pyx.pyx":927
9894 * if i != 0:
9895 * out[0] = c'\x00'
9896 * out = out + 1 # <<<<<<<<<<<<<<
9897 * ref_bit = reference[i]
9898 * ref_bit_len = PyBytes_GET_SIZE(ref_bit)
9899 */
9900 __pyx_v_out = (__pyx_v_out + 1);
9901
9902 /* "breezy/bzr/_btree_serializer_pyx.pyx":925
9903 * next_len = len(reference)
9904 * for i from 0 <= i < next_len:
9905 * if i != 0: # <<<<<<<<<<<<<<
9906 * out[0] = c'\x00'
9907 * out = out + 1
9908 */
9909 }
9910
9911 /* "breezy/bzr/_btree_serializer_pyx.pyx":928
9912 * out[0] = c'\x00'
9913 * out = out + 1
9914 * ref_bit = reference[i] # <<<<<<<<<<<<<<
9915 * ref_bit_len = PyBytes_GET_SIZE(ref_bit)
9916 * memcpy(out, PyBytes_AS_STRING(ref_bit), ref_bit_len)
9917 */
9918 __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_reference, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 928, __pyx_L1_error)
9919 __Pyx_GOTREF(__pyx_t_11);
9920 __Pyx_XDECREF_SET(__pyx_v_ref_bit, __pyx_t_11);
9921 __pyx_t_11 = 0;
9922
9923 /* "breezy/bzr/_btree_serializer_pyx.pyx":929
9924 * out = out + 1
9925 * ref_bit = reference[i]
9926 * ref_bit_len = PyBytes_GET_SIZE(ref_bit) # <<<<<<<<<<<<<<
9927 * memcpy(out, PyBytes_AS_STRING(ref_bit), ref_bit_len)
9928 * out = out + ref_bit_len
9929 */
9930 __pyx_v_ref_bit_len = PyBytes_GET_SIZE(__pyx_v_ref_bit);
9931
9932 /* "breezy/bzr/_btree_serializer_pyx.pyx":930
9933 * ref_bit = reference[i]
9934 * ref_bit_len = PyBytes_GET_SIZE(ref_bit)
9935 * memcpy(out, PyBytes_AS_STRING(ref_bit), ref_bit_len) # <<<<<<<<<<<<<<
9936 * out = out + ref_bit_len
9937 * out[0] = c'\0'
9938 */
9939 (void)(memcpy(__pyx_v_out, PyBytes_AS_STRING(__pyx_v_ref_bit), __pyx_v_ref_bit_len));
9940
9941 /* "breezy/bzr/_btree_serializer_pyx.pyx":931
9942 * ref_bit_len = PyBytes_GET_SIZE(ref_bit)
9943 * memcpy(out, PyBytes_AS_STRING(ref_bit), ref_bit_len)
9944 * out = out + ref_bit_len # <<<<<<<<<<<<<<
9945 * out[0] = c'\0'
9946 * out = out + 1
9947 */
9948 __pyx_v_out = (__pyx_v_out + __pyx_v_ref_bit_len);
9949 }
9950
9951 /* "breezy/bzr/_btree_serializer_pyx.pyx":918
9952 * first_ref_list = 0
9953 * first_reference = 1
9954 * for reference in ref_list: # <<<<<<<<<<<<<<
9955 * if first_reference == 0:
9956 * out[0] = c'\r'
9957 */
9958 }
9959 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9960
9961 /* "breezy/bzr/_btree_serializer_pyx.pyx":912
9962 * if refs_len > 0:
9963 * first_ref_list = 1
9964 * for ref_list in ref_lists: # <<<<<<<<<<<<<<
9965 * if first_ref_list == 0:
9966 * out[0] = c'\t'
9967 */
9968 }
9969 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9970
9971 /* "breezy/bzr/_btree_serializer_pyx.pyx":910
9972 * out[0] = c'\0'
9973 * out = out + 1
9974 * if refs_len > 0: # <<<<<<<<<<<<<<
9975 * first_ref_list = 1
9976 * for ref_list in ref_lists:
9977 */
9978 }
9979
9980 /* "breezy/bzr/_btree_serializer_pyx.pyx":932
9981 * memcpy(out, PyBytes_AS_STRING(ref_bit), ref_bit_len)
9982 * out = out + ref_bit_len
9983 * out[0] = c'\0' # <<<<<<<<<<<<<<
9984 * out = out + 1
9985 * memcpy(out, value, value_len)
9986 */
9987 (__pyx_v_out[0]) = '\x00';
9988
9989 /* "breezy/bzr/_btree_serializer_pyx.pyx":933
9990 * out = out + ref_bit_len
9991 * out[0] = c'\0'
9992 * out = out + 1 # <<<<<<<<<<<<<<
9993 * memcpy(out, value, value_len)
9994 * out = out + value_len
9995 */
9996 __pyx_v_out = (__pyx_v_out + 1);
9997
9998 /* "breezy/bzr/_btree_serializer_pyx.pyx":934
9999 * out[0] = c'\0'
10000 * out = out + 1
10001 * memcpy(out, value, value_len) # <<<<<<<<<<<<<<
10002 * out = out + value_len
10003 * out[0] = c'\n'
10004 */
10005 (void)(memcpy(__pyx_v_out, __pyx_v_value, __pyx_v_value_len));
10006
10007 /* "breezy/bzr/_btree_serializer_pyx.pyx":935
10008 * out = out + 1
10009 * memcpy(out, value, value_len)
10010 * out = out + value_len # <<<<<<<<<<<<<<
10011 * out[0] = c'\n'
10012 * return string_key, line
10013 */
10014 __pyx_v_out = (__pyx_v_out + __pyx_v_value_len);
10015
10016 /* "breezy/bzr/_btree_serializer_pyx.pyx":936
10017 * memcpy(out, value, value_len)
10018 * out = out + value_len
10019 * out[0] = c'\n' # <<<<<<<<<<<<<<
10020 * return string_key, line
10021 */
10022 (__pyx_v_out[0]) = '\n';
10023
10024 /* "breezy/bzr/_btree_serializer_pyx.pyx":937
10025 * out = out + value_len
10026 * out[0] = c'\n'
10027 * return string_key, line # <<<<<<<<<<<<<<
10028 */
10029 __Pyx_XDECREF(__pyx_r);
10030 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 937, __pyx_L1_error)
10031 __Pyx_GOTREF(__pyx_t_4);
10032 __Pyx_INCREF(__pyx_v_string_key);
10033 __Pyx_GIVEREF(__pyx_v_string_key);
10034 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_string_key);
10035 __Pyx_INCREF(__pyx_v_line);
10036 __Pyx_GIVEREF(__pyx_v_line);
10037 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_line);
10038 __pyx_r = __pyx_t_4;
10039 __pyx_t_4 = 0;
10040 goto __pyx_L0;
10041
10042 /* "breezy/bzr/_btree_serializer_pyx.pyx":801
10043 *
10044 *
10045 * def _flatten_node(node, reference_lists): # <<<<<<<<<<<<<<
10046 * """Convert a node into the serialized form.
10047 *
10048 */
10049
10050 /* function exit code */
10051 __pyx_L1_error:;
10052 __Pyx_XDECREF(__pyx_t_3);
10053 __Pyx_XDECREF(__pyx_t_4);
10054 __Pyx_XDECREF(__pyx_t_10);
10055 __Pyx_XDECREF(__pyx_t_11);
10056 __Pyx_XDECREF(__pyx_t_14);
10057 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx._flatten_node", __pyx_clineno, __pyx_lineno, __pyx_filename);
10058 __pyx_r = NULL;
10059 __pyx_L0:;
10060 __Pyx_XDECREF(__pyx_v_string_key);
10061 __Pyx_XDECREF(__pyx_v_ref_lists);
10062 __Pyx_XDECREF(__pyx_v_ref_list);
10063 __Pyx_XDECREF(__pyx_v_reference);
10064 __Pyx_XDECREF(__pyx_v_ref_bit);
10065 __Pyx_XDECREF(__pyx_v_val);
10066 __Pyx_XDECREF(__pyx_v_line);
10067 __Pyx_XGIVEREF(__pyx_r);
10068 __Pyx_RefNannyFinishContext();
10069 return __pyx_r;
10070 }
10071
10072 /* "(tree fragment)":1
10073 * def __pyx_unpickle_BTreeLeafParser(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
10074 * cdef object __pyx_PickleError
10075 * cdef object __pyx_result
10076 */
10077
10078 /* Python wrapper */
10079 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15__pyx_unpickle_BTreeLeafParser(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
10080 static PyMethodDef __pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_15__pyx_unpickle_BTreeLeafParser = {"__pyx_unpickle_BTreeLeafParser", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15__pyx_unpickle_BTreeLeafParser, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15__pyx_unpickle_BTreeLeafParser(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)10081 static PyObject *__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15__pyx_unpickle_BTreeLeafParser(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
10082 PyObject *__pyx_v___pyx_type = 0;
10083 long __pyx_v___pyx_checksum;
10084 PyObject *__pyx_v___pyx_state = 0;
10085 int __pyx_lineno = 0;
10086 const char *__pyx_filename = NULL;
10087 int __pyx_clineno = 0;
10088 PyObject *__pyx_r = 0;
10089 __Pyx_RefNannyDeclarations
10090 __Pyx_RefNannySetupContext("__pyx_unpickle_BTreeLeafParser (wrapper)", 0);
10091 {
10092 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
10093 PyObject* values[3] = {0,0,0};
10094 if (unlikely(__pyx_kwds)) {
10095 Py_ssize_t kw_args;
10096 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
10097 switch (pos_args) {
10098 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10099 CYTHON_FALLTHROUGH;
10100 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10101 CYTHON_FALLTHROUGH;
10102 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10103 CYTHON_FALLTHROUGH;
10104 case 0: break;
10105 default: goto __pyx_L5_argtuple_error;
10106 }
10107 kw_args = PyDict_Size(__pyx_kwds);
10108 switch (pos_args) {
10109 case 0:
10110 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
10111 else goto __pyx_L5_argtuple_error;
10112 CYTHON_FALLTHROUGH;
10113 case 1:
10114 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
10115 else {
10116 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BTreeLeafParser", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
10117 }
10118 CYTHON_FALLTHROUGH;
10119 case 2:
10120 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
10121 else {
10122 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BTreeLeafParser", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
10123 }
10124 }
10125 if (unlikely(kw_args > 0)) {
10126 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_BTreeLeafParser") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
10127 }
10128 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
10129 goto __pyx_L5_argtuple_error;
10130 } else {
10131 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10132 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10133 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10134 }
10135 __pyx_v___pyx_type = values[0];
10136 __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
10137 __pyx_v___pyx_state = values[2];
10138 }
10139 goto __pyx_L4_argument_unpacking_done;
10140 __pyx_L5_argtuple_error:;
10141 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BTreeLeafParser", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
10142 __pyx_L3_error:;
10143 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.__pyx_unpickle_BTreeLeafParser", __pyx_clineno, __pyx_lineno, __pyx_filename);
10144 __Pyx_RefNannyFinishContext();
10145 return NULL;
10146 __pyx_L4_argument_unpacking_done:;
10147 __pyx_r = __pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_14__pyx_unpickle_BTreeLeafParser(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
10148
10149 /* function exit code */
10150 __Pyx_RefNannyFinishContext();
10151 return __pyx_r;
10152 }
10153
__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_14__pyx_unpickle_BTreeLeafParser(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v___pyx_type,long __pyx_v___pyx_checksum,PyObject * __pyx_v___pyx_state)10154 static PyObject *__pyx_pf_6breezy_3bzr_21_btree_serializer_pyx_14__pyx_unpickle_BTreeLeafParser(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
10155 PyObject *__pyx_v___pyx_PickleError = 0;
10156 PyObject *__pyx_v___pyx_result = 0;
10157 PyObject *__pyx_r = NULL;
10158 __Pyx_RefNannyDeclarations
10159 int __pyx_t_1;
10160 PyObject *__pyx_t_2 = NULL;
10161 PyObject *__pyx_t_3 = NULL;
10162 PyObject *__pyx_t_4 = NULL;
10163 PyObject *__pyx_t_5 = NULL;
10164 int __pyx_t_6;
10165 int __pyx_lineno = 0;
10166 const char *__pyx_filename = NULL;
10167 int __pyx_clineno = 0;
10168 __Pyx_RefNannySetupContext("__pyx_unpickle_BTreeLeafParser", 0);
10169
10170 /* "(tree fragment)":4
10171 * cdef object __pyx_PickleError
10172 * cdef object __pyx_result
10173 * if __pyx_checksum != 0x9b802a2: # <<<<<<<<<<<<<<
10174 * from pickle import PickleError as __pyx_PickleError
10175 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x9b802a2 = (_cur_str, _end_str, _header_found, _start, data, key_length, keys, ref_list_length))" % __pyx_checksum)
10176 */
10177 __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x9b802a2) != 0);
10178 if (__pyx_t_1) {
10179
10180 /* "(tree fragment)":5
10181 * cdef object __pyx_result
10182 * if __pyx_checksum != 0x9b802a2:
10183 * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
10184 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x9b802a2 = (_cur_str, _end_str, _header_found, _start, data, key_length, keys, ref_list_length))" % __pyx_checksum)
10185 * __pyx_result = BTreeLeafParser.__new__(__pyx_type)
10186 */
10187 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
10188 __Pyx_GOTREF(__pyx_t_2);
10189 __Pyx_INCREF(__pyx_n_s_PickleError);
10190 __Pyx_GIVEREF(__pyx_n_s_PickleError);
10191 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
10192 __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
10193 __Pyx_GOTREF(__pyx_t_3);
10194 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10195 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
10196 __Pyx_GOTREF(__pyx_t_2);
10197 __Pyx_INCREF(__pyx_t_2);
10198 __pyx_v___pyx_PickleError = __pyx_t_2;
10199 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10200 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10201
10202 /* "(tree fragment)":6
10203 * if __pyx_checksum != 0x9b802a2:
10204 * from pickle import PickleError as __pyx_PickleError
10205 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x9b802a2 = (_cur_str, _end_str, _header_found, _start, data, key_length, keys, ref_list_length))" % __pyx_checksum) # <<<<<<<<<<<<<<
10206 * __pyx_result = BTreeLeafParser.__new__(__pyx_type)
10207 * if __pyx_state is not None:
10208 */
10209 __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
10210 __Pyx_GOTREF(__pyx_t_2);
10211 __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x9b, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
10212 __Pyx_GOTREF(__pyx_t_4);
10213 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10214 __Pyx_INCREF(__pyx_v___pyx_PickleError);
10215 __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
10216 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
10217 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
10218 if (likely(__pyx_t_5)) {
10219 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
10220 __Pyx_INCREF(__pyx_t_5);
10221 __Pyx_INCREF(function);
10222 __Pyx_DECREF_SET(__pyx_t_2, function);
10223 }
10224 }
10225 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
10226 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
10227 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
10228 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
10229 __Pyx_GOTREF(__pyx_t_3);
10230 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10231 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
10232 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10233 __PYX_ERR(1, 6, __pyx_L1_error)
10234
10235 /* "(tree fragment)":4
10236 * cdef object __pyx_PickleError
10237 * cdef object __pyx_result
10238 * if __pyx_checksum != 0x9b802a2: # <<<<<<<<<<<<<<
10239 * from pickle import PickleError as __pyx_PickleError
10240 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x9b802a2 = (_cur_str, _end_str, _header_found, _start, data, key_length, keys, ref_list_length))" % __pyx_checksum)
10241 */
10242 }
10243
10244 /* "(tree fragment)":7
10245 * from pickle import PickleError as __pyx_PickleError
10246 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x9b802a2 = (_cur_str, _end_str, _header_found, _start, data, key_length, keys, ref_list_length))" % __pyx_checksum)
10247 * __pyx_result = BTreeLeafParser.__new__(__pyx_type) # <<<<<<<<<<<<<<
10248 * if __pyx_state is not None:
10249 * __pyx_unpickle_BTreeLeafParser__set_state(<BTreeLeafParser> __pyx_result, __pyx_state)
10250 */
10251 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
10252 __Pyx_GOTREF(__pyx_t_2);
10253 __pyx_t_4 = NULL;
10254 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
10255 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
10256 if (likely(__pyx_t_4)) {
10257 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
10258 __Pyx_INCREF(__pyx_t_4);
10259 __Pyx_INCREF(function);
10260 __Pyx_DECREF_SET(__pyx_t_2, function);
10261 }
10262 }
10263 __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
10264 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
10265 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
10266 __Pyx_GOTREF(__pyx_t_3);
10267 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10268 __pyx_v___pyx_result = __pyx_t_3;
10269 __pyx_t_3 = 0;
10270
10271 /* "(tree fragment)":8
10272 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x9b802a2 = (_cur_str, _end_str, _header_found, _start, data, key_length, keys, ref_list_length))" % __pyx_checksum)
10273 * __pyx_result = BTreeLeafParser.__new__(__pyx_type)
10274 * if __pyx_state is not None: # <<<<<<<<<<<<<<
10275 * __pyx_unpickle_BTreeLeafParser__set_state(<BTreeLeafParser> __pyx_result, __pyx_state)
10276 * return __pyx_result
10277 */
10278 __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
10279 __pyx_t_6 = (__pyx_t_1 != 0);
10280 if (__pyx_t_6) {
10281
10282 /* "(tree fragment)":9
10283 * __pyx_result = BTreeLeafParser.__new__(__pyx_type)
10284 * if __pyx_state is not None:
10285 * __pyx_unpickle_BTreeLeafParser__set_state(<BTreeLeafParser> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
10286 * return __pyx_result
10287 * cdef __pyx_unpickle_BTreeLeafParser__set_state(BTreeLeafParser __pyx_result, tuple __pyx_state):
10288 */
10289 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
10290 __pyx_t_3 = __pyx_f_6breezy_3bzr_21_btree_serializer_pyx___pyx_unpickle_BTreeLeafParser__set_state(((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
10291 __Pyx_GOTREF(__pyx_t_3);
10292 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10293
10294 /* "(tree fragment)":8
10295 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x9b802a2 = (_cur_str, _end_str, _header_found, _start, data, key_length, keys, ref_list_length))" % __pyx_checksum)
10296 * __pyx_result = BTreeLeafParser.__new__(__pyx_type)
10297 * if __pyx_state is not None: # <<<<<<<<<<<<<<
10298 * __pyx_unpickle_BTreeLeafParser__set_state(<BTreeLeafParser> __pyx_result, __pyx_state)
10299 * return __pyx_result
10300 */
10301 }
10302
10303 /* "(tree fragment)":10
10304 * if __pyx_state is not None:
10305 * __pyx_unpickle_BTreeLeafParser__set_state(<BTreeLeafParser> __pyx_result, __pyx_state)
10306 * return __pyx_result # <<<<<<<<<<<<<<
10307 * cdef __pyx_unpickle_BTreeLeafParser__set_state(BTreeLeafParser __pyx_result, tuple __pyx_state):
10308 * __pyx_result._cur_str = __pyx_state[0]; __pyx_result._end_str = __pyx_state[1]; __pyx_result._header_found = __pyx_state[2]; __pyx_result._start = __pyx_state[3]; __pyx_result.data = __pyx_state[4]; __pyx_result.key_length = __pyx_state[5]; __pyx_result.keys = __pyx_state[6]; __pyx_result.ref_list_length = __pyx_state[7]
10309 */
10310 __Pyx_XDECREF(__pyx_r);
10311 __Pyx_INCREF(__pyx_v___pyx_result);
10312 __pyx_r = __pyx_v___pyx_result;
10313 goto __pyx_L0;
10314
10315 /* "(tree fragment)":1
10316 * def __pyx_unpickle_BTreeLeafParser(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
10317 * cdef object __pyx_PickleError
10318 * cdef object __pyx_result
10319 */
10320
10321 /* function exit code */
10322 __pyx_L1_error:;
10323 __Pyx_XDECREF(__pyx_t_2);
10324 __Pyx_XDECREF(__pyx_t_3);
10325 __Pyx_XDECREF(__pyx_t_4);
10326 __Pyx_XDECREF(__pyx_t_5);
10327 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.__pyx_unpickle_BTreeLeafParser", __pyx_clineno, __pyx_lineno, __pyx_filename);
10328 __pyx_r = NULL;
10329 __pyx_L0:;
10330 __Pyx_XDECREF(__pyx_v___pyx_PickleError);
10331 __Pyx_XDECREF(__pyx_v___pyx_result);
10332 __Pyx_XGIVEREF(__pyx_r);
10333 __Pyx_RefNannyFinishContext();
10334 return __pyx_r;
10335 }
10336
10337 /* "(tree fragment)":11
10338 * __pyx_unpickle_BTreeLeafParser__set_state(<BTreeLeafParser> __pyx_result, __pyx_state)
10339 * return __pyx_result
10340 * cdef __pyx_unpickle_BTreeLeafParser__set_state(BTreeLeafParser __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
10341 * __pyx_result._cur_str = __pyx_state[0]; __pyx_result._end_str = __pyx_state[1]; __pyx_result._header_found = __pyx_state[2]; __pyx_result._start = __pyx_state[3]; __pyx_result.data = __pyx_state[4]; __pyx_result.key_length = __pyx_state[5]; __pyx_result.keys = __pyx_state[6]; __pyx_result.ref_list_length = __pyx_state[7]
10342 * if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):
10343 */
10344
__pyx_f_6breezy_3bzr_21_btree_serializer_pyx___pyx_unpickle_BTreeLeafParser__set_state(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser * __pyx_v___pyx_result,PyObject * __pyx_v___pyx_state)10345 static PyObject *__pyx_f_6breezy_3bzr_21_btree_serializer_pyx___pyx_unpickle_BTreeLeafParser__set_state(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
10346 PyObject *__pyx_r = NULL;
10347 __Pyx_RefNannyDeclarations
10348 PyObject *__pyx_t_1 = NULL;
10349 char *__pyx_t_2;
10350 int __pyx_t_3;
10351 int __pyx_t_4;
10352 Py_ssize_t __pyx_t_5;
10353 int __pyx_t_6;
10354 int __pyx_t_7;
10355 PyObject *__pyx_t_8 = NULL;
10356 PyObject *__pyx_t_9 = NULL;
10357 PyObject *__pyx_t_10 = NULL;
10358 int __pyx_lineno = 0;
10359 const char *__pyx_filename = NULL;
10360 int __pyx_clineno = 0;
10361 __Pyx_RefNannySetupContext("__pyx_unpickle_BTreeLeafParser__set_state", 0);
10362
10363 /* "(tree fragment)":12
10364 * return __pyx_result
10365 * cdef __pyx_unpickle_BTreeLeafParser__set_state(BTreeLeafParser __pyx_result, tuple __pyx_state):
10366 * __pyx_result._cur_str = __pyx_state[0]; __pyx_result._end_str = __pyx_state[1]; __pyx_result._header_found = __pyx_state[2]; __pyx_result._start = __pyx_state[3]; __pyx_result.data = __pyx_state[4]; __pyx_result.key_length = __pyx_state[5]; __pyx_result.keys = __pyx_state[6]; __pyx_result.ref_list_length = __pyx_state[7] # <<<<<<<<<<<<<<
10367 * if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):
10368 * __pyx_result.__dict__.update(__pyx_state[8])
10369 */
10370 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10371 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
10372 __PYX_ERR(1, 12, __pyx_L1_error)
10373 }
10374 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
10375 __Pyx_GOTREF(__pyx_t_1);
10376 __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
10377 __pyx_v___pyx_result->_cur_str = __pyx_t_2;
10378 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10379 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10380 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
10381 __PYX_ERR(1, 12, __pyx_L1_error)
10382 }
10383 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
10384 __Pyx_GOTREF(__pyx_t_1);
10385 __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
10386 __pyx_v___pyx_result->_end_str = __pyx_t_2;
10387 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10388 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10389 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
10390 __PYX_ERR(1, 12, __pyx_L1_error)
10391 }
10392 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
10393 __Pyx_GOTREF(__pyx_t_1);
10394 __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
10395 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10396 __pyx_v___pyx_result->_header_found = __pyx_t_3;
10397 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10398 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
10399 __PYX_ERR(1, 12, __pyx_L1_error)
10400 }
10401 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
10402 __Pyx_GOTREF(__pyx_t_1);
10403 __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
10404 __pyx_v___pyx_result->_start = __pyx_t_2;
10405 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10406 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10407 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
10408 __PYX_ERR(1, 12, __pyx_L1_error)
10409 }
10410 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
10411 __Pyx_GOTREF(__pyx_t_1);
10412 __Pyx_GIVEREF(__pyx_t_1);
10413 __Pyx_GOTREF(__pyx_v___pyx_result->data);
10414 __Pyx_DECREF(__pyx_v___pyx_result->data);
10415 __pyx_v___pyx_result->data = __pyx_t_1;
10416 __pyx_t_1 = 0;
10417 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10418 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
10419 __PYX_ERR(1, 12, __pyx_L1_error)
10420 }
10421 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
10422 __Pyx_GOTREF(__pyx_t_1);
10423 __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
10424 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10425 __pyx_v___pyx_result->key_length = __pyx_t_3;
10426 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10427 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
10428 __PYX_ERR(1, 12, __pyx_L1_error)
10429 }
10430 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
10431 __Pyx_GOTREF(__pyx_t_1);
10432 __Pyx_GIVEREF(__pyx_t_1);
10433 __Pyx_GOTREF(__pyx_v___pyx_result->keys);
10434 __Pyx_DECREF(__pyx_v___pyx_result->keys);
10435 __pyx_v___pyx_result->keys = __pyx_t_1;
10436 __pyx_t_1 = 0;
10437 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10438 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
10439 __PYX_ERR(1, 12, __pyx_L1_error)
10440 }
10441 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
10442 __Pyx_GOTREF(__pyx_t_1);
10443 __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
10444 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10445 __pyx_v___pyx_result->ref_list_length = __pyx_t_3;
10446
10447 /* "(tree fragment)":13
10448 * cdef __pyx_unpickle_BTreeLeafParser__set_state(BTreeLeafParser __pyx_result, tuple __pyx_state):
10449 * __pyx_result._cur_str = __pyx_state[0]; __pyx_result._end_str = __pyx_state[1]; __pyx_result._header_found = __pyx_state[2]; __pyx_result._start = __pyx_state[3]; __pyx_result.data = __pyx_state[4]; __pyx_result.key_length = __pyx_state[5]; __pyx_result.keys = __pyx_state[6]; __pyx_result.ref_list_length = __pyx_state[7]
10450 * if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
10451 * __pyx_result.__dict__.update(__pyx_state[8])
10452 */
10453 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10454 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
10455 __PYX_ERR(1, 13, __pyx_L1_error)
10456 }
10457 __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
10458 __pyx_t_6 = ((__pyx_t_5 > 8) != 0);
10459 if (__pyx_t_6) {
10460 } else {
10461 __pyx_t_4 = __pyx_t_6;
10462 goto __pyx_L4_bool_binop_done;
10463 }
10464 __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
10465 __pyx_t_7 = (__pyx_t_6 != 0);
10466 __pyx_t_4 = __pyx_t_7;
10467 __pyx_L4_bool_binop_done:;
10468 if (__pyx_t_4) {
10469
10470 /* "(tree fragment)":14
10471 * __pyx_result._cur_str = __pyx_state[0]; __pyx_result._end_str = __pyx_state[1]; __pyx_result._header_found = __pyx_state[2]; __pyx_result._start = __pyx_state[3]; __pyx_result.data = __pyx_state[4]; __pyx_result.key_length = __pyx_state[5]; __pyx_result.keys = __pyx_state[6]; __pyx_result.ref_list_length = __pyx_state[7]
10472 * if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):
10473 * __pyx_result.__dict__.update(__pyx_state[8]) # <<<<<<<<<<<<<<
10474 */
10475 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
10476 __Pyx_GOTREF(__pyx_t_8);
10477 __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 14, __pyx_L1_error)
10478 __Pyx_GOTREF(__pyx_t_9);
10479 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10480 if (unlikely(__pyx_v___pyx_state == Py_None)) {
10481 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
10482 __PYX_ERR(1, 14, __pyx_L1_error)
10483 }
10484 __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
10485 __Pyx_GOTREF(__pyx_t_8);
10486 __pyx_t_10 = NULL;
10487 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
10488 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
10489 if (likely(__pyx_t_10)) {
10490 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
10491 __Pyx_INCREF(__pyx_t_10);
10492 __Pyx_INCREF(function);
10493 __Pyx_DECREF_SET(__pyx_t_9, function);
10494 }
10495 }
10496 __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
10497 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
10498 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10499 if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
10500 __Pyx_GOTREF(__pyx_t_1);
10501 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
10502 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10503
10504 /* "(tree fragment)":13
10505 * cdef __pyx_unpickle_BTreeLeafParser__set_state(BTreeLeafParser __pyx_result, tuple __pyx_state):
10506 * __pyx_result._cur_str = __pyx_state[0]; __pyx_result._end_str = __pyx_state[1]; __pyx_result._header_found = __pyx_state[2]; __pyx_result._start = __pyx_state[3]; __pyx_result.data = __pyx_state[4]; __pyx_result.key_length = __pyx_state[5]; __pyx_result.keys = __pyx_state[6]; __pyx_result.ref_list_length = __pyx_state[7]
10507 * if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
10508 * __pyx_result.__dict__.update(__pyx_state[8])
10509 */
10510 }
10511
10512 /* "(tree fragment)":11
10513 * __pyx_unpickle_BTreeLeafParser__set_state(<BTreeLeafParser> __pyx_result, __pyx_state)
10514 * return __pyx_result
10515 * cdef __pyx_unpickle_BTreeLeafParser__set_state(BTreeLeafParser __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
10516 * __pyx_result._cur_str = __pyx_state[0]; __pyx_result._end_str = __pyx_state[1]; __pyx_result._header_found = __pyx_state[2]; __pyx_result._start = __pyx_state[3]; __pyx_result.data = __pyx_state[4]; __pyx_result.key_length = __pyx_state[5]; __pyx_result.keys = __pyx_state[6]; __pyx_result.ref_list_length = __pyx_state[7]
10517 * if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):
10518 */
10519
10520 /* function exit code */
10521 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10522 goto __pyx_L0;
10523 __pyx_L1_error:;
10524 __Pyx_XDECREF(__pyx_t_1);
10525 __Pyx_XDECREF(__pyx_t_8);
10526 __Pyx_XDECREF(__pyx_t_9);
10527 __Pyx_XDECREF(__pyx_t_10);
10528 __Pyx_AddTraceback("breezy.bzr._btree_serializer_pyx.__pyx_unpickle_BTreeLeafParser__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
10529 __pyx_r = 0;
10530 __pyx_L0:;
10531 __Pyx_XGIVEREF(__pyx_r);
10532 __Pyx_RefNannyFinishContext();
10533 return __pyx_r;
10534 }
10535
10536 /* "_str_helpers.pxd":27
10537 *
10538 *
10539 * cdef inline void* _my_memrchr(void *s, int c, size_t n): # cannot_raise # <<<<<<<<<<<<<<
10540 * # memrchr seems to be a GNU extension, so we have to implement it ourselves
10541 * cdef char *pos
10542 */
10543
__pyx_f_6breezy_3bzr_12_str_helpers__my_memrchr(void * __pyx_v_s,int __pyx_v_c,size_t __pyx_v_n)10544 static CYTHON_INLINE void *__pyx_f_6breezy_3bzr_12_str_helpers__my_memrchr(void *__pyx_v_s, int __pyx_v_c, size_t __pyx_v_n) {
10545 char *__pyx_v_pos;
10546 char *__pyx_v_start;
10547 void *__pyx_r;
10548 __Pyx_RefNannyDeclarations
10549 int __pyx_t_1;
10550 __Pyx_RefNannySetupContext("_my_memrchr", 0);
10551
10552 /* "_str_helpers.pxd":32
10553 * cdef char *start
10554 *
10555 * start = <char*>s # <<<<<<<<<<<<<<
10556 * pos = start + n - 1
10557 * while pos >= start:
10558 */
10559 __pyx_v_start = ((char *)__pyx_v_s);
10560
10561 /* "_str_helpers.pxd":33
10562 *
10563 * start = <char*>s
10564 * pos = start + n - 1 # <<<<<<<<<<<<<<
10565 * while pos >= start:
10566 * if pos[0] == c:
10567 */
10568 __pyx_v_pos = ((__pyx_v_start + __pyx_v_n) - 1);
10569
10570 /* "_str_helpers.pxd":34
10571 * start = <char*>s
10572 * pos = start + n - 1
10573 * while pos >= start: # <<<<<<<<<<<<<<
10574 * if pos[0] == c:
10575 * return <void*>pos
10576 */
10577 while (1) {
10578 __pyx_t_1 = ((__pyx_v_pos >= __pyx_v_start) != 0);
10579 if (!__pyx_t_1) break;
10580
10581 /* "_str_helpers.pxd":35
10582 * pos = start + n - 1
10583 * while pos >= start:
10584 * if pos[0] == c: # <<<<<<<<<<<<<<
10585 * return <void*>pos
10586 * pos = pos - 1
10587 */
10588 __pyx_t_1 = (((__pyx_v_pos[0]) == __pyx_v_c) != 0);
10589 if (__pyx_t_1) {
10590
10591 /* "_str_helpers.pxd":36
10592 * while pos >= start:
10593 * if pos[0] == c:
10594 * return <void*>pos # <<<<<<<<<<<<<<
10595 * pos = pos - 1
10596 * return NULL
10597 */
10598 __pyx_r = ((void *)__pyx_v_pos);
10599 goto __pyx_L0;
10600
10601 /* "_str_helpers.pxd":35
10602 * pos = start + n - 1
10603 * while pos >= start:
10604 * if pos[0] == c: # <<<<<<<<<<<<<<
10605 * return <void*>pos
10606 * pos = pos - 1
10607 */
10608 }
10609
10610 /* "_str_helpers.pxd":37
10611 * if pos[0] == c:
10612 * return <void*>pos
10613 * pos = pos - 1 # <<<<<<<<<<<<<<
10614 * return NULL
10615 *
10616 */
10617 __pyx_v_pos = (__pyx_v_pos - 1);
10618 }
10619
10620 /* "_str_helpers.pxd":38
10621 * return <void*>pos
10622 * pos = pos - 1
10623 * return NULL # <<<<<<<<<<<<<<
10624 *
10625 *
10626 */
10627 __pyx_r = NULL;
10628 goto __pyx_L0;
10629
10630 /* "_str_helpers.pxd":27
10631 *
10632 *
10633 * cdef inline void* _my_memrchr(void *s, int c, size_t n): # cannot_raise # <<<<<<<<<<<<<<
10634 * # memrchr seems to be a GNU extension, so we have to implement it ourselves
10635 * cdef char *pos
10636 */
10637
10638 /* function exit code */
10639 __pyx_L0:;
10640 __Pyx_RefNannyFinishContext();
10641 return __pyx_r;
10642 }
10643
10644 /* "_str_helpers.pxd":41
10645 *
10646 *
10647 * cdef inline object safe_string_from_size(char *s, Py_ssize_t size): # <<<<<<<<<<<<<<
10648 * if size < 0:
10649 * raise AssertionError(
10650 */
10651
__pyx_f_6breezy_3bzr_12_str_helpers_safe_string_from_size(char * __pyx_v_s,Py_ssize_t __pyx_v_size)10652 static CYTHON_INLINE PyObject *__pyx_f_6breezy_3bzr_12_str_helpers_safe_string_from_size(char *__pyx_v_s, Py_ssize_t __pyx_v_size) {
10653 PyObject *__pyx_r = NULL;
10654 __Pyx_RefNannyDeclarations
10655 int __pyx_t_1;
10656 PyObject *__pyx_t_2 = NULL;
10657 PyObject *__pyx_t_3 = NULL;
10658 int __pyx_lineno = 0;
10659 const char *__pyx_filename = NULL;
10660 int __pyx_clineno = 0;
10661 __Pyx_RefNannySetupContext("safe_string_from_size", 0);
10662
10663 /* "_str_helpers.pxd":42
10664 *
10665 * cdef inline object safe_string_from_size(char *s, Py_ssize_t size):
10666 * if size < 0: # <<<<<<<<<<<<<<
10667 * raise AssertionError(
10668 * 'tried to create a string with an invalid size: %d' % size)
10669 */
10670 __pyx_t_1 = ((__pyx_v_size < 0) != 0);
10671 if (unlikely(__pyx_t_1)) {
10672
10673 /* "_str_helpers.pxd":44
10674 * if size < 0:
10675 * raise AssertionError(
10676 * 'tried to create a string with an invalid size: %d' % size) # <<<<<<<<<<<<<<
10677 * return PyBytes_FromStringAndSize(s, size)
10678 *
10679 */
10680 __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 44, __pyx_L1_error)
10681 __Pyx_GOTREF(__pyx_t_2);
10682 __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_tried_to_create_a_string_with_an, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 44, __pyx_L1_error)
10683 __Pyx_GOTREF(__pyx_t_3);
10684 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10685
10686 /* "_str_helpers.pxd":43
10687 * cdef inline object safe_string_from_size(char *s, Py_ssize_t size):
10688 * if size < 0:
10689 * raise AssertionError( # <<<<<<<<<<<<<<
10690 * 'tried to create a string with an invalid size: %d' % size)
10691 * return PyBytes_FromStringAndSize(s, size)
10692 */
10693 __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AssertionError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 43, __pyx_L1_error)
10694 __Pyx_GOTREF(__pyx_t_2);
10695 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10696 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
10697 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10698 __PYX_ERR(2, 43, __pyx_L1_error)
10699
10700 /* "_str_helpers.pxd":42
10701 *
10702 * cdef inline object safe_string_from_size(char *s, Py_ssize_t size):
10703 * if size < 0: # <<<<<<<<<<<<<<
10704 * raise AssertionError(
10705 * 'tried to create a string with an invalid size: %d' % size)
10706 */
10707 }
10708
10709 /* "_str_helpers.pxd":45
10710 * raise AssertionError(
10711 * 'tried to create a string with an invalid size: %d' % size)
10712 * return PyBytes_FromStringAndSize(s, size) # <<<<<<<<<<<<<<
10713 *
10714 *
10715 */
10716 __Pyx_XDECREF(__pyx_r);
10717 __pyx_t_2 = PyBytes_FromStringAndSize(__pyx_v_s, __pyx_v_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 45, __pyx_L1_error)
10718 __Pyx_GOTREF(__pyx_t_2);
10719 __pyx_r = __pyx_t_2;
10720 __pyx_t_2 = 0;
10721 goto __pyx_L0;
10722
10723 /* "_str_helpers.pxd":41
10724 *
10725 *
10726 * cdef inline object safe_string_from_size(char *s, Py_ssize_t size): # <<<<<<<<<<<<<<
10727 * if size < 0:
10728 * raise AssertionError(
10729 */
10730
10731 /* function exit code */
10732 __pyx_L1_error:;
10733 __Pyx_XDECREF(__pyx_t_2);
10734 __Pyx_XDECREF(__pyx_t_3);
10735 __Pyx_AddTraceback("breezy.bzr._str_helpers.safe_string_from_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
10736 __pyx_r = 0;
10737 __pyx_L0:;
10738 __Pyx_XGIVEREF(__pyx_r);
10739 __Pyx_RefNannyFinishContext();
10740 return __pyx_r;
10741 }
10742
10743 /* "_str_helpers.pxd":48
10744 *
10745 *
10746 * cdef inline object safe_interned_string_from_size(char *s, Py_ssize_t size): # <<<<<<<<<<<<<<
10747 * if size < 0:
10748 * raise AssertionError(
10749 */
10750
__pyx_f_6breezy_3bzr_12_str_helpers_safe_interned_string_from_size(char * __pyx_v_s,Py_ssize_t __pyx_v_size)10751 static CYTHON_INLINE PyObject *__pyx_f_6breezy_3bzr_12_str_helpers_safe_interned_string_from_size(char *__pyx_v_s, Py_ssize_t __pyx_v_size) {
10752 PyObject *__pyx_r = NULL;
10753 __Pyx_RefNannyDeclarations
10754 int __pyx_t_1;
10755 PyObject *__pyx_t_2 = NULL;
10756 PyObject *__pyx_t_3 = NULL;
10757 int __pyx_lineno = 0;
10758 const char *__pyx_filename = NULL;
10759 int __pyx_clineno = 0;
10760 __Pyx_RefNannySetupContext("safe_interned_string_from_size", 0);
10761
10762 /* "_str_helpers.pxd":49
10763 *
10764 * cdef inline object safe_interned_string_from_size(char *s, Py_ssize_t size):
10765 * if size < 0: # <<<<<<<<<<<<<<
10766 * raise AssertionError(
10767 * 'tried to create a string with an invalid size: %d' % size)
10768 */
10769 __pyx_t_1 = ((__pyx_v_size < 0) != 0);
10770 if (unlikely(__pyx_t_1)) {
10771
10772 /* "_str_helpers.pxd":51
10773 * if size < 0:
10774 * raise AssertionError(
10775 * 'tried to create a string with an invalid size: %d' % size) # <<<<<<<<<<<<<<
10776 * return PyBytes_InternFromStringAndSize(s, size)
10777 */
10778 __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 51, __pyx_L1_error)
10779 __Pyx_GOTREF(__pyx_t_2);
10780 __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_tried_to_create_a_string_with_an, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 51, __pyx_L1_error)
10781 __Pyx_GOTREF(__pyx_t_3);
10782 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10783
10784 /* "_str_helpers.pxd":50
10785 * cdef inline object safe_interned_string_from_size(char *s, Py_ssize_t size):
10786 * if size < 0:
10787 * raise AssertionError( # <<<<<<<<<<<<<<
10788 * 'tried to create a string with an invalid size: %d' % size)
10789 * return PyBytes_InternFromStringAndSize(s, size)
10790 */
10791 __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AssertionError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 50, __pyx_L1_error)
10792 __Pyx_GOTREF(__pyx_t_2);
10793 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10794 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
10795 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10796 __PYX_ERR(2, 50, __pyx_L1_error)
10797
10798 /* "_str_helpers.pxd":49
10799 *
10800 * cdef inline object safe_interned_string_from_size(char *s, Py_ssize_t size):
10801 * if size < 0: # <<<<<<<<<<<<<<
10802 * raise AssertionError(
10803 * 'tried to create a string with an invalid size: %d' % size)
10804 */
10805 }
10806
10807 /* "_str_helpers.pxd":52
10808 * raise AssertionError(
10809 * 'tried to create a string with an invalid size: %d' % size)
10810 * return PyBytes_InternFromStringAndSize(s, size) # <<<<<<<<<<<<<<
10811 */
10812 __Pyx_XDECREF(__pyx_r);
10813 __pyx_t_2 = PyBytes_InternFromStringAndSize(__pyx_v_s, __pyx_v_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 52, __pyx_L1_error)
10814 __Pyx_GOTREF(__pyx_t_2);
10815 __pyx_r = __pyx_t_2;
10816 __pyx_t_2 = 0;
10817 goto __pyx_L0;
10818
10819 /* "_str_helpers.pxd":48
10820 *
10821 *
10822 * cdef inline object safe_interned_string_from_size(char *s, Py_ssize_t size): # <<<<<<<<<<<<<<
10823 * if size < 0:
10824 * raise AssertionError(
10825 */
10826
10827 /* function exit code */
10828 __pyx_L1_error:;
10829 __Pyx_XDECREF(__pyx_t_2);
10830 __Pyx_XDECREF(__pyx_t_3);
10831 __Pyx_AddTraceback("breezy.bzr._str_helpers.safe_interned_string_from_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
10832 __pyx_r = 0;
10833 __pyx_L0:;
10834 __Pyx_XGIVEREF(__pyx_r);
10835 __Pyx_RefNannyFinishContext();
10836 return __pyx_r;
10837 }
10838 static struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser;
10839
__pyx_tp_new_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)10840 static PyObject *__pyx_tp_new_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
10841 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *p;
10842 PyObject *o;
10843 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
10844 o = (*t->tp_alloc)(t, 0);
10845 } else {
10846 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
10847 }
10848 if (unlikely(!o)) return 0;
10849 p = ((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)o);
10850 p->__pyx_vtab = __pyx_vtabptr_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser;
10851 p->data = Py_None; Py_INCREF(Py_None);
10852 p->keys = Py_None; Py_INCREF(Py_None);
10853 return o;
10854 }
10855
__pyx_tp_dealloc_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser(PyObject * o)10856 static void __pyx_tp_dealloc_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser(PyObject *o) {
10857 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *p = (struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)o;
10858 #if CYTHON_USE_TP_FINALIZE
10859 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
10860 if (PyObject_CallFinalizerFromDealloc(o)) return;
10861 }
10862 #endif
10863 PyObject_GC_UnTrack(o);
10864 Py_CLEAR(p->data);
10865 Py_CLEAR(p->keys);
10866 (*Py_TYPE(o)->tp_free)(o);
10867 }
10868
__pyx_tp_traverse_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser(PyObject * o,visitproc v,void * a)10869 static int __pyx_tp_traverse_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser(PyObject *o, visitproc v, void *a) {
10870 int e;
10871 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *p = (struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)o;
10872 if (p->data) {
10873 e = (*v)(p->data, a); if (e) return e;
10874 }
10875 if (p->keys) {
10876 e = (*v)(p->keys, a); if (e) return e;
10877 }
10878 return 0;
10879 }
10880
__pyx_tp_clear_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser(PyObject * o)10881 static int __pyx_tp_clear_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser(PyObject *o) {
10882 PyObject* tmp;
10883 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *p = (struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *)o;
10884 tmp = ((PyObject*)p->data);
10885 p->data = Py_None; Py_INCREF(Py_None);
10886 Py_XDECREF(tmp);
10887 tmp = ((PyObject*)p->keys);
10888 p->keys = Py_None; Py_INCREF(Py_None);
10889 Py_XDECREF(tmp);
10890 return 0;
10891 }
10892
10893 static PyMethodDef __pyx_methods_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser[] = {
10894 {"parse", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_3parse, METH_NOARGS, 0},
10895 {"__reduce_cython__", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_5__reduce_cython__, METH_NOARGS, 0},
10896 {"__setstate_cython__", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_7__setstate_cython__, METH_O, 0},
10897 {0, 0, 0, 0}
10898 };
10899
10900 static PyTypeObject __pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser = {
10901 PyVarObject_HEAD_INIT(0, 0)
10902 "breezy.bzr._btree_serializer_pyx.BTreeLeafParser", /*tp_name*/
10903 sizeof(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser), /*tp_basicsize*/
10904 0, /*tp_itemsize*/
10905 __pyx_tp_dealloc_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser, /*tp_dealloc*/
10906 #if PY_VERSION_HEX < 0x030800b4
10907 0, /*tp_print*/
10908 #endif
10909 #if PY_VERSION_HEX >= 0x030800b4
10910 0, /*tp_vectorcall_offset*/
10911 #endif
10912 0, /*tp_getattr*/
10913 0, /*tp_setattr*/
10914 #if PY_MAJOR_VERSION < 3
10915 0, /*tp_compare*/
10916 #endif
10917 #if PY_MAJOR_VERSION >= 3
10918 0, /*tp_as_async*/
10919 #endif
10920 0, /*tp_repr*/
10921 0, /*tp_as_number*/
10922 0, /*tp_as_sequence*/
10923 0, /*tp_as_mapping*/
10924 0, /*tp_hash*/
10925 0, /*tp_call*/
10926 0, /*tp_str*/
10927 0, /*tp_getattro*/
10928 0, /*tp_setattro*/
10929 0, /*tp_as_buffer*/
10930 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
10931 "Parse the leaf nodes of a BTree index.\n\n :ivar data: The PyBytes 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*/
10932 __pyx_tp_traverse_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser, /*tp_traverse*/
10933 __pyx_tp_clear_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser, /*tp_clear*/
10934 0, /*tp_richcompare*/
10935 0, /*tp_weaklistoffset*/
10936 0, /*tp_iter*/
10937 0, /*tp_iternext*/
10938 __pyx_methods_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser, /*tp_methods*/
10939 0, /*tp_members*/
10940 0, /*tp_getset*/
10941 0, /*tp_base*/
10942 0, /*tp_dict*/
10943 0, /*tp_descr_get*/
10944 0, /*tp_descr_set*/
10945 0, /*tp_dictoffset*/
10946 __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_1__init__, /*tp_init*/
10947 0, /*tp_alloc*/
10948 __pyx_tp_new_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser, /*tp_new*/
10949 0, /*tp_free*/
10950 0, /*tp_is_gc*/
10951 0, /*tp_bases*/
10952 0, /*tp_mro*/
10953 0, /*tp_cache*/
10954 0, /*tp_subclasses*/
10955 0, /*tp_weaklist*/
10956 0, /*tp_del*/
10957 0, /*tp_version_tag*/
10958 #if PY_VERSION_HEX >= 0x030400a1
10959 0, /*tp_finalize*/
10960 #endif
10961 #if PY_VERSION_HEX >= 0x030800b1
10962 0, /*tp_vectorcall*/
10963 #endif
10964 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
10965 0, /*tp_print*/
10966 #endif
10967 };
10968 static struct __pyx_vtabstruct_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
10969
__pyx_tp_new_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)10970 static PyObject *__pyx_tp_new_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
10971 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *p;
10972 PyObject *o;
10973 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
10974 o = (*t->tp_alloc)(t, 0);
10975 } else {
10976 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
10977 }
10978 if (unlikely(!o)) return 0;
10979 p = ((struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)o);
10980 p->__pyx_vtab = __pyx_vtabptr_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
10981 p->last_key = Py_None; Py_INCREF(Py_None);
10982 return o;
10983 }
10984
__pyx_tp_dealloc_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject * o)10985 static void __pyx_tp_dealloc_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject *o) {
10986 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *p = (struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)o;
10987 #if CYTHON_USE_TP_FINALIZE
10988 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
10989 if (PyObject_CallFinalizerFromDealloc(o)) return;
10990 }
10991 #endif
10992 PyObject_GC_UnTrack(o);
10993 {
10994 PyObject *etype, *eval, *etb;
10995 PyErr_Fetch(&etype, &eval, &etb);
10996 __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
10997 __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_3__dealloc__(o);
10998 __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
10999 PyErr_Restore(etype, eval, etb);
11000 }
11001 Py_CLEAR(p->last_key);
11002 (*Py_TYPE(o)->tp_free)(o);
11003 }
11004
__pyx_tp_traverse_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject * o,visitproc v,void * a)11005 static int __pyx_tp_traverse_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject *o, visitproc v, void *a) {
11006 int e;
11007 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *p = (struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)o;
11008 if (p->last_key) {
11009 e = (*v)(p->last_key, a); if (e) return e;
11010 }
11011 return 0;
11012 }
11013
__pyx_tp_clear_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject * o)11014 static int __pyx_tp_clear_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject *o) {
11015 PyObject* tmp;
11016 struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *p = (struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *)o;
11017 tmp = ((PyObject*)p->last_key);
11018 p->last_key = Py_None; Py_INCREF(Py_None);
11019 Py_XDECREF(tmp);
11020 return 0;
11021 }
__pyx_sq_item_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject * o,Py_ssize_t i)11022 static PyObject *__pyx_sq_item_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode(PyObject *o, Py_ssize_t i) {
11023 PyObject *r;
11024 PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
11025 r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
11026 Py_DECREF(x);
11027 return r;
11028 }
11029
__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_min_key(PyObject * o,CYTHON_UNUSED void * x)11030 static PyObject *__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_min_key(PyObject *o, CYTHON_UNUSED void *x) {
11031 return __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7min_key_1__get__(o);
11032 }
11033
__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_max_key(PyObject * o,CYTHON_UNUSED void * x)11034 static PyObject *__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_max_key(PyObject *o, CYTHON_UNUSED void *x) {
11035 return __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7max_key_1__get__(o);
11036 }
11037
__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key(PyObject * o,CYTHON_UNUSED void * x)11038 static PyObject *__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key(PyObject *o, CYTHON_UNUSED void *x) {
11039 return __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_1__get__(o);
11040 }
11041
__pyx_setprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key(PyObject * o,PyObject * v,CYTHON_UNUSED void * x)11042 static int __pyx_setprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
11043 if (v) {
11044 return __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_3__set__(o, v);
11045 }
11046 else {
11047 return __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_8last_key_5__del__(o);
11048 }
11049 }
11050
__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records(PyObject * o,CYTHON_UNUSED void * x)11051 static PyObject *__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records(PyObject *o, CYTHON_UNUSED void *x) {
11052 return __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_1__get__(o);
11053 }
11054
__pyx_setprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records(PyObject * o,PyObject * v,CYTHON_UNUSED void * x)11055 static int __pyx_setprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
11056 if (v) {
11057 return __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11num_records_3__set__(o, v);
11058 }
11059 else {
11060 PyErr_SetString(PyExc_NotImplementedError, "__del__");
11061 return -1;
11062 }
11063 }
11064
__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift(PyObject * o,CYTHON_UNUSED void * x)11065 static PyObject *__pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift(PyObject *o, CYTHON_UNUSED void *x) {
11066 return __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_1__get__(o);
11067 }
11068
__pyx_setprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift(PyObject * o,PyObject * v,CYTHON_UNUSED void * x)11069 static int __pyx_setprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
11070 if (v) {
11071 return __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_12common_shift_3__set__(o, v);
11072 }
11073 else {
11074 PyErr_SetString(PyExc_NotImplementedError, "__del__");
11075 return -1;
11076 }
11077 }
11078
11079 static PyMethodDef __pyx_methods_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode[] = {
11080 {"__sizeof__", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_1__sizeof__, METH_NOARGS, 0},
11081 {"all_keys", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_13all_keys, METH_NOARGS, 0},
11082 {"all_items", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_15all_items, METH_NOARGS, 0},
11083 {"_get_offset_for_sha1", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_17_get_offset_for_sha1, METH_O, 0},
11084 {"_get_offsets", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_19_get_offsets, METH_NOARGS, 0},
11085 {"__reduce_cython__", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_21__reduce_cython__, METH_NOARGS, 0},
11086 {"__setstate_cython__", (PyCFunction)__pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_23__setstate_cython__, METH_O, 0},
11087 {0, 0, 0, 0}
11088 };
11089
11090 static struct PyGetSetDef __pyx_getsets_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode[] = {
11091 {(char *)"min_key", __pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_min_key, 0, (char *)0, 0},
11092 {(char *)"max_key", __pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_max_key, 0, (char *)0, 0},
11093 {(char *)"last_key", __pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key, __pyx_setprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_last_key, (char *)0, 0},
11094 {(char *)"num_records", __pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records, __pyx_setprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_num_records, (char *)0, 0},
11095 {(char *)"common_shift", __pyx_getprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift, __pyx_setprop_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_common_shift, (char *)0, 0},
11096 {0, 0, 0, 0, 0}
11097 };
11098
11099 static PySequenceMethods __pyx_tp_as_sequence_GCCHKSHA1LeafNode = {
11100 __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11__len__, /*sq_length*/
11101 0, /*sq_concat*/
11102 0, /*sq_repeat*/
11103 __pyx_sq_item_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*sq_item*/
11104 0, /*sq_slice*/
11105 0, /*sq_ass_item*/
11106 0, /*sq_ass_slice*/
11107 __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_7__contains__, /*sq_contains*/
11108 0, /*sq_inplace_concat*/
11109 0, /*sq_inplace_repeat*/
11110 };
11111
11112 static PyMappingMethods __pyx_tp_as_mapping_GCCHKSHA1LeafNode = {
11113 __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_11__len__, /*mp_length*/
11114 __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_9__getitem__, /*mp_subscript*/
11115 0, /*mp_ass_subscript*/
11116 };
11117
11118 static PyTypeObject __pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode = {
11119 PyVarObject_HEAD_INIT(0, 0)
11120 "breezy.bzr._btree_serializer_pyx.GCCHKSHA1LeafNode", /*tp_name*/
11121 sizeof(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode), /*tp_basicsize*/
11122 0, /*tp_itemsize*/
11123 __pyx_tp_dealloc_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_dealloc*/
11124 #if PY_VERSION_HEX < 0x030800b4
11125 0, /*tp_print*/
11126 #endif
11127 #if PY_VERSION_HEX >= 0x030800b4
11128 0, /*tp_vectorcall_offset*/
11129 #endif
11130 0, /*tp_getattr*/
11131 0, /*tp_setattr*/
11132 #if PY_MAJOR_VERSION < 3
11133 0, /*tp_compare*/
11134 #endif
11135 #if PY_MAJOR_VERSION >= 3
11136 0, /*tp_as_async*/
11137 #endif
11138 0, /*tp_repr*/
11139 0, /*tp_as_number*/
11140 &__pyx_tp_as_sequence_GCCHKSHA1LeafNode, /*tp_as_sequence*/
11141 &__pyx_tp_as_mapping_GCCHKSHA1LeafNode, /*tp_as_mapping*/
11142 0, /*tp_hash*/
11143 0, /*tp_call*/
11144 0, /*tp_str*/
11145 0, /*tp_getattro*/
11146 0, /*tp_setattro*/
11147 0, /*tp_as_buffer*/
11148 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
11149 "Track all the entries for a given leaf node.", /*tp_doc*/
11150 __pyx_tp_traverse_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_traverse*/
11151 __pyx_tp_clear_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_clear*/
11152 0, /*tp_richcompare*/
11153 0, /*tp_weaklistoffset*/
11154 0, /*tp_iter*/
11155 0, /*tp_iternext*/
11156 __pyx_methods_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_methods*/
11157 0, /*tp_members*/
11158 __pyx_getsets_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_getset*/
11159 0, /*tp_base*/
11160 0, /*tp_dict*/
11161 0, /*tp_descr_get*/
11162 0, /*tp_descr_set*/
11163 0, /*tp_dictoffset*/
11164 __pyx_pw_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode_5__init__, /*tp_init*/
11165 0, /*tp_alloc*/
11166 __pyx_tp_new_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode, /*tp_new*/
11167 0, /*tp_free*/
11168 0, /*tp_is_gc*/
11169 0, /*tp_bases*/
11170 0, /*tp_mro*/
11171 0, /*tp_cache*/
11172 0, /*tp_subclasses*/
11173 0, /*tp_weaklist*/
11174 0, /*tp_del*/
11175 0, /*tp_version_tag*/
11176 #if PY_VERSION_HEX >= 0x030400a1
11177 0, /*tp_finalize*/
11178 #endif
11179 #if PY_VERSION_HEX >= 0x030800b1
11180 0, /*tp_vectorcall*/
11181 #endif
11182 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
11183 0, /*tp_print*/
11184 #endif
11185 };
11186
11187 static PyMethodDef __pyx_methods[] = {
11188 {0, 0, 0, 0}
11189 };
11190
11191 #if PY_MAJOR_VERSION >= 3
11192 #if CYTHON_PEP489_MULTI_PHASE_INIT
11193 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
11194 static int __pyx_pymod_exec__btree_serializer_pyx(PyObject* module); /*proto*/
11195 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
11196 {Py_mod_create, (void*)__pyx_pymod_create},
11197 {Py_mod_exec, (void*)__pyx_pymod_exec__btree_serializer_pyx},
11198 {0, NULL}
11199 };
11200 #endif
11201
11202 static struct PyModuleDef __pyx_moduledef = {
11203 PyModuleDef_HEAD_INIT,
11204 "_btree_serializer_pyx",
11205 __pyx_k_Pyrex_extensions_to_btree_node_p, /* m_doc */
11206 #if CYTHON_PEP489_MULTI_PHASE_INIT
11207 0, /* m_size */
11208 #else
11209 -1, /* m_size */
11210 #endif
11211 __pyx_methods /* m_methods */,
11212 #if CYTHON_PEP489_MULTI_PHASE_INIT
11213 __pyx_moduledef_slots, /* m_slots */
11214 #else
11215 NULL, /* m_reload */
11216 #endif
11217 NULL, /* m_traverse */
11218 NULL, /* m_clear */
11219 NULL /* m_free */
11220 };
11221 #endif
11222 #ifndef CYTHON_SMALL_CODE
11223 #if defined(__clang__)
11224 #define CYTHON_SMALL_CODE
11225 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
11226 #define CYTHON_SMALL_CODE __attribute__((cold))
11227 #else
11228 #define CYTHON_SMALL_CODE
11229 #endif
11230 #endif
11231
11232 static __Pyx_StringTabEntry __pyx_string_tab[] = {
11233 {&__pyx_n_s_AssertionError, __pyx_k_AssertionError, sizeof(__pyx_k_AssertionError), 0, 0, 1, 1},
11234 {&__pyx_n_s_BTreeLeafParser, __pyx_k_BTreeLeafParser, sizeof(__pyx_k_BTreeLeafParser), 0, 0, 1, 1},
11235 {&__pyx_kp_u_Expected_bytes_for_value_not_r, __pyx_k_Expected_bytes_for_value_not_r, sizeof(__pyx_k_Expected_bytes_for_value_not_r), 0, 1, 0, 0},
11236 {&__pyx_kp_u_Failed_to_find_the_value_area, __pyx_k_Failed_to_find_the_value_area, sizeof(__pyx_k_Failed_to_find_the_value_area), 0, 1, 0, 0},
11237 {&__pyx_kp_u_Failed_to_parse_block_length, __pyx_k_Failed_to_parse_block_length, sizeof(__pyx_k_Failed_to_parse_block_length), 0, 1, 0, 0},
11238 {&__pyx_kp_u_Failed_to_parse_block_offset, __pyx_k_Failed_to_parse_block_offset, sizeof(__pyx_k_Failed_to_parse_block_offset), 0, 1, 0, 0},
11239 {&__pyx_kp_u_Failed_to_parse_record_end, __pyx_k_Failed_to_parse_record_end, sizeof(__pyx_k_Failed_to_parse_record_end), 0, 1, 0, 0},
11240 {&__pyx_n_s_GCCHKSHA1LeafNode, __pyx_k_GCCHKSHA1LeafNode, sizeof(__pyx_k_GCCHKSHA1LeafNode), 0, 0, 1, 1},
11241 {&__pyx_kp_s_Incompatible_checksums_s_vs_0x9b, __pyx_k_Incompatible_checksums_s_vs_0x9b, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x9b), 0, 0, 1, 0},
11242 {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
11243 {&__pyx_kp_u_Line_did_not_contain_40_hex_byte, __pyx_k_Line_did_not_contain_40_hex_byte, sizeof(__pyx_k_Line_did_not_contain_40_hex_byte), 0, 1, 0, 0},
11244 {&__pyx_kp_u_Node_did_not_start_with_type_lea, __pyx_k_Node_did_not_start_with_type_lea, sizeof(__pyx_k_Node_did_not_start_with_type_lea), 0, 1, 0, 0},
11245 {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
11246 {&__pyx_kp_u_Something_went_wrong_while_parsi, __pyx_k_Something_went_wrong_while_parsi, sizeof(__pyx_k_Something_went_wrong_while_parsi), 0, 1, 0, 0},
11247 {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
11248 {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
11249 {&__pyx_kp_u_We_expect_reference_bits_to_be_b, __pyx_k_We_expect_reference_bits_to_be_b, sizeof(__pyx_k_We_expect_reference_bits_to_be_b), 0, 1, 0, 0},
11250 {&__pyx_kp_u_We_expect_references_to_be_tuple, __pyx_k_We_expect_references_to_be_tuple, sizeof(__pyx_k_We_expect_references_to_be_tuple), 0, 1, 0, 0},
11251 {&__pyx_kp_u_We_expected_a_tuple_or_StaticTup, __pyx_k_We_expected_a_tuple_or_StaticTup, sizeof(__pyx_k_We_expected_a_tuple_or_StaticTup), 0, 1, 0, 0},
11252 {&__pyx_kp_u_We_failed_to_unhexlify, __pyx_k_We_failed_to_unhexlify, sizeof(__pyx_k_We_failed_to_unhexlify), 0, 1, 0, 0},
11253 {&__pyx_kp_u_We_only_support_parsing_byte_str, __pyx_k_We_only_support_parsing_byte_str, sizeof(__pyx_k_We_only_support_parsing_byte_str), 0, 1, 0, 0},
11254 {&__pyx_kp_u_With_ref_lists_we_expected_4_ent, __pyx_k_With_ref_lists_we_expected_4_ent, sizeof(__pyx_k_With_ref_lists_we_expected_4_ent), 0, 1, 0, 0},
11255 {&__pyx_kp_u_Without_ref_lists_we_need_at_lea, __pyx_k_Without_ref_lists_we_need_at_lea, sizeof(__pyx_k_Without_ref_lists_we_need_at_lea), 0, 1, 0, 0},
11256 {&__pyx_kp_b__20, __pyx_k__20, sizeof(__pyx_k__20), 0, 0, 0, 0},
11257 {&__pyx_n_s_as_bin, __pyx_k_as_bin, sizeof(__pyx_k_as_bin), 0, 0, 1, 1},
11258 {&__pyx_n_s_as_bin_sha, __pyx_k_as_bin_sha, sizeof(__pyx_k_as_bin_sha), 0, 0, 1, 1},
11259 {&__pyx_n_s_as_hex, __pyx_k_as_hex, sizeof(__pyx_k_as_hex), 0, 0, 1, 1},
11260 {&__pyx_kp_s_breezy_bzr__btree_serializer_pyx, __pyx_k_breezy_bzr__btree_serializer_pyx, sizeof(__pyx_k_breezy_bzr__btree_serializer_pyx), 0, 0, 1, 0},
11261 {&__pyx_n_s_breezy_bzr__btree_serializer_pyx_2, __pyx_k_breezy_bzr__btree_serializer_pyx_2, sizeof(__pyx_k_breezy_bzr__btree_serializer_pyx_2), 0, 0, 1, 1},
11262 {&__pyx_n_s_bytes, __pyx_k_bytes, sizeof(__pyx_k_bytes), 0, 0, 1, 1},
11263 {&__pyx_kp_u_bytes_did_not_start_with_type_le, __pyx_k_bytes_did_not_start_with_type_le, sizeof(__pyx_k_bytes_did_not_start_with_type_le), 0, 1, 0, 0},
11264 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
11265 {&__pyx_kp_b_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 0, 0},
11266 {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
11267 {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
11268 {&__pyx_n_s_first_ref_list, __pyx_k_first_ref_list, sizeof(__pyx_k_first_ref_list), 0, 0, 1, 1},
11269 {&__pyx_n_s_first_reference, __pyx_k_first_reference, sizeof(__pyx_k_first_reference), 0, 0, 1, 1},
11270 {&__pyx_n_s_flat_len, __pyx_k_flat_len, sizeof(__pyx_k_flat_len), 0, 0, 1, 1},
11271 {&__pyx_n_s_flatten_node, __pyx_k_flatten_node, sizeof(__pyx_k_flatten_node), 0, 0, 1, 1},
11272 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
11273 {&__pyx_n_s_have_reference_lists, __pyx_k_have_reference_lists, sizeof(__pyx_k_have_reference_lists), 0, 0, 1, 1},
11274 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
11275 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
11276 {&__pyx_kp_u_invalid_key_loop_counter_self_re, __pyx_k_invalid_key_loop_counter_self_re, sizeof(__pyx_k_invalid_key_loop_counter_self_re), 0, 1, 0, 0},
11277 {&__pyx_kp_u_invalid_key_wanted_segment_from, __pyx_k_invalid_key_wanted_segment_from, sizeof(__pyx_k_invalid_key_wanted_segment_from), 0, 1, 0, 0},
11278 {&__pyx_kp_u_is_not_present, __pyx_k_is_not_present, sizeof(__pyx_k_is_not_present), 0, 1, 0, 0},
11279 {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
11280 {&__pyx_kp_u_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 1, 0, 0},
11281 {&__pyx_n_s_key_2, __pyx_k_key_2, sizeof(__pyx_k_key_2), 0, 0, 1, 1},
11282 {&__pyx_n_s_key_len, __pyx_k_key_len, sizeof(__pyx_k_key_len), 0, 0, 1, 1},
11283 {&__pyx_n_s_key_length, __pyx_k_key_length, sizeof(__pyx_k_key_length), 0, 0, 1, 1},
11284 {&__pyx_kp_u_last_self__start, __pyx_k_last_self__start, sizeof(__pyx_k_last_self__start), 0, 1, 0, 0},
11285 {&__pyx_n_s_line, __pyx_k_line, sizeof(__pyx_k_line), 0, 0, 1, 1},
11286 {&__pyx_kp_u_line_did_not_start_with_sha1, __pyx_k_line_did_not_start_with_sha1, sizeof(__pyx_k_line_did_not_start_with_sha1), 0, 1, 0, 0},
11287 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
11288 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
11289 {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
11290 {&__pyx_n_s_next_len, __pyx_k_next_len, sizeof(__pyx_k_next_len), 0, 0, 1, 1},
11291 {&__pyx_n_s_node, __pyx_k_node, sizeof(__pyx_k_node), 0, 0, 1, 1},
11292 {&__pyx_n_s_node_len, __pyx_k_node_len, sizeof(__pyx_k_node_len), 0, 0, 1, 1},
11293 {&__pyx_kp_u_not_a_20_byte_binary_digest, __pyx_k_not_a_20_byte_binary_digest, sizeof(__pyx_k_not_a_20_byte_binary_digest), 0, 1, 0, 0},
11294 {&__pyx_kp_u_not_a_40_byte_hex_digest, __pyx_k_not_a_40_byte_hex_digest, sizeof(__pyx_k_not_a_40_byte_hex_digest), 0, 1, 0, 0},
11295 {&__pyx_kp_u_only_1_null_not_2_as_expected, __pyx_k_only_1_null_not_2_as_expected, sizeof(__pyx_k_only_1_null_not_2_as_expected), 0, 1, 0, 0},
11296 {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
11297 {&__pyx_n_s_parse, __pyx_k_parse, sizeof(__pyx_k_parse), 0, 0, 1, 1},
11298 {&__pyx_n_s_parse_into_chk, __pyx_k_parse_into_chk, sizeof(__pyx_k_parse_into_chk), 0, 0, 1, 1},
11299 {&__pyx_n_s_parse_leaf_lines, __pyx_k_parse_leaf_lines, sizeof(__pyx_k_parse_leaf_lines), 0, 0, 1, 1},
11300 {&__pyx_n_s_parser, __pyx_k_parser, sizeof(__pyx_k_parser), 0, 0, 1, 1},
11301 {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
11302 {&__pyx_n_s_py_hexlify, __pyx_k_py_hexlify, sizeof(__pyx_k_py_hexlify), 0, 0, 1, 1},
11303 {&__pyx_n_s_py_key_to_sha1, __pyx_k_py_key_to_sha1, sizeof(__pyx_k_py_key_to_sha1), 0, 0, 1, 1},
11304 {&__pyx_n_s_py_sha1_to_key, __pyx_k_py_sha1_to_key, sizeof(__pyx_k_py_sha1_to_key), 0, 0, 1, 1},
11305 {&__pyx_n_s_py_unhexlify, __pyx_k_py_unhexlify, sizeof(__pyx_k_py_unhexlify), 0, 0, 1, 1},
11306 {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
11307 {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
11308 {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
11309 {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
11310 {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
11311 {&__pyx_n_s_pyx_unpickle_BTreeLeafParser, __pyx_k_pyx_unpickle_BTreeLeafParser, sizeof(__pyx_k_pyx_unpickle_BTreeLeafParser), 0, 0, 1, 1},
11312 {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
11313 {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
11314 {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
11315 {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
11316 {&__pyx_n_s_ref_bit, __pyx_k_ref_bit, sizeof(__pyx_k_ref_bit), 0, 0, 1, 1},
11317 {&__pyx_n_s_ref_bit_len, __pyx_k_ref_bit_len, sizeof(__pyx_k_ref_bit_len), 0, 0, 1, 1},
11318 {&__pyx_n_s_ref_list, __pyx_k_ref_list, sizeof(__pyx_k_ref_list), 0, 0, 1, 1},
11319 {&__pyx_n_s_ref_list_length, __pyx_k_ref_list_length, sizeof(__pyx_k_ref_list_length), 0, 0, 1, 1},
11320 {&__pyx_n_s_ref_lists, __pyx_k_ref_lists, sizeof(__pyx_k_ref_lists), 0, 0, 1, 1},
11321 {&__pyx_n_s_reference, __pyx_k_reference, sizeof(__pyx_k_reference), 0, 0, 1, 1},
11322 {&__pyx_n_s_reference_lists, __pyx_k_reference_lists, sizeof(__pyx_k_reference_lists), 0, 0, 1, 1},
11323 {&__pyx_n_s_refs_len, __pyx_k_refs_len, sizeof(__pyx_k_refs_len), 0, 0, 1, 1},
11324 {&__pyx_kp_u_self_data_is_not_a_byte_string, __pyx_k_self_data_is_not_a_byte_string, sizeof(__pyx_k_self_data_is_not_a_byte_string), 0, 1, 0, 0},
11325 {&__pyx_kp_s_self_last_record_self_records_ca, __pyx_k_self_last_record_self_records_ca, sizeof(__pyx_k_self_last_record_self_records_ca), 0, 0, 1, 0},
11326 {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
11327 {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
11328 {&__pyx_n_s_sha1_bin, __pyx_k_sha1_bin, sizeof(__pyx_k_sha1_bin), 0, 0, 1, 1},
11329 {&__pyx_kp_u_sha1_bin_must_be_a_str_of_exactl, __pyx_k_sha1_bin_must_be_a_str_of_exactl, sizeof(__pyx_k_sha1_bin_must_be_a_str_of_exactl), 0, 1, 0, 0},
11330 {&__pyx_n_s_string_key, __pyx_k_string_key, sizeof(__pyx_k_string_key), 0, 0, 1, 1},
11331 {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
11332 {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
11333 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
11334 {&__pyx_kp_u_tried_to_create_a_string_with_an, __pyx_k_tried_to_create_a_string_with_an, sizeof(__pyx_k_tried_to_create_a_string_with_an), 0, 1, 0, 0},
11335 {&__pyx_kp_u_unexpected_reference_data_presen, __pyx_k_unexpected_reference_data_presen, sizeof(__pyx_k_unexpected_reference_data_presen), 0, 1, 0, 0},
11336 {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
11337 {&__pyx_n_s_val, __pyx_k_val, sizeof(__pyx_k_val), 0, 0, 1, 1},
11338 {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
11339 {&__pyx_n_s_value_len, __pyx_k_value_len, sizeof(__pyx_k_value_len), 0, 0, 1, 1},
11340 {0, 0, 0, 0, 0, 0, 0}
11341 };
__Pyx_InitCachedBuiltins(void)11342 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
11343 __pyx_builtin_AssertionError = __Pyx_GetBuiltinName(__pyx_n_s_AssertionError); if (!__pyx_builtin_AssertionError) __PYX_ERR(0, 153, __pyx_L1_error)
11344 __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 356, __pyx_L1_error)
11345 __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 616, __pyx_L1_error)
11346 __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 663, __pyx_L1_error)
11347 return 0;
11348 __pyx_L1_error:;
11349 return -1;
11350 }
11351
__Pyx_InitCachedConstants(void)11352 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
11353 __Pyx_RefNannyDeclarations
11354 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
11355
11356 /* "breezy/bzr/_btree_serializer_pyx.pyx":196
11357 * if last < self._start:
11358 * # Unexpected error condition - fail
11359 * raise AssertionError("last < self._start") # <<<<<<<<<<<<<<
11360 * if 0 == self._header_found:
11361 * # The first line in a leaf node is the header "type=leaf\n"
11362 */
11363 __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_last_self__start); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 196, __pyx_L1_error)
11364 __Pyx_GOTREF(__pyx_tuple_);
11365 __Pyx_GIVEREF(__pyx_tuple_);
11366
11367 /* "breezy/bzr/_btree_serializer_pyx.pyx":211
11368 * if temp_ptr == NULL:
11369 * # Invalid line
11370 * raise AssertionError("Failed to find the value area") # <<<<<<<<<<<<<<
11371 * else:
11372 * # Because of how conversions were done, we ended up with *lots* of
11373 */
11374 __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Failed_to_find_the_value_area); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 211, __pyx_L1_error)
11375 __Pyx_GOTREF(__pyx_tuple__2);
11376 __Pyx_GIVEREF(__pyx_tuple__2);
11377
11378 /* "breezy/bzr/_btree_serializer_pyx.pyx":245
11379 * if loop_counter != self.ref_list_length:
11380 * # Invalid line
11381 * raise AssertionError( # <<<<<<<<<<<<<<
11382 * "invalid key, loop_counter != self.ref_list_length")
11383 * else:
11384 */
11385 __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_invalid_key_loop_counter_self_re); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 245, __pyx_L1_error)
11386 __Pyx_GOTREF(__pyx_tuple__3);
11387 __Pyx_GIVEREF(__pyx_tuple__3);
11388
11389 /* "breezy/bzr/_btree_serializer_pyx.pyx":274
11390 * if last != self._start:
11391 * # unexpected reference data present
11392 * raise AssertionError("unexpected reference data present") # <<<<<<<<<<<<<<
11393 * node_value = StaticTuple(value, StaticTuple())
11394 * PyList_Append(self.keys, StaticTuple(key, node_value))
11395 */
11396 __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_unexpected_reference_data_presen); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 274, __pyx_L1_error)
11397 __Pyx_GOTREF(__pyx_tuple__4);
11398 __Pyx_GIVEREF(__pyx_tuple__4);
11399
11400 /* "breezy/bzr/_btree_serializer_pyx.pyx":282
11401 * cdef Py_ssize_t byte_count
11402 * if not PyBytes_CheckExact(self.data):
11403 * raise AssertionError('self.data is not a byte string.') # <<<<<<<<<<<<<<
11404 * byte_count = PyBytes_GET_SIZE(self.data)
11405 * self._cur_str = PyBytes_AS_STRING(self.data)
11406 */
11407 __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_self_data_is_not_a_byte_string); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 282, __pyx_L1_error)
11408 __Pyx_GOTREF(__pyx_tuple__5);
11409 __Pyx_GIVEREF(__pyx_tuple__5);
11410
11411 /* "breezy/bzr/_btree_serializer_pyx.pyx":356
11412 * """For the test infrastructure, just thunks to _unhexlify_sha1"""
11413 * if not PyBytes_CheckExact(as_hex) or PyBytes_GET_SIZE(as_hex) != 40:
11414 * raise ValueError('not a 40-byte hex digest') # <<<<<<<<<<<<<<
11415 * as_bin = PyBytes_FromStringAndSize(NULL, 20)
11416 * if _unhexlify_sha1(PyBytes_AS_STRING(as_hex), PyBytes_AS_STRING(as_bin)):
11417 */
11418 __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_not_a_40_byte_hex_digest); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 356, __pyx_L1_error)
11419 __Pyx_GOTREF(__pyx_tuple__6);
11420 __Pyx_GIVEREF(__pyx_tuple__6);
11421
11422 /* "breezy/bzr/_btree_serializer_pyx.pyx":379
11423 * """For test infrastructure, thunk to _hexlify_sha1"""
11424 * if len(as_bin) != 20 or not PyBytes_CheckExact(as_bin):
11425 * raise ValueError('not a 20-byte binary digest') # <<<<<<<<<<<<<<
11426 * as_hex = PyBytes_FromStringAndSize(NULL, 40)
11427 * _hexlify_sha1(PyBytes_AS_STRING(as_bin), PyBytes_AS_STRING(as_hex))
11428 */
11429 __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_not_a_20_byte_binary_digest); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 379, __pyx_L1_error)
11430 __Pyx_GOTREF(__pyx_tuple__7);
11431 __Pyx_GIVEREF(__pyx_tuple__7);
11432
11433 /* "breezy/bzr/_btree_serializer_pyx.pyx":453
11434 * """Test thunk to check the sha1 mapping."""
11435 * if not PyBytes_CheckExact(sha1_bin) or PyBytes_GET_SIZE(sha1_bin) != 20:
11436 * raise ValueError('sha1_bin must be a str of exactly 20 bytes') # <<<<<<<<<<<<<<
11437 * return _sha1_to_key(PyBytes_AS_STRING(sha1_bin))
11438 *
11439 */
11440 __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_sha1_bin_must_be_a_str_of_exactl); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 453, __pyx_L1_error)
11441 __Pyx_GOTREF(__pyx_tuple__8);
11442 __Pyx_GIVEREF(__pyx_tuple__8);
11443
11444 /* "breezy/bzr/_btree_serializer_pyx.pyx":663
11445 *
11446 * if not PyBytes_CheckExact(data):
11447 * raise TypeError('We only support parsing byte strings.') # <<<<<<<<<<<<<<
11448 * # Pass 1, count how many records there will be
11449 * n_bytes = PyBytes_GET_SIZE(data)
11450 */
11451 __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_We_only_support_parsing_byte_str); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 663, __pyx_L1_error)
11452 __Pyx_GOTREF(__pyx_tuple__9);
11453 __Pyx_GIVEREF(__pyx_tuple__9);
11454
11455 /* "breezy/bzr/_btree_serializer_pyx.pyx":670
11456 * if strncmp(c_bytes, b'type=leaf\n', 10):
11457 * raise ValueError("bytes did not start with 'type=leaf\\n': %r"
11458 * % (data[:10],)) # <<<<<<<<<<<<<<
11459 * c_cur = c_bytes + 10
11460 * num_records = self._count_records(c_cur, c_end)
11461 */
11462 __pyx_slice__10 = PySlice_New(Py_None, __pyx_int_10, Py_None); if (unlikely(!__pyx_slice__10)) __PYX_ERR(0, 670, __pyx_L1_error)
11463 __Pyx_GOTREF(__pyx_slice__10);
11464 __Pyx_GIVEREF(__pyx_slice__10);
11465
11466 /* "breezy/bzr/_btree_serializer_pyx.pyx":686
11467 * or c_cur != c_end
11468 * or cur_record != self.records + self.num_records):
11469 * raise ValueError('Something went wrong while parsing.') # <<<<<<<<<<<<<<
11470 * # Pass 3: build the offset map
11471 * self._compute_common()
11472 */
11473 __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_Something_went_wrong_while_parsi); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 686, __pyx_L1_error)
11474 __Pyx_GOTREF(__pyx_tuple__11);
11475 __Pyx_GIVEREF(__pyx_tuple__11);
11476
11477 /* "breezy/bzr/_btree_serializer_pyx.pyx":704
11478 * c_next = <char *>memchr(c_cur, c'\0', c_end - c_cur)
11479 * if c_next == NULL or (c_next - c_cur != 40):
11480 * raise ValueError('Line did not contain 40 hex bytes') # <<<<<<<<<<<<<<
11481 * if not _unhexlify_sha1(c_cur, cur_record.sha1):
11482 * raise ValueError('We failed to unhexlify')
11483 */
11484 __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_Line_did_not_contain_40_hex_byte); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 704, __pyx_L1_error)
11485 __Pyx_GOTREF(__pyx_tuple__12);
11486 __Pyx_GIVEREF(__pyx_tuple__12);
11487
11488 /* "breezy/bzr/_btree_serializer_pyx.pyx":706
11489 * raise ValueError('Line did not contain 40 hex bytes')
11490 * if not _unhexlify_sha1(c_cur, cur_record.sha1):
11491 * raise ValueError('We failed to unhexlify') # <<<<<<<<<<<<<<
11492 * c_cur = c_next + 1
11493 * if c_cur[0] != c'\0':
11494 */
11495 __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_u_We_failed_to_unhexlify); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 706, __pyx_L1_error)
11496 __Pyx_GOTREF(__pyx_tuple__13);
11497 __Pyx_GIVEREF(__pyx_tuple__13);
11498
11499 /* "breezy/bzr/_btree_serializer_pyx.pyx":709
11500 * c_cur = c_next + 1
11501 * if c_cur[0] != c'\0':
11502 * raise ValueError('only 1 null, not 2 as expected') # <<<<<<<<<<<<<<
11503 * c_cur = c_cur + 1
11504 * cur_record.block_offset = strtoull(c_cur, &c_next, 10)
11505 */
11506 __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_u_only_1_null_not_2_as_expected); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 709, __pyx_L1_error)
11507 __Pyx_GOTREF(__pyx_tuple__14);
11508 __Pyx_GIVEREF(__pyx_tuple__14);
11509
11510 /* "breezy/bzr/_btree_serializer_pyx.pyx":713
11511 * cur_record.block_offset = strtoull(c_cur, &c_next, 10)
11512 * if c_cur == c_next or c_next[0] != c' ':
11513 * raise ValueError('Failed to parse block offset') # <<<<<<<<<<<<<<
11514 * c_cur = c_next + 1
11515 * cur_record.block_length = strtoul(c_cur, &c_next, 10)
11516 */
11517 __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_Failed_to_parse_block_offset); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 713, __pyx_L1_error)
11518 __Pyx_GOTREF(__pyx_tuple__15);
11519 __Pyx_GIVEREF(__pyx_tuple__15);
11520
11521 /* "breezy/bzr/_btree_serializer_pyx.pyx":717
11522 * cur_record.block_length = strtoul(c_cur, &c_next, 10)
11523 * if c_cur == c_next or c_next[0] != c' ':
11524 * raise ValueError('Failed to parse block length') # <<<<<<<<<<<<<<
11525 * c_cur = c_next + 1
11526 * cur_record.record_start = strtoul(c_cur, &c_next, 10)
11527 */
11528 __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_Failed_to_parse_block_length); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 717, __pyx_L1_error)
11529 __Pyx_GOTREF(__pyx_tuple__16);
11530 __Pyx_GIVEREF(__pyx_tuple__16);
11531
11532 /* "breezy/bzr/_btree_serializer_pyx.pyx":725
11533 * cur_record.record_end = strtoul(c_cur, &c_next, 10)
11534 * if c_cur == c_next or c_next[0] != c'\n':
11535 * raise ValueError('Failed to parse record end') # <<<<<<<<<<<<<<
11536 * c_cur = c_next + 1
11537 * return c_cur
11538 */
11539 __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_Failed_to_parse_record_end); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 725, __pyx_L1_error)
11540 __Pyx_GOTREF(__pyx_tuple__17);
11541 __Pyx_GIVEREF(__pyx_tuple__17);
11542
11543 /* "(tree fragment)":2
11544 * def __reduce_cython__(self):
11545 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
11546 * def __setstate_cython__(self, __pyx_state):
11547 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
11548 */
11549 __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_self_last_record_self_records_ca); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 2, __pyx_L1_error)
11550 __Pyx_GOTREF(__pyx_tuple__18);
11551 __Pyx_GIVEREF(__pyx_tuple__18);
11552
11553 /* "(tree fragment)":4
11554 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling")
11555 * def __setstate_cython__(self, __pyx_state):
11556 * raise TypeError("self.last_record,self.records cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
11557 */
11558 __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_self_last_record_self_records_ca); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 4, __pyx_L1_error)
11559 __Pyx_GOTREF(__pyx_tuple__19);
11560 __Pyx_GIVEREF(__pyx_tuple__19);
11561
11562 /* "breezy/bzr/_btree_serializer_pyx.pyx":292
11563 *
11564 *
11565 * def _parse_leaf_lines(data, key_length, ref_list_length): # <<<<<<<<<<<<<<
11566 * parser = BTreeLeafParser(data, key_length, ref_list_length)
11567 * return parser.parse()
11568 */
11569 __pyx_tuple__21 = PyTuple_Pack(4, __pyx_n_s_data, __pyx_n_s_key_length, __pyx_n_s_ref_list_length, __pyx_n_s_parser); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 292, __pyx_L1_error)
11570 __Pyx_GOTREF(__pyx_tuple__21);
11571 __Pyx_GIVEREF(__pyx_tuple__21);
11572 __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_breezy_bzr__btree_serializer_pyx, __pyx_n_s_parse_leaf_lines, 292, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 292, __pyx_L1_error)
11573
11574 /* "breezy/bzr/_btree_serializer_pyx.pyx":353
11575 *
11576 *
11577 * def _py_unhexlify(as_hex): # <<<<<<<<<<<<<<
11578 * """For the test infrastructure, just thunks to _unhexlify_sha1"""
11579 * if not PyBytes_CheckExact(as_hex) or PyBytes_GET_SIZE(as_hex) != 40:
11580 */
11581 __pyx_tuple__23 = PyTuple_Pack(2, __pyx_n_s_as_hex, __pyx_n_s_as_bin); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 353, __pyx_L1_error)
11582 __Pyx_GOTREF(__pyx_tuple__23);
11583 __Pyx_GIVEREF(__pyx_tuple__23);
11584 __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_breezy_bzr__btree_serializer_pyx, __pyx_n_s_py_unhexlify, 353, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 353, __pyx_L1_error)
11585
11586 /* "breezy/bzr/_btree_serializer_pyx.pyx":376
11587 *
11588 *
11589 * def _py_hexlify(as_bin): # <<<<<<<<<<<<<<
11590 * """For test infrastructure, thunk to _hexlify_sha1"""
11591 * if len(as_bin) != 20 or not PyBytes_CheckExact(as_bin):
11592 */
11593 __pyx_tuple__25 = PyTuple_Pack(2, __pyx_n_s_as_bin, __pyx_n_s_as_hex); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 376, __pyx_L1_error)
11594 __Pyx_GOTREF(__pyx_tuple__25);
11595 __Pyx_GIVEREF(__pyx_tuple__25);
11596 __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_breezy_bzr__btree_serializer_pyx, __pyx_n_s_py_hexlify, 376, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 376, __pyx_L1_error)
11597
11598 /* "breezy/bzr/_btree_serializer_pyx.pyx":414
11599 *
11600 *
11601 * def _py_key_to_sha1(key): # <<<<<<<<<<<<<<
11602 * """Map a key to a simple sha1 string.
11603 *
11604 */
11605 __pyx_tuple__27 = PyTuple_Pack(2, __pyx_n_s_key_2, __pyx_n_s_as_bin_sha); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 414, __pyx_L1_error)
11606 __Pyx_GOTREF(__pyx_tuple__27);
11607 __Pyx_GIVEREF(__pyx_tuple__27);
11608 __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_breezy_bzr__btree_serializer_pyx, __pyx_n_s_py_key_to_sha1, 414, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 414, __pyx_L1_error)
11609
11610 /* "breezy/bzr/_btree_serializer_pyx.pyx":450
11611 *
11612 *
11613 * def _py_sha1_to_key(sha1_bin): # <<<<<<<<<<<<<<
11614 * """Test thunk to check the sha1 mapping."""
11615 * if not PyBytes_CheckExact(sha1_bin) or PyBytes_GET_SIZE(sha1_bin) != 20:
11616 */
11617 __pyx_tuple__29 = PyTuple_Pack(1, __pyx_n_s_sha1_bin); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 450, __pyx_L1_error)
11618 __Pyx_GOTREF(__pyx_tuple__29);
11619 __Pyx_GIVEREF(__pyx_tuple__29);
11620 __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_breezy_bzr__btree_serializer_pyx, __pyx_n_s_py_sha1_to_key, 450, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 450, __pyx_L1_error)
11621
11622 /* "breezy/bzr/_btree_serializer_pyx.pyx":794
11623 *
11624 *
11625 * def _parse_into_chk(bytes, key_length, ref_list_length): # <<<<<<<<<<<<<<
11626 * """Parse into a format optimized for chk records."""
11627 * assert key_length == 1
11628 */
11629 __pyx_tuple__31 = PyTuple_Pack(3, __pyx_n_s_bytes, __pyx_n_s_key_length, __pyx_n_s_ref_list_length); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 794, __pyx_L1_error)
11630 __Pyx_GOTREF(__pyx_tuple__31);
11631 __Pyx_GIVEREF(__pyx_tuple__31);
11632 __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_breezy_bzr__btree_serializer_pyx, __pyx_n_s_parse_into_chk, 794, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 794, __pyx_L1_error)
11633
11634 /* "breezy/bzr/_btree_serializer_pyx.pyx":801
11635 *
11636 *
11637 * def _flatten_node(node, reference_lists): # <<<<<<<<<<<<<<
11638 * """Convert a node into the serialized form.
11639 *
11640 */
11641 __pyx_tuple__33 = PyTuple_Pack(22, __pyx_n_s_node, __pyx_n_s_reference_lists, __pyx_n_s_have_reference_lists, __pyx_n_s_flat_len, __pyx_n_s_key_len, __pyx_n_s_node_len, __pyx_n_s_value, __pyx_n_s_value_len, __pyx_n_s_out, __pyx_n_s_refs_len, __pyx_n_s_next_len, __pyx_n_s_first_ref_list, __pyx_n_s_first_reference, __pyx_n_s_i, __pyx_n_s_ref_bit_len, __pyx_n_s_string_key, __pyx_n_s_ref_lists, __pyx_n_s_ref_list, __pyx_n_s_reference, __pyx_n_s_ref_bit, __pyx_n_s_val, __pyx_n_s_line); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 801, __pyx_L1_error)
11642 __Pyx_GOTREF(__pyx_tuple__33);
11643 __Pyx_GIVEREF(__pyx_tuple__33);
11644 __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(2, 0, 22, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_breezy_bzr__btree_serializer_pyx, __pyx_n_s_flatten_node, 801, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 801, __pyx_L1_error)
11645
11646 /* "(tree fragment)":1
11647 * def __pyx_unpickle_BTreeLeafParser(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
11648 * cdef object __pyx_PickleError
11649 * cdef object __pyx_result
11650 */
11651 __pyx_tuple__35 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(1, 1, __pyx_L1_error)
11652 __Pyx_GOTREF(__pyx_tuple__35);
11653 __Pyx_GIVEREF(__pyx_tuple__35);
11654 __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_BTreeLeafParser, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(1, 1, __pyx_L1_error)
11655 __Pyx_RefNannyFinishContext();
11656 return 0;
11657 __pyx_L1_error:;
11658 __Pyx_RefNannyFinishContext();
11659 return -1;
11660 }
11661
__Pyx_InitGlobals(void)11662 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
11663 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
11664 __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
11665 __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
11666 __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) __PYX_ERR(0, 1, __pyx_L1_error)
11667 __pyx_int_163054242 = PyInt_FromLong(163054242L); if (unlikely(!__pyx_int_163054242)) __PYX_ERR(0, 1, __pyx_L1_error)
11668 __pyx_int_2147483648 = PyInt_FromString((char *)"2147483648", 0, 0); if (unlikely(!__pyx_int_2147483648)) __PYX_ERR(0, 1, __pyx_L1_error)
11669 __pyx_int_4294967295 = PyInt_FromString((char *)"4294967295", 0, 0); if (unlikely(!__pyx_int_4294967295)) __PYX_ERR(0, 1, __pyx_L1_error)
11670 return 0;
11671 __pyx_L1_error:;
11672 return -1;
11673 }
11674
11675 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
11676 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
11677 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
11678 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
11679 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
11680 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
11681 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
11682
__Pyx_modinit_global_init_code(void)11683 static int __Pyx_modinit_global_init_code(void) {
11684 __Pyx_RefNannyDeclarations
11685 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
11686 /*--- Global init code ---*/
11687 __Pyx_RefNannyFinishContext();
11688 return 0;
11689 }
11690
__Pyx_modinit_variable_export_code(void)11691 static int __Pyx_modinit_variable_export_code(void) {
11692 __Pyx_RefNannyDeclarations
11693 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
11694 /*--- Variable export code ---*/
11695 __Pyx_RefNannyFinishContext();
11696 return 0;
11697 }
11698
__Pyx_modinit_function_export_code(void)11699 static int __Pyx_modinit_function_export_code(void) {
11700 __Pyx_RefNannyDeclarations
11701 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
11702 /*--- Function export code ---*/
11703 __Pyx_RefNannyFinishContext();
11704 return 0;
11705 }
11706
__Pyx_modinit_type_init_code(void)11707 static int __Pyx_modinit_type_init_code(void) {
11708 __Pyx_RefNannyDeclarations
11709 int __pyx_lineno = 0;
11710 const char *__pyx_filename = NULL;
11711 int __pyx_clineno = 0;
11712 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
11713 /*--- Type init code ---*/
11714 __pyx_vtabptr_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser = &__pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser;
11715 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser.extract_key = (PyObject *(*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *, char *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_extract_key;
11716 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser.process_line = (int (*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_15BTreeLeafParser_process_line;
11717 if (PyType_Ready(&__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
11718 #if PY_VERSION_HEX < 0x030800B1
11719 __pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser.tp_print = 0;
11720 #endif
11721 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser.tp_dictoffset && __pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser.tp_getattro == PyObject_GenericGetAttr)) {
11722 __pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser.tp_getattro = __Pyx_PyObject_GenericGetAttr;
11723 }
11724 if (__Pyx_SetVtable(__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser.tp_dict, __pyx_vtabptr_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
11725 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BTreeLeafParser, (PyObject *)&__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
11726 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
11727 __pyx_ptype_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser = &__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_BTreeLeafParser;
11728 __pyx_vtabptr_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode = &__pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
11729 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode._record_to_value_and_refs = (StaticTuple *(*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_value_and_refs;
11730 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode._record_to_item = (StaticTuple *(*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__record_to_item;
11731 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode._lookup_record = (__pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *(*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__lookup_record;
11732 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode._count_records = (int (*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *, char *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__count_records;
11733 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode._parse_bytes = (PyObject *(*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, PyObject *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_bytes;
11734 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode._parse_one_entry = (char *(*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *, char *, __pyx_t_6breezy_3bzr_21_btree_serializer_pyx_gc_chk_sha1_record *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__parse_one_entry;
11735 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode._offset_for_sha1 = (int (*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *, char *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__offset_for_sha1;
11736 __pyx_vtable_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode._compute_common = (PyObject *(*)(struct __pyx_obj_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode *))__pyx_f_6breezy_3bzr_21_btree_serializer_pyx_17GCCHKSHA1LeafNode__compute_common;
11737 if (PyType_Ready(&__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode) < 0) __PYX_ERR(0, 484, __pyx_L1_error)
11738 #if PY_VERSION_HEX < 0x030800B1
11739 __pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode.tp_print = 0;
11740 #endif
11741 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode.tp_dictoffset && __pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode.tp_getattro == PyObject_GenericGetAttr)) {
11742 __pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode.tp_getattro = __Pyx_PyObject_GenericGetAttr;
11743 }
11744 if (__Pyx_SetVtable(__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode.tp_dict, __pyx_vtabptr_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode) < 0) __PYX_ERR(0, 484, __pyx_L1_error)
11745 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_GCCHKSHA1LeafNode, (PyObject *)&__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode) < 0) __PYX_ERR(0, 484, __pyx_L1_error)
11746 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode) < 0) __PYX_ERR(0, 484, __pyx_L1_error)
11747 __pyx_ptype_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode = &__pyx_type_6breezy_3bzr_21_btree_serializer_pyx_GCCHKSHA1LeafNode;
11748 __Pyx_RefNannyFinishContext();
11749 return 0;
11750 __pyx_L1_error:;
11751 __Pyx_RefNannyFinishContext();
11752 return -1;
11753 }
11754
__Pyx_modinit_type_import_code(void)11755 static int __Pyx_modinit_type_import_code(void) {
11756 __Pyx_RefNannyDeclarations
11757 PyObject *__pyx_t_1 = NULL;
11758 int __pyx_lineno = 0;
11759 const char *__pyx_filename = NULL;
11760 int __pyx_clineno = 0;
11761 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
11762 /*--- Type import code ---*/
11763 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
11764 __Pyx_GOTREF(__pyx_t_1);
11765 __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
11766 #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
11767 sizeof(PyTypeObject),
11768 #else
11769 sizeof(PyHeapTypeObject),
11770 #endif
11771 __Pyx_ImportType_CheckSize_Warn);
11772 if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
11773 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11774 __pyx_t_1 = PyImport_ImportModule("breezy._static_tuple_c"); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 27, __pyx_L1_error)
11775 __Pyx_GOTREF(__pyx_t_1);
11776 __pyx_ptype_6breezy_15_static_tuple_c_StaticTuple = __Pyx_ImportType(__pyx_t_1, "breezy._static_tuple_c", "StaticTuple", sizeof(StaticTuple), __Pyx_ImportType_CheckSize_Warn);
11777 if (!__pyx_ptype_6breezy_15_static_tuple_c_StaticTuple) __PYX_ERR(4, 27, __pyx_L1_error)
11778 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11779 __Pyx_RefNannyFinishContext();
11780 return 0;
11781 __pyx_L1_error:;
11782 __Pyx_XDECREF(__pyx_t_1);
11783 __Pyx_RefNannyFinishContext();
11784 return -1;
11785 }
11786
__Pyx_modinit_variable_import_code(void)11787 static int __Pyx_modinit_variable_import_code(void) {
11788 __Pyx_RefNannyDeclarations
11789 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
11790 /*--- Variable import code ---*/
11791 __Pyx_RefNannyFinishContext();
11792 return 0;
11793 }
11794
__Pyx_modinit_function_import_code(void)11795 static int __Pyx_modinit_function_import_code(void) {
11796 __Pyx_RefNannyDeclarations
11797 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
11798 /*--- Function import code ---*/
11799 __Pyx_RefNannyFinishContext();
11800 return 0;
11801 }
11802
11803
11804 #ifndef CYTHON_NO_PYINIT_EXPORT
11805 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
11806 #elif PY_MAJOR_VERSION < 3
11807 #ifdef __cplusplus
11808 #define __Pyx_PyMODINIT_FUNC extern "C" void
11809 #else
11810 #define __Pyx_PyMODINIT_FUNC void
11811 #endif
11812 #else
11813 #ifdef __cplusplus
11814 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
11815 #else
11816 #define __Pyx_PyMODINIT_FUNC PyObject *
11817 #endif
11818 #endif
11819
11820
11821 #if PY_MAJOR_VERSION < 3
11822 __Pyx_PyMODINIT_FUNC init_btree_serializer_pyx(void) CYTHON_SMALL_CODE; /*proto*/
init_btree_serializer_pyx(void)11823 __Pyx_PyMODINIT_FUNC init_btree_serializer_pyx(void)
11824 #else
11825 __Pyx_PyMODINIT_FUNC PyInit__btree_serializer_pyx(void) CYTHON_SMALL_CODE; /*proto*/
11826 __Pyx_PyMODINIT_FUNC PyInit__btree_serializer_pyx(void)
11827 #if CYTHON_PEP489_MULTI_PHASE_INIT
11828 {
11829 return PyModuleDef_Init(&__pyx_moduledef);
11830 }
11831 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
11832 #if PY_VERSION_HEX >= 0x030700A1
11833 static PY_INT64_T main_interpreter_id = -1;
11834 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
11835 if (main_interpreter_id == -1) {
11836 main_interpreter_id = current_id;
11837 return (unlikely(current_id == -1)) ? -1 : 0;
11838 } else if (unlikely(main_interpreter_id != current_id))
11839 #else
11840 static PyInterpreterState *main_interpreter = NULL;
11841 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
11842 if (!main_interpreter) {
11843 main_interpreter = current_interpreter;
11844 } else if (unlikely(main_interpreter != current_interpreter))
11845 #endif
11846 {
11847 PyErr_SetString(
11848 PyExc_ImportError,
11849 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
11850 return -1;
11851 }
11852 return 0;
11853 }
11854 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
11855 PyObject *value = PyObject_GetAttrString(spec, from_name);
11856 int result = 0;
11857 if (likely(value)) {
11858 if (allow_none || value != Py_None) {
11859 result = PyDict_SetItemString(moddict, to_name, value);
11860 }
11861 Py_DECREF(value);
11862 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
11863 PyErr_Clear();
11864 } else {
11865 result = -1;
11866 }
11867 return result;
11868 }
11869 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
11870 PyObject *module = NULL, *moddict, *modname;
11871 if (__Pyx_check_single_interpreter())
11872 return NULL;
11873 if (__pyx_m)
11874 return __Pyx_NewRef(__pyx_m);
11875 modname = PyObject_GetAttrString(spec, "name");
11876 if (unlikely(!modname)) goto bad;
11877 module = PyModule_NewObject(modname);
11878 Py_DECREF(modname);
11879 if (unlikely(!module)) goto bad;
11880 moddict = PyModule_GetDict(module);
11881 if (unlikely(!moddict)) goto bad;
11882 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
11883 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
11884 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
11885 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
11886 return module;
11887 bad:
11888 Py_XDECREF(module);
11889 return NULL;
11890 }
11891
11892
11893 static CYTHON_SMALL_CODE int __pyx_pymod_exec__btree_serializer_pyx(PyObject *__pyx_pyinit_module)
11894 #endif
11895 #endif
11896 {
11897 PyObject *__pyx_t_1 = NULL;
11898 int __pyx_t_2;
11899 int __pyx_lineno = 0;
11900 const char *__pyx_filename = NULL;
11901 int __pyx_clineno = 0;
11902 __Pyx_RefNannyDeclarations
11903 #if CYTHON_PEP489_MULTI_PHASE_INIT
11904 if (__pyx_m) {
11905 if (__pyx_m == __pyx_pyinit_module) return 0;
11906 PyErr_SetString(PyExc_RuntimeError, "Module '_btree_serializer_pyx' has already been imported. Re-initialisation is not supported.");
11907 return -1;
11908 }
11909 #elif PY_MAJOR_VERSION >= 3
11910 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
11911 #endif
11912 #if CYTHON_REFNANNY
11913 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
11914 if (!__Pyx_RefNanny) {
11915 PyErr_Clear();
11916 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
11917 if (!__Pyx_RefNanny)
11918 Py_FatalError("failed to import 'refnanny' module");
11919 }
11920 #endif
11921 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__btree_serializer_pyx(void)", 0);
11922 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11923 #ifdef __Pxy_PyFrame_Initialize_Offsets
11924 __Pxy_PyFrame_Initialize_Offsets();
11925 #endif
11926 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
11927 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
11928 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
11929 #ifdef __Pyx_CyFunction_USED
11930 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11931 #endif
11932 #ifdef __Pyx_FusedFunction_USED
11933 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11934 #endif
11935 #ifdef __Pyx_Coroutine_USED
11936 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11937 #endif
11938 #ifdef __Pyx_Generator_USED
11939 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11940 #endif
11941 #ifdef __Pyx_AsyncGen_USED
11942 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11943 #endif
11944 #ifdef __Pyx_StopAsyncIteration_USED
11945 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11946 #endif
11947 /*--- Library function declarations ---*/
11948 /*--- Threads initialization code ---*/
11949 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
11950 #ifdef WITH_THREAD /* Python build with threading support? */
11951 PyEval_InitThreads();
11952 #endif
11953 #endif
11954 /*--- Module creation code ---*/
11955 #if CYTHON_PEP489_MULTI_PHASE_INIT
11956 __pyx_m = __pyx_pyinit_module;
11957 Py_INCREF(__pyx_m);
11958 #else
11959 #if PY_MAJOR_VERSION < 3
11960 __pyx_m = Py_InitModule4("_btree_serializer_pyx", __pyx_methods, __pyx_k_Pyrex_extensions_to_btree_node_p, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
11961 #else
11962 __pyx_m = PyModule_Create(&__pyx_moduledef);
11963 #endif
11964 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
11965 #endif
11966 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
11967 Py_INCREF(__pyx_d);
11968 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
11969 Py_INCREF(__pyx_b);
11970 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
11971 Py_INCREF(__pyx_cython_runtime);
11972 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
11973 /*--- Initialize various global constants etc. ---*/
11974 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11975 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
11976 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11977 #endif
11978 if (__pyx_module_is_main_breezy__bzr___btree_serializer_pyx) {
11979 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11980 }
11981 #if PY_MAJOR_VERSION >= 3
11982 {
11983 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
11984 if (!PyDict_GetItemString(modules, "breezy.bzr._btree_serializer_pyx")) {
11985 if (unlikely(PyDict_SetItemString(modules, "breezy.bzr._btree_serializer_pyx", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
11986 }
11987 }
11988 #endif
11989 /*--- Builtin init code ---*/
11990 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11991 /*--- Constants init code ---*/
11992 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11993 /*--- Global type/function init code ---*/
11994 (void)__Pyx_modinit_global_init_code();
11995 (void)__Pyx_modinit_variable_export_code();
11996 (void)__Pyx_modinit_function_export_code();
11997 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
11998 if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
11999 (void)__Pyx_modinit_variable_import_code();
12000 (void)__Pyx_modinit_function_import_code();
12001 /*--- Execution code ---*/
12002 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
12003 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12004 #endif
12005
12006 /* "breezy/bzr/_btree_serializer_pyx.pyx":83
12007 * )
12008 *
12009 * import sys # <<<<<<<<<<<<<<
12010 *
12011 *
12012 */
12013 __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
12014 __Pyx_GOTREF(__pyx_t_1);
12015 if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 83, __pyx_L1_error)
12016 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12017
12018 /* "breezy/bzr/_btree_serializer_pyx.pyx":87
12019 *
12020 * # This sets up the StaticTuple C_API functionality
12021 * import_static_tuple_c() # <<<<<<<<<<<<<<
12022 *
12023 *
12024 */
12025 __pyx_t_2 = import_static_tuple_c(); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 87, __pyx_L1_error)
12026
12027 /* "breezy/bzr/_btree_serializer_pyx.pyx":292
12028 *
12029 *
12030 * def _parse_leaf_lines(data, key_length, ref_list_length): # <<<<<<<<<<<<<<
12031 * parser = BTreeLeafParser(data, key_length, ref_list_length)
12032 * return parser.parse()
12033 */
12034 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_1_parse_leaf_lines, NULL, __pyx_n_s_breezy_bzr__btree_serializer_pyx_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error)
12035 __Pyx_GOTREF(__pyx_t_1);
12036 if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_leaf_lines, __pyx_t_1) < 0) __PYX_ERR(0, 292, __pyx_L1_error)
12037 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12038
12039 /* "breezy/bzr/_btree_serializer_pyx.pyx":314
12040 * cdef int _unhexbuf[256]
12041 * cdef char *_hexbuf
12042 * _hexbuf = b'0123456789abcdef' # <<<<<<<<<<<<<<
12043 *
12044 * cdef _populate_unhexbuf():
12045 */
12046 __pyx_v_6breezy_3bzr_21_btree_serializer_pyx__hexbuf = ((char *)"0123456789abcdef");
12047
12048 /* "breezy/bzr/_btree_serializer_pyx.pyx":326
12049 * for i from 10 <= i < 16: # ABCDEF => 10, 11, 12, 13, 14, 15, 16
12050 * _unhexbuf[(i - 10 + c'A')] = i
12051 * _populate_unhexbuf() # <<<<<<<<<<<<<<
12052 *
12053 *
12054 */
12055 __pyx_t_1 = __pyx_f_6breezy_3bzr_21_btree_serializer_pyx__populate_unhexbuf(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error)
12056 __Pyx_GOTREF(__pyx_t_1);
12057 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12058
12059 /* "breezy/bzr/_btree_serializer_pyx.pyx":353
12060 *
12061 *
12062 * def _py_unhexlify(as_hex): # <<<<<<<<<<<<<<
12063 * """For the test infrastructure, just thunks to _unhexlify_sha1"""
12064 * if not PyBytes_CheckExact(as_hex) or PyBytes_GET_SIZE(as_hex) != 40:
12065 */
12066 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_3_py_unhexlify, NULL, __pyx_n_s_breezy_bzr__btree_serializer_pyx_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L1_error)
12067 __Pyx_GOTREF(__pyx_t_1);
12068 if (PyDict_SetItem(__pyx_d, __pyx_n_s_py_unhexlify, __pyx_t_1) < 0) __PYX_ERR(0, 353, __pyx_L1_error)
12069 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12070
12071 /* "breezy/bzr/_btree_serializer_pyx.pyx":376
12072 *
12073 *
12074 * def _py_hexlify(as_bin): # <<<<<<<<<<<<<<
12075 * """For test infrastructure, thunk to _hexlify_sha1"""
12076 * if len(as_bin) != 20 or not PyBytes_CheckExact(as_bin):
12077 */
12078 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_5_py_hexlify, NULL, __pyx_n_s_breezy_bzr__btree_serializer_pyx_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 376, __pyx_L1_error)
12079 __Pyx_GOTREF(__pyx_t_1);
12080 if (PyDict_SetItem(__pyx_d, __pyx_n_s_py_hexlify, __pyx_t_1) < 0) __PYX_ERR(0, 376, __pyx_L1_error)
12081 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12082
12083 /* "breezy/bzr/_btree_serializer_pyx.pyx":414
12084 *
12085 *
12086 * def _py_key_to_sha1(key): # <<<<<<<<<<<<<<
12087 * """Map a key to a simple sha1 string.
12088 *
12089 */
12090 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_7_py_key_to_sha1, NULL, __pyx_n_s_breezy_bzr__btree_serializer_pyx_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
12091 __Pyx_GOTREF(__pyx_t_1);
12092 if (PyDict_SetItem(__pyx_d, __pyx_n_s_py_key_to_sha1, __pyx_t_1) < 0) __PYX_ERR(0, 414, __pyx_L1_error)
12093 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12094
12095 /* "breezy/bzr/_btree_serializer_pyx.pyx":450
12096 *
12097 *
12098 * def _py_sha1_to_key(sha1_bin): # <<<<<<<<<<<<<<
12099 * """Test thunk to check the sha1 mapping."""
12100 * if not PyBytes_CheckExact(sha1_bin) or PyBytes_GET_SIZE(sha1_bin) != 20:
12101 */
12102 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_9_py_sha1_to_key, NULL, __pyx_n_s_breezy_bzr__btree_serializer_pyx_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
12103 __Pyx_GOTREF(__pyx_t_1);
12104 if (PyDict_SetItem(__pyx_d, __pyx_n_s_py_sha1_to_key, __pyx_t_1) < 0) __PYX_ERR(0, 450, __pyx_L1_error)
12105 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12106
12107 /* "breezy/bzr/_btree_serializer_pyx.pyx":794
12108 *
12109 *
12110 * def _parse_into_chk(bytes, key_length, ref_list_length): # <<<<<<<<<<<<<<
12111 * """Parse into a format optimized for chk records."""
12112 * assert key_length == 1
12113 */
12114 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_11_parse_into_chk, NULL, __pyx_n_s_breezy_bzr__btree_serializer_pyx_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 794, __pyx_L1_error)
12115 __Pyx_GOTREF(__pyx_t_1);
12116 if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_into_chk, __pyx_t_1) < 0) __PYX_ERR(0, 794, __pyx_L1_error)
12117 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12118
12119 /* "breezy/bzr/_btree_serializer_pyx.pyx":801
12120 *
12121 *
12122 * def _flatten_node(node, reference_lists): # <<<<<<<<<<<<<<
12123 * """Convert a node into the serialized form.
12124 *
12125 */
12126 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_13_flatten_node, NULL, __pyx_n_s_breezy_bzr__btree_serializer_pyx_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 801, __pyx_L1_error)
12127 __Pyx_GOTREF(__pyx_t_1);
12128 if (PyDict_SetItem(__pyx_d, __pyx_n_s_flatten_node, __pyx_t_1) < 0) __PYX_ERR(0, 801, __pyx_L1_error)
12129 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12130
12131 /* "(tree fragment)":1
12132 * def __pyx_unpickle_BTreeLeafParser(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
12133 * cdef object __pyx_PickleError
12134 * cdef object __pyx_result
12135 */
12136 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6breezy_3bzr_21_btree_serializer_pyx_15__pyx_unpickle_BTreeLeafParser, NULL, __pyx_n_s_breezy_bzr__btree_serializer_pyx_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
12137 __Pyx_GOTREF(__pyx_t_1);
12138 if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_BTreeLeafParser, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
12139 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12140
12141 /* "breezy/bzr/_btree_serializer_pyx.pyx":1
12142 * # Copyright (C) 2008, 2009, 2010 Canonical Ltd # <<<<<<<<<<<<<<
12143 * #
12144 * # This program is free software; you can redistribute it and/or modify
12145 */
12146 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
12147 __Pyx_GOTREF(__pyx_t_1);
12148 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12149 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12150
12151 /* "_str_helpers.pxd":48
12152 *
12153 *
12154 * cdef inline object safe_interned_string_from_size(char *s, Py_ssize_t size): # <<<<<<<<<<<<<<
12155 * if size < 0:
12156 * raise AssertionError(
12157 */
12158
12159 /*--- Wrapped vars code ---*/
12160
12161 goto __pyx_L0;
12162 __pyx_L1_error:;
12163 __Pyx_XDECREF(__pyx_t_1);
12164 if (__pyx_m) {
12165 if (__pyx_d) {
12166 __Pyx_AddTraceback("init breezy.bzr._btree_serializer_pyx", __pyx_clineno, __pyx_lineno, __pyx_filename);
12167 }
12168 Py_CLEAR(__pyx_m);
12169 } else if (!PyErr_Occurred()) {
12170 PyErr_SetString(PyExc_ImportError, "init breezy.bzr._btree_serializer_pyx");
12171 }
12172 __pyx_L0:;
12173 __Pyx_RefNannyFinishContext();
12174 #if CYTHON_PEP489_MULTI_PHASE_INIT
12175 return (__pyx_m != NULL) ? 0 : -1;
12176 #elif PY_MAJOR_VERSION >= 3
12177 return __pyx_m;
12178 #else
12179 return;
12180 #endif
12181 }
12182
12183 /* --- Runtime support code --- */
12184 /* Refnanny */
12185 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)12186 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
12187 PyObject *m = NULL, *p = NULL;
12188 void *r = NULL;
12189 m = PyImport_ImportModule(modname);
12190 if (!m) goto end;
12191 p = PyObject_GetAttrString(m, "RefNannyAPI");
12192 if (!p) goto end;
12193 r = PyLong_AsVoidPtr(p);
12194 end:
12195 Py_XDECREF(p);
12196 Py_XDECREF(m);
12197 return (__Pyx_RefNannyAPIStruct *)r;
12198 }
12199 #endif
12200
12201 /* PyObjectGetAttrStr */
12202 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)12203 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
12204 PyTypeObject* tp = Py_TYPE(obj);
12205 if (likely(tp->tp_getattro))
12206 return tp->tp_getattro(obj, attr_name);
12207 #if PY_MAJOR_VERSION < 3
12208 if (likely(tp->tp_getattr))
12209 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
12210 #endif
12211 return PyObject_GetAttr(obj, attr_name);
12212 }
12213 #endif
12214
12215 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)12216 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
12217 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
12218 if (unlikely(!result)) {
12219 PyErr_Format(PyExc_NameError,
12220 #if PY_MAJOR_VERSION >= 3
12221 "name '%U' is not defined", name);
12222 #else
12223 "name '%.200s' is not defined", PyString_AS_STRING(name));
12224 #endif
12225 }
12226 return result;
12227 }
12228
12229 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)12230 static void __Pyx_RaiseArgtupleInvalid(
12231 const char* func_name,
12232 int exact,
12233 Py_ssize_t num_min,
12234 Py_ssize_t num_max,
12235 Py_ssize_t num_found)
12236 {
12237 Py_ssize_t num_expected;
12238 const char *more_or_less;
12239 if (num_found < num_min) {
12240 num_expected = num_min;
12241 more_or_less = "at least";
12242 } else {
12243 num_expected = num_max;
12244 more_or_less = "at most";
12245 }
12246 if (exact) {
12247 more_or_less = "exactly";
12248 }
12249 PyErr_Format(PyExc_TypeError,
12250 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
12251 func_name, more_or_less, num_expected,
12252 (num_expected == 1) ? "" : "s", num_found);
12253 }
12254
12255 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)12256 static void __Pyx_RaiseDoubleKeywordsError(
12257 const char* func_name,
12258 PyObject* kw_name)
12259 {
12260 PyErr_Format(PyExc_TypeError,
12261 #if PY_MAJOR_VERSION >= 3
12262 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
12263 #else
12264 "%s() got multiple values for keyword argument '%s'", func_name,
12265 PyString_AsString(kw_name));
12266 #endif
12267 }
12268
12269 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)12270 static int __Pyx_ParseOptionalKeywords(
12271 PyObject *kwds,
12272 PyObject **argnames[],
12273 PyObject *kwds2,
12274 PyObject *values[],
12275 Py_ssize_t num_pos_args,
12276 const char* function_name)
12277 {
12278 PyObject *key = 0, *value = 0;
12279 Py_ssize_t pos = 0;
12280 PyObject*** name;
12281 PyObject*** first_kw_arg = argnames + num_pos_args;
12282 while (PyDict_Next(kwds, &pos, &key, &value)) {
12283 name = first_kw_arg;
12284 while (*name && (**name != key)) name++;
12285 if (*name) {
12286 values[name-argnames] = value;
12287 continue;
12288 }
12289 name = first_kw_arg;
12290 #if PY_MAJOR_VERSION < 3
12291 if (likely(PyString_Check(key))) {
12292 while (*name) {
12293 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
12294 && _PyString_Eq(**name, key)) {
12295 values[name-argnames] = value;
12296 break;
12297 }
12298 name++;
12299 }
12300 if (*name) continue;
12301 else {
12302 PyObject*** argname = argnames;
12303 while (argname != first_kw_arg) {
12304 if ((**argname == key) || (
12305 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
12306 && _PyString_Eq(**argname, key))) {
12307 goto arg_passed_twice;
12308 }
12309 argname++;
12310 }
12311 }
12312 } else
12313 #endif
12314 if (likely(PyUnicode_Check(key))) {
12315 while (*name) {
12316 int cmp = (**name == key) ? 0 :
12317 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
12318 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
12319 #endif
12320 PyUnicode_Compare(**name, key);
12321 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
12322 if (cmp == 0) {
12323 values[name-argnames] = value;
12324 break;
12325 }
12326 name++;
12327 }
12328 if (*name) continue;
12329 else {
12330 PyObject*** argname = argnames;
12331 while (argname != first_kw_arg) {
12332 int cmp = (**argname == key) ? 0 :
12333 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
12334 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
12335 #endif
12336 PyUnicode_Compare(**argname, key);
12337 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
12338 if (cmp == 0) goto arg_passed_twice;
12339 argname++;
12340 }
12341 }
12342 } else
12343 goto invalid_keyword_type;
12344 if (kwds2) {
12345 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
12346 } else {
12347 goto invalid_keyword;
12348 }
12349 }
12350 return 0;
12351 arg_passed_twice:
12352 __Pyx_RaiseDoubleKeywordsError(function_name, key);
12353 goto bad;
12354 invalid_keyword_type:
12355 PyErr_Format(PyExc_TypeError,
12356 "%.200s() keywords must be strings", function_name);
12357 goto bad;
12358 invalid_keyword:
12359 PyErr_Format(PyExc_TypeError,
12360 #if PY_MAJOR_VERSION < 3
12361 "%.200s() got an unexpected keyword argument '%.200s'",
12362 function_name, PyString_AsString(key));
12363 #else
12364 "%s() got an unexpected keyword argument '%U'",
12365 function_name, key);
12366 #endif
12367 bad:
12368 return -1;
12369 }
12370
12371 /* PyCFunctionFastCall */
12372 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)12373 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
12374 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
12375 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
12376 PyObject *self = PyCFunction_GET_SELF(func);
12377 int flags = PyCFunction_GET_FLAGS(func);
12378 assert(PyCFunction_Check(func));
12379 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
12380 assert(nargs >= 0);
12381 assert(nargs == 0 || args != NULL);
12382 /* _PyCFunction_FastCallDict() must not be called with an exception set,
12383 because it may clear it (directly or indirectly) and so the
12384 caller loses its exception */
12385 assert(!PyErr_Occurred());
12386 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
12387 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
12388 } else {
12389 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
12390 }
12391 }
12392 #endif
12393
12394 /* PyFunctionFastCall */
12395 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)12396 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
12397 PyObject *globals) {
12398 PyFrameObject *f;
12399 PyThreadState *tstate = __Pyx_PyThreadState_Current;
12400 PyObject **fastlocals;
12401 Py_ssize_t i;
12402 PyObject *result;
12403 assert(globals != NULL);
12404 /* XXX Perhaps we should create a specialized
12405 PyFrame_New() that doesn't take locals, but does
12406 take builtins without sanity checking them.
12407 */
12408 assert(tstate != NULL);
12409 f = PyFrame_New(tstate, co, globals, NULL);
12410 if (f == NULL) {
12411 return NULL;
12412 }
12413 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
12414 for (i = 0; i < na; i++) {
12415 Py_INCREF(*args);
12416 fastlocals[i] = *args++;
12417 }
12418 result = PyEval_EvalFrameEx(f,0);
12419 ++tstate->recursion_depth;
12420 Py_DECREF(f);
12421 --tstate->recursion_depth;
12422 return result;
12423 }
12424 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)12425 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
12426 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
12427 PyObject *globals = PyFunction_GET_GLOBALS(func);
12428 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
12429 PyObject *closure;
12430 #if PY_MAJOR_VERSION >= 3
12431 PyObject *kwdefs;
12432 #endif
12433 PyObject *kwtuple, **k;
12434 PyObject **d;
12435 Py_ssize_t nd;
12436 Py_ssize_t nk;
12437 PyObject *result;
12438 assert(kwargs == NULL || PyDict_Check(kwargs));
12439 nk = kwargs ? PyDict_Size(kwargs) : 0;
12440 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
12441 return NULL;
12442 }
12443 if (
12444 #if PY_MAJOR_VERSION >= 3
12445 co->co_kwonlyargcount == 0 &&
12446 #endif
12447 likely(kwargs == NULL || nk == 0) &&
12448 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
12449 if (argdefs == NULL && co->co_argcount == nargs) {
12450 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
12451 goto done;
12452 }
12453 else if (nargs == 0 && argdefs != NULL
12454 && co->co_argcount == Py_SIZE(argdefs)) {
12455 /* function called with no arguments, but all parameters have
12456 a default value: use default values as arguments .*/
12457 args = &PyTuple_GET_ITEM(argdefs, 0);
12458 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
12459 goto done;
12460 }
12461 }
12462 if (kwargs != NULL) {
12463 Py_ssize_t pos, i;
12464 kwtuple = PyTuple_New(2 * nk);
12465 if (kwtuple == NULL) {
12466 result = NULL;
12467 goto done;
12468 }
12469 k = &PyTuple_GET_ITEM(kwtuple, 0);
12470 pos = i = 0;
12471 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
12472 Py_INCREF(k[i]);
12473 Py_INCREF(k[i+1]);
12474 i += 2;
12475 }
12476 nk = i / 2;
12477 }
12478 else {
12479 kwtuple = NULL;
12480 k = NULL;
12481 }
12482 closure = PyFunction_GET_CLOSURE(func);
12483 #if PY_MAJOR_VERSION >= 3
12484 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
12485 #endif
12486 if (argdefs != NULL) {
12487 d = &PyTuple_GET_ITEM(argdefs, 0);
12488 nd = Py_SIZE(argdefs);
12489 }
12490 else {
12491 d = NULL;
12492 nd = 0;
12493 }
12494 #if PY_MAJOR_VERSION >= 3
12495 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
12496 args, (int)nargs,
12497 k, (int)nk,
12498 d, (int)nd, kwdefs, closure);
12499 #else
12500 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
12501 args, (int)nargs,
12502 k, (int)nk,
12503 d, (int)nd, closure);
12504 #endif
12505 Py_XDECREF(kwtuple);
12506 done:
12507 Py_LeaveRecursiveCall();
12508 return result;
12509 }
12510 #endif
12511 #endif
12512
12513 /* PyObjectCall */
12514 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)12515 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
12516 PyObject *result;
12517 ternaryfunc call = func->ob_type->tp_call;
12518 if (unlikely(!call))
12519 return PyObject_Call(func, arg, kw);
12520 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
12521 return NULL;
12522 result = (*call)(func, arg, kw);
12523 Py_LeaveRecursiveCall();
12524 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
12525 PyErr_SetString(
12526 PyExc_SystemError,
12527 "NULL result without error in PyObject_Call");
12528 }
12529 return result;
12530 }
12531 #endif
12532
12533 /* PyObjectCallMethO */
12534 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)12535 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
12536 PyObject *self, *result;
12537 PyCFunction cfunc;
12538 cfunc = PyCFunction_GET_FUNCTION(func);
12539 self = PyCFunction_GET_SELF(func);
12540 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
12541 return NULL;
12542 result = cfunc(self, arg);
12543 Py_LeaveRecursiveCall();
12544 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
12545 PyErr_SetString(
12546 PyExc_SystemError,
12547 "NULL result without error in PyObject_Call");
12548 }
12549 return result;
12550 }
12551 #endif
12552
12553 /* PyObjectCallOneArg */
12554 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)12555 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
12556 PyObject *result;
12557 PyObject *args = PyTuple_New(1);
12558 if (unlikely(!args)) return NULL;
12559 Py_INCREF(arg);
12560 PyTuple_SET_ITEM(args, 0, arg);
12561 result = __Pyx_PyObject_Call(func, args, NULL);
12562 Py_DECREF(args);
12563 return result;
12564 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)12565 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
12566 #if CYTHON_FAST_PYCALL
12567 if (PyFunction_Check(func)) {
12568 return __Pyx_PyFunction_FastCall(func, &arg, 1);
12569 }
12570 #endif
12571 if (likely(PyCFunction_Check(func))) {
12572 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
12573 return __Pyx_PyObject_CallMethO(func, arg);
12574 #if CYTHON_FAST_PYCCALL
12575 } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
12576 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
12577 #endif
12578 }
12579 }
12580 return __Pyx__PyObject_CallOneArg(func, arg);
12581 }
12582 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)12583 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
12584 PyObject *result;
12585 PyObject *args = PyTuple_Pack(1, arg);
12586 if (unlikely(!args)) return NULL;
12587 result = __Pyx_PyObject_Call(func, args, NULL);
12588 Py_DECREF(args);
12589 return result;
12590 }
12591 #endif
12592
12593 /* PyErrFetchRestore */
12594 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)12595 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
12596 PyObject *tmp_type, *tmp_value, *tmp_tb;
12597 tmp_type = tstate->curexc_type;
12598 tmp_value = tstate->curexc_value;
12599 tmp_tb = tstate->curexc_traceback;
12600 tstate->curexc_type = type;
12601 tstate->curexc_value = value;
12602 tstate->curexc_traceback = tb;
12603 Py_XDECREF(tmp_type);
12604 Py_XDECREF(tmp_value);
12605 Py_XDECREF(tmp_tb);
12606 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)12607 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
12608 *type = tstate->curexc_type;
12609 *value = tstate->curexc_value;
12610 *tb = tstate->curexc_traceback;
12611 tstate->curexc_type = 0;
12612 tstate->curexc_value = 0;
12613 tstate->curexc_traceback = 0;
12614 }
12615 #endif
12616
12617 /* RaiseException */
12618 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)12619 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
12620 CYTHON_UNUSED PyObject *cause) {
12621 __Pyx_PyThreadState_declare
12622 Py_XINCREF(type);
12623 if (!value || value == Py_None)
12624 value = NULL;
12625 else
12626 Py_INCREF(value);
12627 if (!tb || tb == Py_None)
12628 tb = NULL;
12629 else {
12630 Py_INCREF(tb);
12631 if (!PyTraceBack_Check(tb)) {
12632 PyErr_SetString(PyExc_TypeError,
12633 "raise: arg 3 must be a traceback or None");
12634 goto raise_error;
12635 }
12636 }
12637 if (PyType_Check(type)) {
12638 #if CYTHON_COMPILING_IN_PYPY
12639 if (!value) {
12640 Py_INCREF(Py_None);
12641 value = Py_None;
12642 }
12643 #endif
12644 PyErr_NormalizeException(&type, &value, &tb);
12645 } else {
12646 if (value) {
12647 PyErr_SetString(PyExc_TypeError,
12648 "instance exception may not have a separate value");
12649 goto raise_error;
12650 }
12651 value = type;
12652 type = (PyObject*) Py_TYPE(type);
12653 Py_INCREF(type);
12654 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
12655 PyErr_SetString(PyExc_TypeError,
12656 "raise: exception class must be a subclass of BaseException");
12657 goto raise_error;
12658 }
12659 }
12660 __Pyx_PyThreadState_assign
12661 __Pyx_ErrRestore(type, value, tb);
12662 return;
12663 raise_error:
12664 Py_XDECREF(value);
12665 Py_XDECREF(type);
12666 Py_XDECREF(tb);
12667 return;
12668 }
12669 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)12670 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
12671 PyObject* owned_instance = NULL;
12672 if (tb == Py_None) {
12673 tb = 0;
12674 } else if (tb && !PyTraceBack_Check(tb)) {
12675 PyErr_SetString(PyExc_TypeError,
12676 "raise: arg 3 must be a traceback or None");
12677 goto bad;
12678 }
12679 if (value == Py_None)
12680 value = 0;
12681 if (PyExceptionInstance_Check(type)) {
12682 if (value) {
12683 PyErr_SetString(PyExc_TypeError,
12684 "instance exception may not have a separate value");
12685 goto bad;
12686 }
12687 value = type;
12688 type = (PyObject*) Py_TYPE(value);
12689 } else if (PyExceptionClass_Check(type)) {
12690 PyObject *instance_class = NULL;
12691 if (value && PyExceptionInstance_Check(value)) {
12692 instance_class = (PyObject*) Py_TYPE(value);
12693 if (instance_class != type) {
12694 int is_subclass = PyObject_IsSubclass(instance_class, type);
12695 if (!is_subclass) {
12696 instance_class = NULL;
12697 } else if (unlikely(is_subclass == -1)) {
12698 goto bad;
12699 } else {
12700 type = instance_class;
12701 }
12702 }
12703 }
12704 if (!instance_class) {
12705 PyObject *args;
12706 if (!value)
12707 args = PyTuple_New(0);
12708 else if (PyTuple_Check(value)) {
12709 Py_INCREF(value);
12710 args = value;
12711 } else
12712 args = PyTuple_Pack(1, value);
12713 if (!args)
12714 goto bad;
12715 owned_instance = PyObject_Call(type, args, NULL);
12716 Py_DECREF(args);
12717 if (!owned_instance)
12718 goto bad;
12719 value = owned_instance;
12720 if (!PyExceptionInstance_Check(value)) {
12721 PyErr_Format(PyExc_TypeError,
12722 "calling %R should have returned an instance of "
12723 "BaseException, not %R",
12724 type, Py_TYPE(value));
12725 goto bad;
12726 }
12727 }
12728 } else {
12729 PyErr_SetString(PyExc_TypeError,
12730 "raise: exception class must be a subclass of BaseException");
12731 goto bad;
12732 }
12733 if (cause) {
12734 PyObject *fixed_cause;
12735 if (cause == Py_None) {
12736 fixed_cause = NULL;
12737 } else if (PyExceptionClass_Check(cause)) {
12738 fixed_cause = PyObject_CallObject(cause, NULL);
12739 if (fixed_cause == NULL)
12740 goto bad;
12741 } else if (PyExceptionInstance_Check(cause)) {
12742 fixed_cause = cause;
12743 Py_INCREF(fixed_cause);
12744 } else {
12745 PyErr_SetString(PyExc_TypeError,
12746 "exception causes must derive from "
12747 "BaseException");
12748 goto bad;
12749 }
12750 PyException_SetCause(value, fixed_cause);
12751 }
12752 PyErr_SetObject(type, value);
12753 if (tb) {
12754 #if CYTHON_COMPILING_IN_PYPY
12755 PyObject *tmp_type, *tmp_value, *tmp_tb;
12756 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
12757 Py_INCREF(tb);
12758 PyErr_Restore(tmp_type, tmp_value, tb);
12759 Py_XDECREF(tmp_tb);
12760 #else
12761 PyThreadState *tstate = __Pyx_PyThreadState_Current;
12762 PyObject* tmp_tb = tstate->curexc_traceback;
12763 if (tb != tmp_tb) {
12764 Py_INCREF(tb);
12765 tstate->curexc_traceback = tb;
12766 Py_XDECREF(tmp_tb);
12767 }
12768 #endif
12769 }
12770 bad:
12771 Py_XDECREF(owned_instance);
12772 return;
12773 }
12774 #endif
12775
12776 /* PyObjectCallNoArg */
12777 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)12778 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
12779 #if CYTHON_FAST_PYCALL
12780 if (PyFunction_Check(func)) {
12781 return __Pyx_PyFunction_FastCall(func, NULL, 0);
12782 }
12783 #endif
12784 #ifdef __Pyx_CyFunction_USED
12785 if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
12786 #else
12787 if (likely(PyCFunction_Check(func)))
12788 #endif
12789 {
12790 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
12791 return __Pyx_PyObject_CallMethO(func, NULL);
12792 }
12793 }
12794 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
12795 }
12796 #endif
12797
12798 /* PyErrExceptionMatches */
12799 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)12800 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
12801 Py_ssize_t i, n;
12802 n = PyTuple_GET_SIZE(tuple);
12803 #if PY_MAJOR_VERSION >= 3
12804 for (i=0; i<n; i++) {
12805 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
12806 }
12807 #endif
12808 for (i=0; i<n; i++) {
12809 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
12810 }
12811 return 0;
12812 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)12813 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
12814 PyObject *exc_type = tstate->curexc_type;
12815 if (exc_type == err) return 1;
12816 if (unlikely(!exc_type)) return 0;
12817 if (unlikely(PyTuple_Check(err)))
12818 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
12819 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
12820 }
12821 #endif
12822
12823 /* GetAttr */
__Pyx_GetAttr(PyObject * o,PyObject * n)12824 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
12825 #if CYTHON_USE_TYPE_SLOTS
12826 #if PY_MAJOR_VERSION >= 3
12827 if (likely(PyUnicode_Check(n)))
12828 #else
12829 if (likely(PyString_Check(n)))
12830 #endif
12831 return __Pyx_PyObject_GetAttrStr(o, n);
12832 #endif
12833 return PyObject_GetAttr(o, n);
12834 }
12835
12836 /* GetAttr3 */
__Pyx_GetAttr3Default(PyObject * d)12837 static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
12838 __Pyx_PyThreadState_declare
12839 __Pyx_PyThreadState_assign
12840 if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
12841 return NULL;
12842 __Pyx_PyErr_Clear();
12843 Py_INCREF(d);
12844 return d;
12845 }
__Pyx_GetAttr3(PyObject * o,PyObject * n,PyObject * d)12846 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
12847 PyObject *r = __Pyx_GetAttr(o, n);
12848 return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
12849 }
12850
12851 /* PyDictVersioning */
12852 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)12853 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
12854 PyObject *dict = Py_TYPE(obj)->tp_dict;
12855 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
12856 }
__Pyx_get_object_dict_version(PyObject * obj)12857 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
12858 PyObject **dictptr = NULL;
12859 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
12860 if (offset) {
12861 #if CYTHON_COMPILING_IN_CPYTHON
12862 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
12863 #else
12864 dictptr = _PyObject_GetDictPtr(obj);
12865 #endif
12866 }
12867 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
12868 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)12869 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
12870 PyObject *dict = Py_TYPE(obj)->tp_dict;
12871 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
12872 return 0;
12873 return obj_dict_version == __Pyx_get_object_dict_version(obj);
12874 }
12875 #endif
12876
12877 /* GetModuleGlobalName */
12878 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)12879 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
12880 #else
12881 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
12882 #endif
12883 {
12884 PyObject *result;
12885 #if !CYTHON_AVOID_BORROWED_REFS
12886 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
12887 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
12888 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
12889 if (likely(result)) {
12890 return __Pyx_NewRef(result);
12891 } else if (unlikely(PyErr_Occurred())) {
12892 return NULL;
12893 }
12894 #else
12895 result = PyDict_GetItem(__pyx_d, name);
12896 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
12897 if (likely(result)) {
12898 return __Pyx_NewRef(result);
12899 }
12900 #endif
12901 #else
12902 result = PyObject_GetItem(__pyx_d, name);
12903 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
12904 if (likely(result)) {
12905 return __Pyx_NewRef(result);
12906 }
12907 PyErr_Clear();
12908 #endif
12909 return __Pyx_GetBuiltinName(name);
12910 }
12911
12912 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)12913 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
12914 if (unlikely(!type)) {
12915 PyErr_SetString(PyExc_SystemError, "Missing type object");
12916 return 0;
12917 }
12918 if (likely(__Pyx_TypeCheck(obj, type)))
12919 return 1;
12920 PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
12921 Py_TYPE(obj)->tp_name, type->tp_name);
12922 return 0;
12923 }
12924
12925 /* WriteUnraisableException */
__Pyx_WriteUnraisable(const char * name,CYTHON_UNUSED int clineno,CYTHON_UNUSED int lineno,CYTHON_UNUSED const char * filename,int full_traceback,CYTHON_UNUSED int nogil)12926 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
12927 CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
12928 int full_traceback, CYTHON_UNUSED int nogil) {
12929 PyObject *old_exc, *old_val, *old_tb;
12930 PyObject *ctx;
12931 __Pyx_PyThreadState_declare
12932 #ifdef WITH_THREAD
12933 PyGILState_STATE state;
12934 if (nogil)
12935 state = PyGILState_Ensure();
12936 #ifdef _MSC_VER
12937 else state = (PyGILState_STATE)-1;
12938 #endif
12939 #endif
12940 __Pyx_PyThreadState_assign
12941 __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
12942 if (full_traceback) {
12943 Py_XINCREF(old_exc);
12944 Py_XINCREF(old_val);
12945 Py_XINCREF(old_tb);
12946 __Pyx_ErrRestore(old_exc, old_val, old_tb);
12947 PyErr_PrintEx(1);
12948 }
12949 #if PY_MAJOR_VERSION < 3
12950 ctx = PyString_FromString(name);
12951 #else
12952 ctx = PyUnicode_FromString(name);
12953 #endif
12954 __Pyx_ErrRestore(old_exc, old_val, old_tb);
12955 if (!ctx) {
12956 PyErr_WriteUnraisable(Py_None);
12957 } else {
12958 PyErr_WriteUnraisable(ctx);
12959 Py_DECREF(ctx);
12960 }
12961 #ifdef WITH_THREAD
12962 if (nogil)
12963 PyGILState_Release(state);
12964 #endif
12965 }
12966
12967 /* None */
__Pyx_div_long(long a,long b)12968 static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
12969 long q = a / b;
12970 long r = a - q*b;
12971 q -= ((r != 0) & ((r ^ b) < 0));
12972 return q;
12973 }
12974
12975 /* PyObjectFormatAndDecref */
__Pyx_PyObject_FormatSimpleAndDecref(PyObject * s,PyObject * f)12976 static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
12977 if (unlikely(!s)) return NULL;
12978 if (likely(PyUnicode_CheckExact(s))) return s;
12979 #if PY_MAJOR_VERSION < 3
12980 if (likely(PyString_CheckExact(s))) {
12981 PyObject *result = PyUnicode_FromEncodedObject(s, NULL, "strict");
12982 Py_DECREF(s);
12983 return result;
12984 }
12985 #endif
12986 return __Pyx_PyObject_FormatAndDecref(s, f);
12987 }
__Pyx_PyObject_FormatAndDecref(PyObject * s,PyObject * f)12988 static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
12989 PyObject *result = PyObject_Format(s, f);
12990 Py_DECREF(s);
12991 return result;
12992 }
12993
12994 /* JoinPyUnicode */
__Pyx_PyUnicode_Join(PyObject * value_tuple,Py_ssize_t value_count,Py_ssize_t result_ulength,CYTHON_UNUSED Py_UCS4 max_char)12995 static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
12996 CYTHON_UNUSED Py_UCS4 max_char) {
12997 #if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12998 PyObject *result_uval;
12999 int result_ukind;
13000 Py_ssize_t i, char_pos;
13001 void *result_udata;
13002 #if CYTHON_PEP393_ENABLED
13003 result_uval = PyUnicode_New(result_ulength, max_char);
13004 if (unlikely(!result_uval)) return NULL;
13005 result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
13006 result_udata = PyUnicode_DATA(result_uval);
13007 #else
13008 result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
13009 if (unlikely(!result_uval)) return NULL;
13010 result_ukind = sizeof(Py_UNICODE);
13011 result_udata = PyUnicode_AS_UNICODE(result_uval);
13012 #endif
13013 char_pos = 0;
13014 for (i=0; i < value_count; i++) {
13015 int ukind;
13016 Py_ssize_t ulength;
13017 void *udata;
13018 PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
13019 if (unlikely(__Pyx_PyUnicode_READY(uval)))
13020 goto bad;
13021 ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
13022 if (unlikely(!ulength))
13023 continue;
13024 if (unlikely(char_pos + ulength < 0))
13025 goto overflow;
13026 ukind = __Pyx_PyUnicode_KIND(uval);
13027 udata = __Pyx_PyUnicode_DATA(uval);
13028 if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
13029 memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
13030 } else {
13031 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
13032 _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
13033 #else
13034 Py_ssize_t j;
13035 for (j=0; j < ulength; j++) {
13036 Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
13037 __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
13038 }
13039 #endif
13040 }
13041 char_pos += ulength;
13042 }
13043 return result_uval;
13044 overflow:
13045 PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
13046 bad:
13047 Py_DECREF(result_uval);
13048 return NULL;
13049 #else
13050 result_ulength++;
13051 value_count++;
13052 return PyUnicode_Join(__pyx_empty_unicode, value_tuple);
13053 #endif
13054 }
13055
13056 /* SliceObject */
__Pyx_PyObject_GetSlice(PyObject * obj,Py_ssize_t cstart,Py_ssize_t cstop,PyObject ** _py_start,PyObject ** _py_stop,PyObject ** _py_slice,int has_cstart,int has_cstop,CYTHON_UNUSED int wraparound)13057 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
13058 Py_ssize_t cstart, Py_ssize_t cstop,
13059 PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
13060 int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
13061 #if CYTHON_USE_TYPE_SLOTS
13062 PyMappingMethods* mp;
13063 #if PY_MAJOR_VERSION < 3
13064 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
13065 if (likely(ms && ms->sq_slice)) {
13066 if (!has_cstart) {
13067 if (_py_start && (*_py_start != Py_None)) {
13068 cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
13069 if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
13070 } else
13071 cstart = 0;
13072 }
13073 if (!has_cstop) {
13074 if (_py_stop && (*_py_stop != Py_None)) {
13075 cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
13076 if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
13077 } else
13078 cstop = PY_SSIZE_T_MAX;
13079 }
13080 if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
13081 Py_ssize_t l = ms->sq_length(obj);
13082 if (likely(l >= 0)) {
13083 if (cstop < 0) {
13084 cstop += l;
13085 if (cstop < 0) cstop = 0;
13086 }
13087 if (cstart < 0) {
13088 cstart += l;
13089 if (cstart < 0) cstart = 0;
13090 }
13091 } else {
13092 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
13093 goto bad;
13094 PyErr_Clear();
13095 }
13096 }
13097 return ms->sq_slice(obj, cstart, cstop);
13098 }
13099 #endif
13100 mp = Py_TYPE(obj)->tp_as_mapping;
13101 if (likely(mp && mp->mp_subscript))
13102 #endif
13103 {
13104 PyObject* result;
13105 PyObject *py_slice, *py_start, *py_stop;
13106 if (_py_slice) {
13107 py_slice = *_py_slice;
13108 } else {
13109 PyObject* owned_start = NULL;
13110 PyObject* owned_stop = NULL;
13111 if (_py_start) {
13112 py_start = *_py_start;
13113 } else {
13114 if (has_cstart) {
13115 owned_start = py_start = PyInt_FromSsize_t(cstart);
13116 if (unlikely(!py_start)) goto bad;
13117 } else
13118 py_start = Py_None;
13119 }
13120 if (_py_stop) {
13121 py_stop = *_py_stop;
13122 } else {
13123 if (has_cstop) {
13124 owned_stop = py_stop = PyInt_FromSsize_t(cstop);
13125 if (unlikely(!py_stop)) {
13126 Py_XDECREF(owned_start);
13127 goto bad;
13128 }
13129 } else
13130 py_stop = Py_None;
13131 }
13132 py_slice = PySlice_New(py_start, py_stop, Py_None);
13133 Py_XDECREF(owned_start);
13134 Py_XDECREF(owned_stop);
13135 if (unlikely(!py_slice)) goto bad;
13136 }
13137 #if CYTHON_USE_TYPE_SLOTS
13138 result = mp->mp_subscript(obj, py_slice);
13139 #else
13140 result = PyObject_GetItem(obj, py_slice);
13141 #endif
13142 if (!_py_slice) {
13143 Py_DECREF(py_slice);
13144 }
13145 return result;
13146 }
13147 PyErr_Format(PyExc_TypeError,
13148 "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
13149 bad:
13150 return NULL;
13151 }
13152
13153 /* PyIntCompare */
__Pyx_PyInt_EqObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,CYTHON_UNUSED long inplace)13154 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
13155 if (op1 == op2) {
13156 Py_RETURN_TRUE;
13157 }
13158 #if PY_MAJOR_VERSION < 3
13159 if (likely(PyInt_CheckExact(op1))) {
13160 const long b = intval;
13161 long a = PyInt_AS_LONG(op1);
13162 if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
13163 }
13164 #endif
13165 #if CYTHON_USE_PYLONG_INTERNALS
13166 if (likely(PyLong_CheckExact(op1))) {
13167 int unequal;
13168 unsigned long uintval;
13169 Py_ssize_t size = Py_SIZE(op1);
13170 const digit* digits = ((PyLongObject*)op1)->ob_digit;
13171 if (intval == 0) {
13172 if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
13173 } else if (intval < 0) {
13174 if (size >= 0)
13175 Py_RETURN_FALSE;
13176 intval = -intval;
13177 size = -size;
13178 } else {
13179 if (size <= 0)
13180 Py_RETURN_FALSE;
13181 }
13182 uintval = (unsigned long) intval;
13183 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
13184 if (uintval >> (PyLong_SHIFT * 4)) {
13185 unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
13186 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
13187 } else
13188 #endif
13189 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
13190 if (uintval >> (PyLong_SHIFT * 3)) {
13191 unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
13192 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
13193 } else
13194 #endif
13195 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
13196 if (uintval >> (PyLong_SHIFT * 2)) {
13197 unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
13198 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
13199 } else
13200 #endif
13201 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
13202 if (uintval >> (PyLong_SHIFT * 1)) {
13203 unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
13204 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
13205 } else
13206 #endif
13207 unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
13208 if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
13209 }
13210 #endif
13211 if (PyFloat_CheckExact(op1)) {
13212 const long b = intval;
13213 double a = PyFloat_AS_DOUBLE(op1);
13214 if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
13215 }
13216 return (
13217 PyObject_RichCompare(op1, op2, Py_EQ));
13218 }
13219
13220 /* StringJoin */
13221 #if !CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyBytes_Join(PyObject * sep,PyObject * values)13222 static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
13223 return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
13224 }
13225 #endif
13226
13227 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)13228 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
13229 PyObject *r;
13230 if (!j) return NULL;
13231 r = PyObject_GetItem(o, j);
13232 Py_DECREF(j);
13233 return r;
13234 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)13235 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
13236 CYTHON_NCP_UNUSED int wraparound,
13237 CYTHON_NCP_UNUSED int boundscheck) {
13238 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
13239 Py_ssize_t wrapped_i = i;
13240 if (wraparound & unlikely(i < 0)) {
13241 wrapped_i += PyList_GET_SIZE(o);
13242 }
13243 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
13244 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
13245 Py_INCREF(r);
13246 return r;
13247 }
13248 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
13249 #else
13250 return PySequence_GetItem(o, i);
13251 #endif
13252 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)13253 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
13254 CYTHON_NCP_UNUSED int wraparound,
13255 CYTHON_NCP_UNUSED int boundscheck) {
13256 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
13257 Py_ssize_t wrapped_i = i;
13258 if (wraparound & unlikely(i < 0)) {
13259 wrapped_i += PyTuple_GET_SIZE(o);
13260 }
13261 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
13262 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
13263 Py_INCREF(r);
13264 return r;
13265 }
13266 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
13267 #else
13268 return PySequence_GetItem(o, i);
13269 #endif
13270 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)13271 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
13272 CYTHON_NCP_UNUSED int wraparound,
13273 CYTHON_NCP_UNUSED int boundscheck) {
13274 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
13275 if (is_list || PyList_CheckExact(o)) {
13276 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
13277 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
13278 PyObject *r = PyList_GET_ITEM(o, n);
13279 Py_INCREF(r);
13280 return r;
13281 }
13282 }
13283 else if (PyTuple_CheckExact(o)) {
13284 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
13285 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
13286 PyObject *r = PyTuple_GET_ITEM(o, n);
13287 Py_INCREF(r);
13288 return r;
13289 }
13290 } else {
13291 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
13292 if (likely(m && m->sq_item)) {
13293 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
13294 Py_ssize_t l = m->sq_length(o);
13295 if (likely(l >= 0)) {
13296 i += l;
13297 } else {
13298 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
13299 return NULL;
13300 PyErr_Clear();
13301 }
13302 }
13303 return m->sq_item(o, i);
13304 }
13305 }
13306 #else
13307 if (is_list || PySequence_Check(o)) {
13308 return PySequence_GetItem(o, i);
13309 }
13310 #endif
13311 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
13312 }
13313
13314 /* None */
__Pyx_RaiseUnboundLocalError(const char * varname)13315 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
13316 PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
13317 }
13318
13319 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)13320 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
13321 PyObject *empty_list = 0;
13322 PyObject *module = 0;
13323 PyObject *global_dict = 0;
13324 PyObject *empty_dict = 0;
13325 PyObject *list;
13326 #if PY_MAJOR_VERSION < 3
13327 PyObject *py_import;
13328 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
13329 if (!py_import)
13330 goto bad;
13331 #endif
13332 if (from_list)
13333 list = from_list;
13334 else {
13335 empty_list = PyList_New(0);
13336 if (!empty_list)
13337 goto bad;
13338 list = empty_list;
13339 }
13340 global_dict = PyModule_GetDict(__pyx_m);
13341 if (!global_dict)
13342 goto bad;
13343 empty_dict = PyDict_New();
13344 if (!empty_dict)
13345 goto bad;
13346 {
13347 #if PY_MAJOR_VERSION >= 3
13348 if (level == -1) {
13349 if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
13350 module = PyImport_ImportModuleLevelObject(
13351 name, global_dict, empty_dict, list, 1);
13352 if (!module) {
13353 if (!PyErr_ExceptionMatches(PyExc_ImportError))
13354 goto bad;
13355 PyErr_Clear();
13356 }
13357 }
13358 level = 0;
13359 }
13360 #endif
13361 if (!module) {
13362 #if PY_MAJOR_VERSION < 3
13363 PyObject *py_level = PyInt_FromLong(level);
13364 if (!py_level)
13365 goto bad;
13366 module = PyObject_CallFunctionObjArgs(py_import,
13367 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
13368 Py_DECREF(py_level);
13369 #else
13370 module = PyImport_ImportModuleLevelObject(
13371 name, global_dict, empty_dict, list, level);
13372 #endif
13373 }
13374 }
13375 bad:
13376 #if PY_MAJOR_VERSION < 3
13377 Py_XDECREF(py_import);
13378 #endif
13379 Py_XDECREF(empty_list);
13380 Py_XDECREF(empty_dict);
13381 return module;
13382 }
13383
13384 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)13385 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
13386 PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
13387 if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
13388 PyErr_Format(PyExc_ImportError,
13389 #if PY_MAJOR_VERSION < 3
13390 "cannot import name %.230s", PyString_AS_STRING(name));
13391 #else
13392 "cannot import name %S", name);
13393 #endif
13394 }
13395 return value;
13396 }
13397
13398 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)13399 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
13400 PyObject *args, *result = NULL;
13401 #if CYTHON_FAST_PYCALL
13402 if (PyFunction_Check(function)) {
13403 PyObject *args[2] = {arg1, arg2};
13404 return __Pyx_PyFunction_FastCall(function, args, 2);
13405 }
13406 #endif
13407 #if CYTHON_FAST_PYCCALL
13408 if (__Pyx_PyFastCFunction_Check(function)) {
13409 PyObject *args[2] = {arg1, arg2};
13410 return __Pyx_PyCFunction_FastCall(function, args, 2);
13411 }
13412 #endif
13413 args = PyTuple_New(2);
13414 if (unlikely(!args)) goto done;
13415 Py_INCREF(arg1);
13416 PyTuple_SET_ITEM(args, 0, arg1);
13417 Py_INCREF(arg2);
13418 PyTuple_SET_ITEM(args, 1, arg2);
13419 Py_INCREF(function);
13420 result = __Pyx_PyObject_Call(function, args, NULL);
13421 Py_DECREF(args);
13422 Py_DECREF(function);
13423 done:
13424 return result;
13425 }
13426
13427 /* HasAttr */
__Pyx_HasAttr(PyObject * o,PyObject * n)13428 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
13429 PyObject *r;
13430 if (unlikely(!__Pyx_PyBaseString_Check(n))) {
13431 PyErr_SetString(PyExc_TypeError,
13432 "hasattr(): attribute name must be string");
13433 return -1;
13434 }
13435 r = __Pyx_GetAttr(o, n);
13436 if (unlikely(!r)) {
13437 PyErr_Clear();
13438 return 0;
13439 } else {
13440 Py_DECREF(r);
13441 return 1;
13442 }
13443 }
13444
13445 /* PyObject_GenericGetAttrNoDict */
13446 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)13447 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
13448 PyErr_Format(PyExc_AttributeError,
13449 #if PY_MAJOR_VERSION >= 3
13450 "'%.50s' object has no attribute '%U'",
13451 tp->tp_name, attr_name);
13452 #else
13453 "'%.50s' object has no attribute '%.400s'",
13454 tp->tp_name, PyString_AS_STRING(attr_name));
13455 #endif
13456 return NULL;
13457 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)13458 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
13459 PyObject *descr;
13460 PyTypeObject *tp = Py_TYPE(obj);
13461 if (unlikely(!PyString_Check(attr_name))) {
13462 return PyObject_GenericGetAttr(obj, attr_name);
13463 }
13464 assert(!tp->tp_dictoffset);
13465 descr = _PyType_Lookup(tp, attr_name);
13466 if (unlikely(!descr)) {
13467 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
13468 }
13469 Py_INCREF(descr);
13470 #if PY_MAJOR_VERSION < 3
13471 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
13472 #endif
13473 {
13474 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
13475 if (unlikely(f)) {
13476 PyObject *res = f(descr, obj, (PyObject *)tp);
13477 Py_DECREF(descr);
13478 return res;
13479 }
13480 }
13481 return descr;
13482 }
13483 #endif
13484
13485 /* PyObject_GenericGetAttr */
13486 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)13487 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
13488 if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
13489 return PyObject_GenericGetAttr(obj, attr_name);
13490 }
13491 return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
13492 }
13493 #endif
13494
13495 /* SetVTable */
__Pyx_SetVtable(PyObject * dict,void * vtable)13496 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
13497 #if PY_VERSION_HEX >= 0x02070000
13498 PyObject *ob = PyCapsule_New(vtable, 0, 0);
13499 #else
13500 PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
13501 #endif
13502 if (!ob)
13503 goto bad;
13504 if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
13505 goto bad;
13506 Py_DECREF(ob);
13507 return 0;
13508 bad:
13509 Py_XDECREF(ob);
13510 return -1;
13511 }
13512
13513 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)13514 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
13515 __Pyx_PyThreadState_declare
13516 __Pyx_PyThreadState_assign
13517 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
13518 __Pyx_PyErr_Clear();
13519 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)13520 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
13521 PyObject *result;
13522 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
13523 PyTypeObject* tp = Py_TYPE(obj);
13524 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
13525 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
13526 }
13527 #endif
13528 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
13529 if (unlikely(!result)) {
13530 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
13531 }
13532 return result;
13533 }
13534
13535 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)13536 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
13537 int ret;
13538 PyObject *name_attr;
13539 name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
13540 if (likely(name_attr)) {
13541 ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
13542 } else {
13543 ret = -1;
13544 }
13545 if (unlikely(ret < 0)) {
13546 PyErr_Clear();
13547 ret = 0;
13548 }
13549 Py_XDECREF(name_attr);
13550 return ret;
13551 }
__Pyx_setup_reduce(PyObject * type_obj)13552 static int __Pyx_setup_reduce(PyObject* type_obj) {
13553 int ret = 0;
13554 PyObject *object_reduce = NULL;
13555 PyObject *object_reduce_ex = NULL;
13556 PyObject *reduce = NULL;
13557 PyObject *reduce_ex = NULL;
13558 PyObject *reduce_cython = NULL;
13559 PyObject *setstate = NULL;
13560 PyObject *setstate_cython = NULL;
13561 #if CYTHON_USE_PYTYPE_LOOKUP
13562 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
13563 #else
13564 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
13565 #endif
13566 #if CYTHON_USE_PYTYPE_LOOKUP
13567 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
13568 #else
13569 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
13570 #endif
13571 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
13572 if (reduce_ex == object_reduce_ex) {
13573 #if CYTHON_USE_PYTYPE_LOOKUP
13574 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
13575 #else
13576 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
13577 #endif
13578 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
13579 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
13580 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
13581 if (likely(reduce_cython)) {
13582 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
13583 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
13584 } else if (reduce == object_reduce || PyErr_Occurred()) {
13585 goto __PYX_BAD;
13586 }
13587 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
13588 if (!setstate) PyErr_Clear();
13589 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
13590 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
13591 if (likely(setstate_cython)) {
13592 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
13593 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
13594 } else if (!setstate || PyErr_Occurred()) {
13595 goto __PYX_BAD;
13596 }
13597 }
13598 PyType_Modified((PyTypeObject*)type_obj);
13599 }
13600 }
13601 goto __PYX_GOOD;
13602 __PYX_BAD:
13603 if (!PyErr_Occurred())
13604 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
13605 ret = -1;
13606 __PYX_GOOD:
13607 #if !CYTHON_USE_PYTYPE_LOOKUP
13608 Py_XDECREF(object_reduce);
13609 Py_XDECREF(object_reduce_ex);
13610 #endif
13611 Py_XDECREF(reduce);
13612 Py_XDECREF(reduce_ex);
13613 Py_XDECREF(reduce_cython);
13614 Py_XDECREF(setstate);
13615 Py_XDECREF(setstate_cython);
13616 return ret;
13617 }
13618
13619 /* TypeImport */
13620 #ifndef __PYX_HAVE_RT_ImportType
13621 #define __PYX_HAVE_RT_ImportType
__Pyx_ImportType(PyObject * module,const char * module_name,const char * class_name,size_t size,enum __Pyx_ImportType_CheckSize check_size)13622 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
13623 size_t size, enum __Pyx_ImportType_CheckSize check_size)
13624 {
13625 PyObject *result = 0;
13626 char warning[200];
13627 Py_ssize_t basicsize;
13628 #ifdef Py_LIMITED_API
13629 PyObject *py_basicsize;
13630 #endif
13631 result = PyObject_GetAttrString(module, class_name);
13632 if (!result)
13633 goto bad;
13634 if (!PyType_Check(result)) {
13635 PyErr_Format(PyExc_TypeError,
13636 "%.200s.%.200s is not a type object",
13637 module_name, class_name);
13638 goto bad;
13639 }
13640 #ifndef Py_LIMITED_API
13641 basicsize = ((PyTypeObject *)result)->tp_basicsize;
13642 #else
13643 py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
13644 if (!py_basicsize)
13645 goto bad;
13646 basicsize = PyLong_AsSsize_t(py_basicsize);
13647 Py_DECREF(py_basicsize);
13648 py_basicsize = 0;
13649 if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
13650 goto bad;
13651 #endif
13652 if ((size_t)basicsize < size) {
13653 PyErr_Format(PyExc_ValueError,
13654 "%.200s.%.200s size changed, may indicate binary incompatibility. "
13655 "Expected %zd from C header, got %zd from PyObject",
13656 module_name, class_name, size, basicsize);
13657 goto bad;
13658 }
13659 if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
13660 PyErr_Format(PyExc_ValueError,
13661 "%.200s.%.200s size changed, may indicate binary incompatibility. "
13662 "Expected %zd from C header, got %zd from PyObject",
13663 module_name, class_name, size, basicsize);
13664 goto bad;
13665 }
13666 else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
13667 PyOS_snprintf(warning, sizeof(warning),
13668 "%s.%s size changed, may indicate binary incompatibility. "
13669 "Expected %zd from C header, got %zd from PyObject",
13670 module_name, class_name, size, basicsize);
13671 if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
13672 }
13673 return (PyTypeObject *)result;
13674 bad:
13675 Py_XDECREF(result);
13676 return NULL;
13677 }
13678 #endif
13679
13680 /* CLineInTraceback */
13681 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)13682 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
13683 PyObject *use_cline;
13684 PyObject *ptype, *pvalue, *ptraceback;
13685 #if CYTHON_COMPILING_IN_CPYTHON
13686 PyObject **cython_runtime_dict;
13687 #endif
13688 if (unlikely(!__pyx_cython_runtime)) {
13689 return c_line;
13690 }
13691 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
13692 #if CYTHON_COMPILING_IN_CPYTHON
13693 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
13694 if (likely(cython_runtime_dict)) {
13695 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
13696 use_cline, *cython_runtime_dict,
13697 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
13698 } else
13699 #endif
13700 {
13701 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
13702 if (use_cline_obj) {
13703 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
13704 Py_DECREF(use_cline_obj);
13705 } else {
13706 PyErr_Clear();
13707 use_cline = NULL;
13708 }
13709 }
13710 if (!use_cline) {
13711 c_line = 0;
13712 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
13713 }
13714 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
13715 c_line = 0;
13716 }
13717 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
13718 return c_line;
13719 }
13720 #endif
13721
13722 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)13723 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
13724 int start = 0, mid = 0, end = count - 1;
13725 if (end >= 0 && code_line > entries[end].code_line) {
13726 return count;
13727 }
13728 while (start < end) {
13729 mid = start + (end - start) / 2;
13730 if (code_line < entries[mid].code_line) {
13731 end = mid;
13732 } else if (code_line > entries[mid].code_line) {
13733 start = mid + 1;
13734 } else {
13735 return mid;
13736 }
13737 }
13738 if (code_line <= entries[mid].code_line) {
13739 return mid;
13740 } else {
13741 return mid + 1;
13742 }
13743 }
__pyx_find_code_object(int code_line)13744 static PyCodeObject *__pyx_find_code_object(int code_line) {
13745 PyCodeObject* code_object;
13746 int pos;
13747 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
13748 return NULL;
13749 }
13750 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
13751 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
13752 return NULL;
13753 }
13754 code_object = __pyx_code_cache.entries[pos].code_object;
13755 Py_INCREF(code_object);
13756 return code_object;
13757 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)13758 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
13759 int pos, i;
13760 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
13761 if (unlikely(!code_line)) {
13762 return;
13763 }
13764 if (unlikely(!entries)) {
13765 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
13766 if (likely(entries)) {
13767 __pyx_code_cache.entries = entries;
13768 __pyx_code_cache.max_count = 64;
13769 __pyx_code_cache.count = 1;
13770 entries[0].code_line = code_line;
13771 entries[0].code_object = code_object;
13772 Py_INCREF(code_object);
13773 }
13774 return;
13775 }
13776 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
13777 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
13778 PyCodeObject* tmp = entries[pos].code_object;
13779 entries[pos].code_object = code_object;
13780 Py_DECREF(tmp);
13781 return;
13782 }
13783 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
13784 int new_max = __pyx_code_cache.max_count + 64;
13785 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
13786 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
13787 if (unlikely(!entries)) {
13788 return;
13789 }
13790 __pyx_code_cache.entries = entries;
13791 __pyx_code_cache.max_count = new_max;
13792 }
13793 for (i=__pyx_code_cache.count; i>pos; i--) {
13794 entries[i] = entries[i-1];
13795 }
13796 entries[pos].code_line = code_line;
13797 entries[pos].code_object = code_object;
13798 __pyx_code_cache.count++;
13799 Py_INCREF(code_object);
13800 }
13801
13802 /* AddTraceback */
13803 #include "compile.h"
13804 #include "frameobject.h"
13805 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)13806 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
13807 const char *funcname, int c_line,
13808 int py_line, const char *filename) {
13809 PyCodeObject *py_code = 0;
13810 PyObject *py_srcfile = 0;
13811 PyObject *py_funcname = 0;
13812 #if PY_MAJOR_VERSION < 3
13813 py_srcfile = PyString_FromString(filename);
13814 #else
13815 py_srcfile = PyUnicode_FromString(filename);
13816 #endif
13817 if (!py_srcfile) goto bad;
13818 if (c_line) {
13819 #if PY_MAJOR_VERSION < 3
13820 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
13821 #else
13822 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
13823 #endif
13824 }
13825 else {
13826 #if PY_MAJOR_VERSION < 3
13827 py_funcname = PyString_FromString(funcname);
13828 #else
13829 py_funcname = PyUnicode_FromString(funcname);
13830 #endif
13831 }
13832 if (!py_funcname) goto bad;
13833 py_code = __Pyx_PyCode_New(
13834 0,
13835 0,
13836 0,
13837 0,
13838 0,
13839 __pyx_empty_bytes, /*PyObject *code,*/
13840 __pyx_empty_tuple, /*PyObject *consts,*/
13841 __pyx_empty_tuple, /*PyObject *names,*/
13842 __pyx_empty_tuple, /*PyObject *varnames,*/
13843 __pyx_empty_tuple, /*PyObject *freevars,*/
13844 __pyx_empty_tuple, /*PyObject *cellvars,*/
13845 py_srcfile, /*PyObject *filename,*/
13846 py_funcname, /*PyObject *name,*/
13847 py_line,
13848 __pyx_empty_bytes /*PyObject *lnotab*/
13849 );
13850 Py_DECREF(py_srcfile);
13851 Py_DECREF(py_funcname);
13852 return py_code;
13853 bad:
13854 Py_XDECREF(py_srcfile);
13855 Py_XDECREF(py_funcname);
13856 return NULL;
13857 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)13858 static void __Pyx_AddTraceback(const char *funcname, int c_line,
13859 int py_line, const char *filename) {
13860 PyCodeObject *py_code = 0;
13861 PyFrameObject *py_frame = 0;
13862 PyThreadState *tstate = __Pyx_PyThreadState_Current;
13863 if (c_line) {
13864 c_line = __Pyx_CLineForTraceback(tstate, c_line);
13865 }
13866 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
13867 if (!py_code) {
13868 py_code = __Pyx_CreateCodeObjectForTraceback(
13869 funcname, c_line, py_line, filename);
13870 if (!py_code) goto bad;
13871 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
13872 }
13873 py_frame = PyFrame_New(
13874 tstate, /*PyThreadState *tstate,*/
13875 py_code, /*PyCodeObject *code,*/
13876 __pyx_d, /*PyObject *globals,*/
13877 0 /*PyObject *locals*/
13878 );
13879 if (!py_frame) goto bad;
13880 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
13881 PyTraceBack_Here(py_frame);
13882 bad:
13883 Py_XDECREF(py_code);
13884 Py_XDECREF(py_frame);
13885 }
13886
13887 /* CIntToPy */
__Pyx_PyInt_From_int(int value)13888 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
13889 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
13890 const int is_unsigned = neg_one > const_zero;
13891 if (is_unsigned) {
13892 if (sizeof(int) < sizeof(long)) {
13893 return PyInt_FromLong((long) value);
13894 } else if (sizeof(int) <= sizeof(unsigned long)) {
13895 return PyLong_FromUnsignedLong((unsigned long) value);
13896 #ifdef HAVE_LONG_LONG
13897 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
13898 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
13899 #endif
13900 }
13901 } else {
13902 if (sizeof(int) <= sizeof(long)) {
13903 return PyInt_FromLong((long) value);
13904 #ifdef HAVE_LONG_LONG
13905 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
13906 return PyLong_FromLongLong((PY_LONG_LONG) value);
13907 #endif
13908 }
13909 }
13910 {
13911 int one = 1; int little = (int)*(unsigned char *)&one;
13912 unsigned char *bytes = (unsigned char *)&value;
13913 return _PyLong_FromByteArray(bytes, sizeof(int),
13914 little, !is_unsigned);
13915 }
13916 }
13917
13918 /* CIntFromPyVerify */
13919 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
13920 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
13921 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
13922 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
13923 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
13924 {\
13925 func_type value = func_value;\
13926 if (sizeof(target_type) < sizeof(func_type)) {\
13927 if (unlikely(value != (func_type) (target_type) value)) {\
13928 func_type zero = 0;\
13929 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
13930 return (target_type) -1;\
13931 if (is_unsigned && unlikely(value < zero))\
13932 goto raise_neg_overflow;\
13933 else\
13934 goto raise_overflow;\
13935 }\
13936 }\
13937 return (target_type) value;\
13938 }
13939
13940 /* CIntToPy */
__Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value)13941 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value) {
13942 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) ((unsigned PY_LONG_LONG) 0 - (unsigned PY_LONG_LONG) 1), const_zero = (unsigned PY_LONG_LONG) 0;
13943 const int is_unsigned = neg_one > const_zero;
13944 if (is_unsigned) {
13945 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
13946 return PyInt_FromLong((long) value);
13947 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
13948 return PyLong_FromUnsignedLong((unsigned long) value);
13949 #ifdef HAVE_LONG_LONG
13950 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
13951 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
13952 #endif
13953 }
13954 } else {
13955 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
13956 return PyInt_FromLong((long) value);
13957 #ifdef HAVE_LONG_LONG
13958 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
13959 return PyLong_FromLongLong((PY_LONG_LONG) value);
13960 #endif
13961 }
13962 }
13963 {
13964 int one = 1; int little = (int)*(unsigned char *)&one;
13965 unsigned char *bytes = (unsigned char *)&value;
13966 return _PyLong_FromByteArray(bytes, sizeof(unsigned PY_LONG_LONG),
13967 little, !is_unsigned);
13968 }
13969 }
13970
13971 /* CIntToPy */
__Pyx_PyInt_From_unsigned_int(unsigned int value)13972 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
13973 const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0;
13974 const int is_unsigned = neg_one > const_zero;
13975 if (is_unsigned) {
13976 if (sizeof(unsigned int) < sizeof(long)) {
13977 return PyInt_FromLong((long) value);
13978 } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
13979 return PyLong_FromUnsignedLong((unsigned long) value);
13980 #ifdef HAVE_LONG_LONG
13981 } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
13982 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
13983 #endif
13984 }
13985 } else {
13986 if (sizeof(unsigned int) <= sizeof(long)) {
13987 return PyInt_FromLong((long) value);
13988 #ifdef HAVE_LONG_LONG
13989 } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
13990 return PyLong_FromLongLong((PY_LONG_LONG) value);
13991 #endif
13992 }
13993 }
13994 {
13995 int one = 1; int little = (int)*(unsigned char *)&one;
13996 unsigned char *bytes = (unsigned char *)&value;
13997 return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
13998 little, !is_unsigned);
13999 }
14000 }
14001
14002 /* CIntToPy */
__Pyx_PyInt_From_unsigned_char(unsigned char value)14003 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_char(unsigned char value) {
14004 const unsigned char neg_one = (unsigned char) ((unsigned char) 0 - (unsigned char) 1), const_zero = (unsigned char) 0;
14005 const int is_unsigned = neg_one > const_zero;
14006 if (is_unsigned) {
14007 if (sizeof(unsigned char) < sizeof(long)) {
14008 return PyInt_FromLong((long) value);
14009 } else if (sizeof(unsigned char) <= sizeof(unsigned long)) {
14010 return PyLong_FromUnsignedLong((unsigned long) value);
14011 #ifdef HAVE_LONG_LONG
14012 } else if (sizeof(unsigned char) <= sizeof(unsigned PY_LONG_LONG)) {
14013 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
14014 #endif
14015 }
14016 } else {
14017 if (sizeof(unsigned char) <= sizeof(long)) {
14018 return PyInt_FromLong((long) value);
14019 #ifdef HAVE_LONG_LONG
14020 } else if (sizeof(unsigned char) <= sizeof(PY_LONG_LONG)) {
14021 return PyLong_FromLongLong((PY_LONG_LONG) value);
14022 #endif
14023 }
14024 }
14025 {
14026 int one = 1; int little = (int)*(unsigned char *)&one;
14027 unsigned char *bytes = (unsigned char *)&value;
14028 return _PyLong_FromByteArray(bytes, sizeof(unsigned char),
14029 little, !is_unsigned);
14030 }
14031 }
14032
14033 /* CIntToPy */
__Pyx_PyInt_From_long(long value)14034 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
14035 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
14036 const int is_unsigned = neg_one > const_zero;
14037 if (is_unsigned) {
14038 if (sizeof(long) < sizeof(long)) {
14039 return PyInt_FromLong((long) value);
14040 } else if (sizeof(long) <= sizeof(unsigned long)) {
14041 return PyLong_FromUnsignedLong((unsigned long) value);
14042 #ifdef HAVE_LONG_LONG
14043 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
14044 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
14045 #endif
14046 }
14047 } else {
14048 if (sizeof(long) <= sizeof(long)) {
14049 return PyInt_FromLong((long) value);
14050 #ifdef HAVE_LONG_LONG
14051 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
14052 return PyLong_FromLongLong((PY_LONG_LONG) value);
14053 #endif
14054 }
14055 }
14056 {
14057 int one = 1; int little = (int)*(unsigned char *)&one;
14058 unsigned char *bytes = (unsigned char *)&value;
14059 return _PyLong_FromByteArray(bytes, sizeof(long),
14060 little, !is_unsigned);
14061 }
14062 }
14063
14064 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)14065 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
14066 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
14067 const int is_unsigned = neg_one > const_zero;
14068 #if PY_MAJOR_VERSION < 3
14069 if (likely(PyInt_Check(x))) {
14070 if (sizeof(int) < sizeof(long)) {
14071 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
14072 } else {
14073 long val = PyInt_AS_LONG(x);
14074 if (is_unsigned && unlikely(val < 0)) {
14075 goto raise_neg_overflow;
14076 }
14077 return (int) val;
14078 }
14079 } else
14080 #endif
14081 if (likely(PyLong_Check(x))) {
14082 if (is_unsigned) {
14083 #if CYTHON_USE_PYLONG_INTERNALS
14084 const digit* digits = ((PyLongObject*)x)->ob_digit;
14085 switch (Py_SIZE(x)) {
14086 case 0: return (int) 0;
14087 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
14088 case 2:
14089 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
14090 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
14091 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14092 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
14093 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
14094 }
14095 }
14096 break;
14097 case 3:
14098 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
14099 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
14100 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14101 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
14102 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
14103 }
14104 }
14105 break;
14106 case 4:
14107 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
14108 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
14109 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14110 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
14111 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
14112 }
14113 }
14114 break;
14115 }
14116 #endif
14117 #if CYTHON_COMPILING_IN_CPYTHON
14118 if (unlikely(Py_SIZE(x) < 0)) {
14119 goto raise_neg_overflow;
14120 }
14121 #else
14122 {
14123 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
14124 if (unlikely(result < 0))
14125 return (int) -1;
14126 if (unlikely(result == 1))
14127 goto raise_neg_overflow;
14128 }
14129 #endif
14130 if (sizeof(int) <= sizeof(unsigned long)) {
14131 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
14132 #ifdef HAVE_LONG_LONG
14133 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
14134 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
14135 #endif
14136 }
14137 } else {
14138 #if CYTHON_USE_PYLONG_INTERNALS
14139 const digit* digits = ((PyLongObject*)x)->ob_digit;
14140 switch (Py_SIZE(x)) {
14141 case 0: return (int) 0;
14142 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
14143 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
14144 case -2:
14145 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
14146 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
14147 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14148 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
14149 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
14150 }
14151 }
14152 break;
14153 case 2:
14154 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
14155 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
14156 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14157 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
14158 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
14159 }
14160 }
14161 break;
14162 case -3:
14163 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
14164 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
14165 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14166 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
14167 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
14168 }
14169 }
14170 break;
14171 case 3:
14172 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
14173 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
14174 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14175 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
14176 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
14177 }
14178 }
14179 break;
14180 case -4:
14181 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
14182 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
14183 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14184 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
14185 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
14186 }
14187 }
14188 break;
14189 case 4:
14190 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
14191 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
14192 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14193 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
14194 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
14195 }
14196 }
14197 break;
14198 }
14199 #endif
14200 if (sizeof(int) <= sizeof(long)) {
14201 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
14202 #ifdef HAVE_LONG_LONG
14203 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
14204 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
14205 #endif
14206 }
14207 }
14208 {
14209 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
14210 PyErr_SetString(PyExc_RuntimeError,
14211 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
14212 #else
14213 int val;
14214 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
14215 #if PY_MAJOR_VERSION < 3
14216 if (likely(v) && !PyLong_Check(v)) {
14217 PyObject *tmp = v;
14218 v = PyNumber_Long(tmp);
14219 Py_DECREF(tmp);
14220 }
14221 #endif
14222 if (likely(v)) {
14223 int one = 1; int is_little = (int)*(unsigned char *)&one;
14224 unsigned char *bytes = (unsigned char *)&val;
14225 int ret = _PyLong_AsByteArray((PyLongObject *)v,
14226 bytes, sizeof(val),
14227 is_little, !is_unsigned);
14228 Py_DECREF(v);
14229 if (likely(!ret))
14230 return val;
14231 }
14232 #endif
14233 return (int) -1;
14234 }
14235 } else {
14236 int val;
14237 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
14238 if (!tmp) return (int) -1;
14239 val = __Pyx_PyInt_As_int(tmp);
14240 Py_DECREF(tmp);
14241 return val;
14242 }
14243 raise_overflow:
14244 PyErr_SetString(PyExc_OverflowError,
14245 "value too large to convert to int");
14246 return (int) -1;
14247 raise_neg_overflow:
14248 PyErr_SetString(PyExc_OverflowError,
14249 "can't convert negative value to int");
14250 return (int) -1;
14251 }
14252
14253 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)14254 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
14255 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
14256 const int is_unsigned = neg_one > const_zero;
14257 #if PY_MAJOR_VERSION < 3
14258 if (likely(PyInt_Check(x))) {
14259 if (sizeof(long) < sizeof(long)) {
14260 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
14261 } else {
14262 long val = PyInt_AS_LONG(x);
14263 if (is_unsigned && unlikely(val < 0)) {
14264 goto raise_neg_overflow;
14265 }
14266 return (long) val;
14267 }
14268 } else
14269 #endif
14270 if (likely(PyLong_Check(x))) {
14271 if (is_unsigned) {
14272 #if CYTHON_USE_PYLONG_INTERNALS
14273 const digit* digits = ((PyLongObject*)x)->ob_digit;
14274 switch (Py_SIZE(x)) {
14275 case 0: return (long) 0;
14276 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
14277 case 2:
14278 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
14279 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
14280 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14281 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
14282 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
14283 }
14284 }
14285 break;
14286 case 3:
14287 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
14288 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
14289 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14290 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
14291 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
14292 }
14293 }
14294 break;
14295 case 4:
14296 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
14297 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
14298 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14299 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
14300 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
14301 }
14302 }
14303 break;
14304 }
14305 #endif
14306 #if CYTHON_COMPILING_IN_CPYTHON
14307 if (unlikely(Py_SIZE(x) < 0)) {
14308 goto raise_neg_overflow;
14309 }
14310 #else
14311 {
14312 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
14313 if (unlikely(result < 0))
14314 return (long) -1;
14315 if (unlikely(result == 1))
14316 goto raise_neg_overflow;
14317 }
14318 #endif
14319 if (sizeof(long) <= sizeof(unsigned long)) {
14320 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
14321 #ifdef HAVE_LONG_LONG
14322 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
14323 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
14324 #endif
14325 }
14326 } else {
14327 #if CYTHON_USE_PYLONG_INTERNALS
14328 const digit* digits = ((PyLongObject*)x)->ob_digit;
14329 switch (Py_SIZE(x)) {
14330 case 0: return (long) 0;
14331 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
14332 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
14333 case -2:
14334 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
14335 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
14336 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14337 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
14338 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
14339 }
14340 }
14341 break;
14342 case 2:
14343 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
14344 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
14345 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14346 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
14347 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
14348 }
14349 }
14350 break;
14351 case -3:
14352 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
14353 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
14354 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14355 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
14356 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
14357 }
14358 }
14359 break;
14360 case 3:
14361 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
14362 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
14363 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14364 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
14365 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
14366 }
14367 }
14368 break;
14369 case -4:
14370 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
14371 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
14372 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14373 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
14374 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
14375 }
14376 }
14377 break;
14378 case 4:
14379 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
14380 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
14381 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14382 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
14383 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
14384 }
14385 }
14386 break;
14387 }
14388 #endif
14389 if (sizeof(long) <= sizeof(long)) {
14390 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
14391 #ifdef HAVE_LONG_LONG
14392 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
14393 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
14394 #endif
14395 }
14396 }
14397 {
14398 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
14399 PyErr_SetString(PyExc_RuntimeError,
14400 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
14401 #else
14402 long val;
14403 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
14404 #if PY_MAJOR_VERSION < 3
14405 if (likely(v) && !PyLong_Check(v)) {
14406 PyObject *tmp = v;
14407 v = PyNumber_Long(tmp);
14408 Py_DECREF(tmp);
14409 }
14410 #endif
14411 if (likely(v)) {
14412 int one = 1; int is_little = (int)*(unsigned char *)&one;
14413 unsigned char *bytes = (unsigned char *)&val;
14414 int ret = _PyLong_AsByteArray((PyLongObject *)v,
14415 bytes, sizeof(val),
14416 is_little, !is_unsigned);
14417 Py_DECREF(v);
14418 if (likely(!ret))
14419 return val;
14420 }
14421 #endif
14422 return (long) -1;
14423 }
14424 } else {
14425 long val;
14426 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
14427 if (!tmp) return (long) -1;
14428 val = __Pyx_PyInt_As_long(tmp);
14429 Py_DECREF(tmp);
14430 return val;
14431 }
14432 raise_overflow:
14433 PyErr_SetString(PyExc_OverflowError,
14434 "value too large to convert to long");
14435 return (long) -1;
14436 raise_neg_overflow:
14437 PyErr_SetString(PyExc_OverflowError,
14438 "can't convert negative value to long");
14439 return (long) -1;
14440 }
14441
14442 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_char(PyObject * x)14443 static CYTHON_INLINE unsigned char __Pyx_PyInt_As_unsigned_char(PyObject *x) {
14444 const unsigned char neg_one = (unsigned char) ((unsigned char) 0 - (unsigned char) 1), const_zero = (unsigned char) 0;
14445 const int is_unsigned = neg_one > const_zero;
14446 #if PY_MAJOR_VERSION < 3
14447 if (likely(PyInt_Check(x))) {
14448 if (sizeof(unsigned char) < sizeof(long)) {
14449 __PYX_VERIFY_RETURN_INT(unsigned char, long, PyInt_AS_LONG(x))
14450 } else {
14451 long val = PyInt_AS_LONG(x);
14452 if (is_unsigned && unlikely(val < 0)) {
14453 goto raise_neg_overflow;
14454 }
14455 return (unsigned char) val;
14456 }
14457 } else
14458 #endif
14459 if (likely(PyLong_Check(x))) {
14460 if (is_unsigned) {
14461 #if CYTHON_USE_PYLONG_INTERNALS
14462 const digit* digits = ((PyLongObject*)x)->ob_digit;
14463 switch (Py_SIZE(x)) {
14464 case 0: return (unsigned char) 0;
14465 case 1: __PYX_VERIFY_RETURN_INT(unsigned char, digit, digits[0])
14466 case 2:
14467 if (8 * sizeof(unsigned char) > 1 * PyLong_SHIFT) {
14468 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
14469 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14470 } else if (8 * sizeof(unsigned char) >= 2 * PyLong_SHIFT) {
14471 return (unsigned char) (((((unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0]));
14472 }
14473 }
14474 break;
14475 case 3:
14476 if (8 * sizeof(unsigned char) > 2 * PyLong_SHIFT) {
14477 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
14478 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14479 } else if (8 * sizeof(unsigned char) >= 3 * PyLong_SHIFT) {
14480 return (unsigned char) (((((((unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0]));
14481 }
14482 }
14483 break;
14484 case 4:
14485 if (8 * sizeof(unsigned char) > 3 * PyLong_SHIFT) {
14486 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
14487 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14488 } else if (8 * sizeof(unsigned char) >= 4 * PyLong_SHIFT) {
14489 return (unsigned char) (((((((((unsigned char)digits[3]) << PyLong_SHIFT) | (unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0]));
14490 }
14491 }
14492 break;
14493 }
14494 #endif
14495 #if CYTHON_COMPILING_IN_CPYTHON
14496 if (unlikely(Py_SIZE(x) < 0)) {
14497 goto raise_neg_overflow;
14498 }
14499 #else
14500 {
14501 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
14502 if (unlikely(result < 0))
14503 return (unsigned char) -1;
14504 if (unlikely(result == 1))
14505 goto raise_neg_overflow;
14506 }
14507 #endif
14508 if (sizeof(unsigned char) <= sizeof(unsigned long)) {
14509 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, unsigned long, PyLong_AsUnsignedLong(x))
14510 #ifdef HAVE_LONG_LONG
14511 } else if (sizeof(unsigned char) <= sizeof(unsigned PY_LONG_LONG)) {
14512 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
14513 #endif
14514 }
14515 } else {
14516 #if CYTHON_USE_PYLONG_INTERNALS
14517 const digit* digits = ((PyLongObject*)x)->ob_digit;
14518 switch (Py_SIZE(x)) {
14519 case 0: return (unsigned char) 0;
14520 case -1: __PYX_VERIFY_RETURN_INT(unsigned char, sdigit, (sdigit) (-(sdigit)digits[0]))
14521 case 1: __PYX_VERIFY_RETURN_INT(unsigned char, digit, +digits[0])
14522 case -2:
14523 if (8 * sizeof(unsigned char) - 1 > 1 * PyLong_SHIFT) {
14524 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
14525 __PYX_VERIFY_RETURN_INT(unsigned char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14526 } else if (8 * sizeof(unsigned char) - 1 > 2 * PyLong_SHIFT) {
14527 return (unsigned char) (((unsigned char)-1)*(((((unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
14528 }
14529 }
14530 break;
14531 case 2:
14532 if (8 * sizeof(unsigned char) > 1 * PyLong_SHIFT) {
14533 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
14534 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14535 } else if (8 * sizeof(unsigned char) - 1 > 2 * PyLong_SHIFT) {
14536 return (unsigned char) ((((((unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
14537 }
14538 }
14539 break;
14540 case -3:
14541 if (8 * sizeof(unsigned char) - 1 > 2 * PyLong_SHIFT) {
14542 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
14543 __PYX_VERIFY_RETURN_INT(unsigned char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14544 } else if (8 * sizeof(unsigned char) - 1 > 3 * PyLong_SHIFT) {
14545 return (unsigned char) (((unsigned char)-1)*(((((((unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
14546 }
14547 }
14548 break;
14549 case 3:
14550 if (8 * sizeof(unsigned char) > 2 * PyLong_SHIFT) {
14551 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
14552 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14553 } else if (8 * sizeof(unsigned char) - 1 > 3 * PyLong_SHIFT) {
14554 return (unsigned char) ((((((((unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
14555 }
14556 }
14557 break;
14558 case -4:
14559 if (8 * sizeof(unsigned char) - 1 > 3 * PyLong_SHIFT) {
14560 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
14561 __PYX_VERIFY_RETURN_INT(unsigned char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14562 } else if (8 * sizeof(unsigned char) - 1 > 4 * PyLong_SHIFT) {
14563 return (unsigned char) (((unsigned char)-1)*(((((((((unsigned char)digits[3]) << PyLong_SHIFT) | (unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
14564 }
14565 }
14566 break;
14567 case 4:
14568 if (8 * sizeof(unsigned char) > 3 * PyLong_SHIFT) {
14569 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
14570 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
14571 } else if (8 * sizeof(unsigned char) - 1 > 4 * PyLong_SHIFT) {
14572 return (unsigned char) ((((((((((unsigned char)digits[3]) << PyLong_SHIFT) | (unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
14573 }
14574 }
14575 break;
14576 }
14577 #endif
14578 if (sizeof(unsigned char) <= sizeof(long)) {
14579 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, long, PyLong_AsLong(x))
14580 #ifdef HAVE_LONG_LONG
14581 } else if (sizeof(unsigned char) <= sizeof(PY_LONG_LONG)) {
14582 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, PY_LONG_LONG, PyLong_AsLongLong(x))
14583 #endif
14584 }
14585 }
14586 {
14587 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
14588 PyErr_SetString(PyExc_RuntimeError,
14589 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
14590 #else
14591 unsigned char val;
14592 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
14593 #if PY_MAJOR_VERSION < 3
14594 if (likely(v) && !PyLong_Check(v)) {
14595 PyObject *tmp = v;
14596 v = PyNumber_Long(tmp);
14597 Py_DECREF(tmp);
14598 }
14599 #endif
14600 if (likely(v)) {
14601 int one = 1; int is_little = (int)*(unsigned char *)&one;
14602 unsigned char *bytes = (unsigned char *)&val;
14603 int ret = _PyLong_AsByteArray((PyLongObject *)v,
14604 bytes, sizeof(val),
14605 is_little, !is_unsigned);
14606 Py_DECREF(v);
14607 if (likely(!ret))
14608 return val;
14609 }
14610 #endif
14611 return (unsigned char) -1;
14612 }
14613 } else {
14614 unsigned char val;
14615 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
14616 if (!tmp) return (unsigned char) -1;
14617 val = __Pyx_PyInt_As_unsigned_char(tmp);
14618 Py_DECREF(tmp);
14619 return val;
14620 }
14621 raise_overflow:
14622 PyErr_SetString(PyExc_OverflowError,
14623 "value too large to convert to unsigned char");
14624 return (unsigned char) -1;
14625 raise_neg_overflow:
14626 PyErr_SetString(PyExc_OverflowError,
14627 "can't convert negative value to unsigned char");
14628 return (unsigned char) -1;
14629 }
14630
14631 /* FastTypeChecks */
14632 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)14633 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
14634 while (a) {
14635 a = a->tp_base;
14636 if (a == b)
14637 return 1;
14638 }
14639 return b == &PyBaseObject_Type;
14640 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)14641 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
14642 PyObject *mro;
14643 if (a == b) return 1;
14644 mro = a->tp_mro;
14645 if (likely(mro)) {
14646 Py_ssize_t i, n;
14647 n = PyTuple_GET_SIZE(mro);
14648 for (i = 0; i < n; i++) {
14649 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
14650 return 1;
14651 }
14652 return 0;
14653 }
14654 return __Pyx_InBases(a, b);
14655 }
14656 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)14657 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
14658 PyObject *exception, *value, *tb;
14659 int res;
14660 __Pyx_PyThreadState_declare
14661 __Pyx_PyThreadState_assign
14662 __Pyx_ErrFetch(&exception, &value, &tb);
14663 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
14664 if (unlikely(res == -1)) {
14665 PyErr_WriteUnraisable(err);
14666 res = 0;
14667 }
14668 if (!res) {
14669 res = PyObject_IsSubclass(err, exc_type2);
14670 if (unlikely(res == -1)) {
14671 PyErr_WriteUnraisable(err);
14672 res = 0;
14673 }
14674 }
14675 __Pyx_ErrRestore(exception, value, tb);
14676 return res;
14677 }
14678 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)14679 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
14680 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
14681 if (!res) {
14682 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
14683 }
14684 return res;
14685 }
14686 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)14687 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
14688 Py_ssize_t i, n;
14689 assert(PyExceptionClass_Check(exc_type));
14690 n = PyTuple_GET_SIZE(tuple);
14691 #if PY_MAJOR_VERSION >= 3
14692 for (i=0; i<n; i++) {
14693 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
14694 }
14695 #endif
14696 for (i=0; i<n; i++) {
14697 PyObject *t = PyTuple_GET_ITEM(tuple, i);
14698 #if PY_MAJOR_VERSION < 3
14699 if (likely(exc_type == t)) return 1;
14700 #endif
14701 if (likely(PyExceptionClass_Check(t))) {
14702 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
14703 } else {
14704 }
14705 }
14706 return 0;
14707 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)14708 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
14709 if (likely(err == exc_type)) return 1;
14710 if (likely(PyExceptionClass_Check(err))) {
14711 if (likely(PyExceptionClass_Check(exc_type))) {
14712 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
14713 } else if (likely(PyTuple_Check(exc_type))) {
14714 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
14715 } else {
14716 }
14717 }
14718 return PyErr_GivenExceptionMatches(err, exc_type);
14719 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)14720 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
14721 assert(PyExceptionClass_Check(exc_type1));
14722 assert(PyExceptionClass_Check(exc_type2));
14723 if (likely(err == exc_type1 || err == exc_type2)) return 1;
14724 if (likely(PyExceptionClass_Check(err))) {
14725 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
14726 }
14727 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
14728 }
14729 #endif
14730
14731 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)14732 static int __Pyx_check_binary_version(void) {
14733 char ctversion[4], rtversion[4];
14734 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
14735 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
14736 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
14737 char message[200];
14738 PyOS_snprintf(message, sizeof(message),
14739 "compiletime version %s of module '%.100s' "
14740 "does not match runtime version %s",
14741 ctversion, __Pyx_MODULE_NAME, rtversion);
14742 return PyErr_WarnEx(NULL, message, 1);
14743 }
14744 return 0;
14745 }
14746
14747 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)14748 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
14749 while (t->p) {
14750 #if PY_MAJOR_VERSION < 3
14751 if (t->is_unicode) {
14752 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
14753 } else if (t->intern) {
14754 *t->p = PyString_InternFromString(t->s);
14755 } else {
14756 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
14757 }
14758 #else
14759 if (t->is_unicode | t->is_str) {
14760 if (t->intern) {
14761 *t->p = PyUnicode_InternFromString(t->s);
14762 } else if (t->encoding) {
14763 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
14764 } else {
14765 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
14766 }
14767 } else {
14768 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
14769 }
14770 #endif
14771 if (!*t->p)
14772 return -1;
14773 if (PyObject_Hash(*t->p) == -1)
14774 return -1;
14775 ++t;
14776 }
14777 return 0;
14778 }
14779
__Pyx_PyUnicode_FromString(const char * c_str)14780 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
14781 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
14782 }
__Pyx_PyObject_AsString(PyObject * o)14783 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
14784 Py_ssize_t ignore;
14785 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
14786 }
14787 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
14788 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)14789 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
14790 char* defenc_c;
14791 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
14792 if (!defenc) return NULL;
14793 defenc_c = PyBytes_AS_STRING(defenc);
14794 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
14795 {
14796 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
14797 char* c;
14798 for (c = defenc_c; c < end; c++) {
14799 if ((unsigned char) (*c) >= 128) {
14800 PyUnicode_AsASCIIString(o);
14801 return NULL;
14802 }
14803 }
14804 }
14805 #endif
14806 *length = PyBytes_GET_SIZE(defenc);
14807 return defenc_c;
14808 }
14809 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)14810 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
14811 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
14812 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
14813 if (likely(PyUnicode_IS_ASCII(o))) {
14814 *length = PyUnicode_GET_LENGTH(o);
14815 return PyUnicode_AsUTF8(o);
14816 } else {
14817 PyUnicode_AsASCIIString(o);
14818 return NULL;
14819 }
14820 #else
14821 return PyUnicode_AsUTF8AndSize(o, length);
14822 #endif
14823 }
14824 #endif
14825 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)14826 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
14827 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
14828 if (
14829 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
14830 __Pyx_sys_getdefaultencoding_not_ascii &&
14831 #endif
14832 PyUnicode_Check(o)) {
14833 return __Pyx_PyUnicode_AsStringAndSize(o, length);
14834 } else
14835 #endif
14836 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
14837 if (PyByteArray_Check(o)) {
14838 *length = PyByteArray_GET_SIZE(o);
14839 return PyByteArray_AS_STRING(o);
14840 } else
14841 #endif
14842 {
14843 char* result;
14844 int r = PyBytes_AsStringAndSize(o, &result, length);
14845 if (unlikely(r < 0)) {
14846 return NULL;
14847 } else {
14848 return result;
14849 }
14850 }
14851 }
__Pyx_PyObject_IsTrue(PyObject * x)14852 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
14853 int is_true = x == Py_True;
14854 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
14855 else return PyObject_IsTrue(x);
14856 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)14857 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
14858 int retval;
14859 if (unlikely(!x)) return -1;
14860 retval = __Pyx_PyObject_IsTrue(x);
14861 Py_DECREF(x);
14862 return retval;
14863 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)14864 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
14865 #if PY_MAJOR_VERSION >= 3
14866 if (PyLong_Check(result)) {
14867 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
14868 "__int__ returned non-int (type %.200s). "
14869 "The ability to return an instance of a strict subclass of int "
14870 "is deprecated, and may be removed in a future version of Python.",
14871 Py_TYPE(result)->tp_name)) {
14872 Py_DECREF(result);
14873 return NULL;
14874 }
14875 return result;
14876 }
14877 #endif
14878 PyErr_Format(PyExc_TypeError,
14879 "__%.4s__ returned non-%.4s (type %.200s)",
14880 type_name, type_name, Py_TYPE(result)->tp_name);
14881 Py_DECREF(result);
14882 return NULL;
14883 }
__Pyx_PyNumber_IntOrLong(PyObject * x)14884 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
14885 #if CYTHON_USE_TYPE_SLOTS
14886 PyNumberMethods *m;
14887 #endif
14888 const char *name = NULL;
14889 PyObject *res = NULL;
14890 #if PY_MAJOR_VERSION < 3
14891 if (likely(PyInt_Check(x) || PyLong_Check(x)))
14892 #else
14893 if (likely(PyLong_Check(x)))
14894 #endif
14895 return __Pyx_NewRef(x);
14896 #if CYTHON_USE_TYPE_SLOTS
14897 m = Py_TYPE(x)->tp_as_number;
14898 #if PY_MAJOR_VERSION < 3
14899 if (m && m->nb_int) {
14900 name = "int";
14901 res = m->nb_int(x);
14902 }
14903 else if (m && m->nb_long) {
14904 name = "long";
14905 res = m->nb_long(x);
14906 }
14907 #else
14908 if (likely(m && m->nb_int)) {
14909 name = "int";
14910 res = m->nb_int(x);
14911 }
14912 #endif
14913 #else
14914 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
14915 res = PyNumber_Int(x);
14916 }
14917 #endif
14918 if (likely(res)) {
14919 #if PY_MAJOR_VERSION < 3
14920 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
14921 #else
14922 if (unlikely(!PyLong_CheckExact(res))) {
14923 #endif
14924 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
14925 }
14926 }
14927 else if (!PyErr_Occurred()) {
14928 PyErr_SetString(PyExc_TypeError,
14929 "an integer is required");
14930 }
14931 return res;
14932 }
14933 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
14934 Py_ssize_t ival;
14935 PyObject *x;
14936 #if PY_MAJOR_VERSION < 3
14937 if (likely(PyInt_CheckExact(b))) {
14938 if (sizeof(Py_ssize_t) >= sizeof(long))
14939 return PyInt_AS_LONG(b);
14940 else
14941 return PyInt_AsSsize_t(b);
14942 }
14943 #endif
14944 if (likely(PyLong_CheckExact(b))) {
14945 #if CYTHON_USE_PYLONG_INTERNALS
14946 const digit* digits = ((PyLongObject*)b)->ob_digit;
14947 const Py_ssize_t size = Py_SIZE(b);
14948 if (likely(__Pyx_sst_abs(size) <= 1)) {
14949 ival = likely(size) ? digits[0] : 0;
14950 if (size == -1) ival = -ival;
14951 return ival;
14952 } else {
14953 switch (size) {
14954 case 2:
14955 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
14956 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
14957 }
14958 break;
14959 case -2:
14960 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
14961 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
14962 }
14963 break;
14964 case 3:
14965 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
14966 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
14967 }
14968 break;
14969 case -3:
14970 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
14971 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
14972 }
14973 break;
14974 case 4:
14975 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
14976 return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
14977 }
14978 break;
14979 case -4:
14980 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
14981 return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
14982 }
14983 break;
14984 }
14985 }
14986 #endif
14987 return PyLong_AsSsize_t(b);
14988 }
14989 x = PyNumber_Index(b);
14990 if (!x) return -1;
14991 ival = PyInt_AsSsize_t(x);
14992 Py_DECREF(x);
14993 return ival;
14994 }
14995 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
14996 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
14997 }
14998 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
14999 return PyInt_FromSize_t(ival);
15000 }
15001
15002
15003 #endif /* Py_PYTHON_H */
15004