Show More
@@ -753,6 +753,7 b' typedef struct {' | |||
|
753 | 753 | PyObject_HEAD |
|
754 | 754 | /* Type-specific fields go here. */ |
|
755 | 755 | PyObject *data; /* raw bytes of index */ |
|
756 | Py_buffer buf; /* buffer of data */ | |
|
756 | 757 | PyObject **cache; /* cached tuples */ |
|
757 | 758 | const char **offsets; /* populated on demand */ |
|
758 | 759 | Py_ssize_t raw_length; /* original number of elements */ |
@@ -808,7 +809,7 b' static const char *index_deref(indexObje' | |||
|
808 | 809 | return self->offsets[pos]; |
|
809 | 810 | } |
|
810 | 811 | |
|
811 |
return |
|
|
812 | return (const char *)(self->buf.buf) + pos * v1_hdrsize; | |
|
812 | 813 | } |
|
813 | 814 | |
|
814 | 815 | static inline int index_get_parents(indexObject *self, Py_ssize_t rev, |
@@ -2389,9 +2390,9 b' static int index_assign_subscript(indexO' | |||
|
2389 | 2390 | */ |
|
2390 | 2391 | static Py_ssize_t inline_scan(indexObject *self, const char **offsets) |
|
2391 | 2392 | { |
|
2392 | const char *data = PyBytes_AS_STRING(self->data); | |
|
2393 | const char *data = (const char *)self->buf.buf; | |
|
2393 | 2394 | Py_ssize_t pos = 0; |
|
2394 |
Py_ssize_t end = |
|
|
2395 | Py_ssize_t end = self->buf.len; | |
|
2395 | 2396 | long incr = v1_hdrsize; |
|
2396 | 2397 | Py_ssize_t len = 0; |
|
2397 | 2398 | |
@@ -2425,6 +2426,7 b' static int index_init(indexObject *self,' | |||
|
2425 | 2426 | self->added = NULL; |
|
2426 | 2427 | self->cache = NULL; |
|
2427 | 2428 | self->data = NULL; |
|
2429 | memset(&self->buf, 0, sizeof(self->buf)); | |
|
2428 | 2430 | self->headrevs = NULL; |
|
2429 | 2431 | self->filteredrevs = Py_None; |
|
2430 | 2432 | Py_INCREF(Py_None); |
@@ -2433,11 +2435,15 b' static int index_init(indexObject *self,' | |||
|
2433 | 2435 | |
|
2434 | 2436 | if (!PyArg_ParseTuple(args, "OO", &data_obj, &inlined_obj)) |
|
2435 | 2437 | return -1; |
|
2436 |
if (!Py |
|
|
2437 |
PyErr_SetString(PyExc_TypeError, |
|
|
2438 | if (!PyObject_CheckBuffer(data_obj)) { | |
|
2439 | PyErr_SetString(PyExc_TypeError, | |
|
2440 | "data does not support buffer interface"); | |
|
2438 | 2441 | return -1; |
|
2439 | 2442 | } |
|
2440 | size = PyBytes_GET_SIZE(data_obj); | |
|
2443 | ||
|
2444 | if (PyObject_GetBuffer(data_obj, &self->buf, PyBUF_SIMPLE) == -1) | |
|
2445 | return -1; | |
|
2446 | size = self->buf.len; | |
|
2441 | 2447 | |
|
2442 | 2448 | self->inlined = inlined_obj && PyObject_IsTrue(inlined_obj); |
|
2443 | 2449 | self->data = data_obj; |
@@ -2478,6 +2484,10 b' static void index_dealloc(indexObject *s' | |||
|
2478 | 2484 | { |
|
2479 | 2485 | _index_clearcaches(self); |
|
2480 | 2486 | Py_XDECREF(self->filteredrevs); |
|
2487 | if (self->buf.buf) { | |
|
2488 | PyBuffer_Release(&self->buf); | |
|
2489 | memset(&self->buf, 0, sizeof(self->buf)); | |
|
2490 | } | |
|
2481 | 2491 | Py_XDECREF(self->data); |
|
2482 | 2492 | Py_XDECREF(self->added); |
|
2483 | 2493 | PyObject_Del(self); |
@@ -2577,7 +2587,8 b' static PyTypeObject indexType = {' | |||
|
2577 | 2587 | * follows: |
|
2578 | 2588 | * |
|
2579 | 2589 | * index: an index object that lazily parses RevlogNG records |
|
2580 |
* cache: if data is inlined, a tuple (index_file_content |
|
|
2590 | * cache: if data is inlined, a tuple (0, index_file_content), else None | |
|
2591 | * index_file_content could be a string, or a buffer | |
|
2581 | 2592 | * |
|
2582 | 2593 | * added complications are for backwards compatibility |
|
2583 | 2594 | */ |
General Comments 0
You need to be logged in to leave comments.
Login now