Show More
@@ -81,7 +81,6 b' struct indexObjectStruct {' | |||||
81 | /* Type-specific fields go here. */ |
|
81 | /* Type-specific fields go here. */ | |
82 | PyObject *data; /* raw bytes of index */ |
|
82 | PyObject *data; /* raw bytes of index */ | |
83 | Py_buffer buf; /* buffer of data */ |
|
83 | Py_buffer buf; /* buffer of data */ | |
84 | PyObject **cache; /* cached tuples */ |
|
|||
85 | const char **offsets; /* populated on demand */ |
|
84 | const char **offsets; /* populated on demand */ | |
86 | Py_ssize_t raw_length; /* original number of elements */ |
|
85 | Py_ssize_t raw_length; /* original number of elements */ | |
87 | Py_ssize_t length; /* current number of elements */ |
|
86 | Py_ssize_t length; /* current number of elements */ | |
@@ -327,7 +326,6 b' static PyObject *index_get(indexObject *' | |||||
327 | const char *c_node_id; |
|
326 | const char *c_node_id; | |
328 | const char *data; |
|
327 | const char *data; | |
329 | Py_ssize_t length = index_length(self); |
|
328 | Py_ssize_t length = index_length(self); | |
330 | PyObject *entry; |
|
|||
331 |
|
329 | |||
332 | if (pos == nullrev) { |
|
330 | if (pos == nullrev) { | |
333 | Py_INCREF(nullentry); |
|
331 | Py_INCREF(nullentry); | |
@@ -346,17 +344,6 b' static PyObject *index_get(indexObject *' | |||||
346 | return obj; |
|
344 | return obj; | |
347 | } |
|
345 | } | |
348 |
|
346 | |||
349 | if (self->cache) { |
|
|||
350 | if (self->cache[pos]) { |
|
|||
351 | Py_INCREF(self->cache[pos]); |
|
|||
352 | return self->cache[pos]; |
|
|||
353 | } |
|
|||
354 | } else { |
|
|||
355 | self->cache = calloc(self->raw_length, sizeof(PyObject *)); |
|
|||
356 | if (self->cache == NULL) |
|
|||
357 | return PyErr_NoMemory(); |
|
|||
358 | } |
|
|||
359 |
|
||||
360 | data = index_deref(self, pos); |
|
347 | data = index_deref(self, pos); | |
361 | if (data == NULL) |
|
348 | if (data == NULL) | |
362 | return NULL; |
|
349 | return NULL; | |
@@ -377,18 +364,9 b' static PyObject *index_get(indexObject *' | |||||
377 | parent_2 = getbe32(data + 28); |
|
364 | parent_2 = getbe32(data + 28); | |
378 | c_node_id = data + 32; |
|
365 | c_node_id = data + 32; | |
379 |
|
366 | |||
380 |
|
|
367 | return Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len, | |
381 |
|
|
368 | base_rev, link_rev, parent_1, parent_2, c_node_id, | |
382 |
|
|
369 | (Py_ssize_t)20); | |
383 |
|
||||
384 | if (entry) { |
|
|||
385 | PyObject_GC_UnTrack(entry); |
|
|||
386 | Py_INCREF(entry); |
|
|||
387 | } |
|
|||
388 |
|
||||
389 | self->cache[pos] = entry; |
|
|||
390 |
|
||||
391 | return entry; |
|
|||
392 | } |
|
370 | } | |
393 |
|
371 | |||
394 | /* |
|
372 | /* | |
@@ -2578,14 +2556,8 b' static int index_slice_del(indexObject *' | |||||
2578 | } |
|
2556 | } | |
2579 |
|
2557 | |||
2580 | self->length = start; |
|
2558 | self->length = start; | |
2581 |
if (start < self->raw_length) |
|
2559 | if (start < self->raw_length) | |
2582 | if (self->cache) { |
|
|||
2583 | Py_ssize_t i; |
|
|||
2584 | for (i = start; i < self->raw_length; i++) |
|
|||
2585 | Py_CLEAR(self->cache[i]); |
|
|||
2586 | } |
|
|||
2587 | self->raw_length = start; |
|
2560 | self->raw_length = start; | |
2588 | } |
|
|||
2589 | goto done; |
|
2561 | goto done; | |
2590 | } |
|
2562 | } | |
2591 |
|
2563 | |||
@@ -2677,7 +2649,6 b' static int index_init(indexObject *self,' | |||||
2677 | */ |
|
2649 | */ | |
2678 | self->raw_length = 0; |
|
2650 | self->raw_length = 0; | |
2679 | self->added = NULL; |
|
2651 | self->added = NULL; | |
2680 | self->cache = NULL; |
|
|||
2681 | self->data = NULL; |
|
2652 | self->data = NULL; | |
2682 | memset(&self->buf, 0, sizeof(self->buf)); |
|
2653 | memset(&self->buf, 0, sizeof(self->buf)); | |
2683 | self->headrevs = NULL; |
|
2654 | self->headrevs = NULL; | |
@@ -2733,14 +2704,6 b' static PyObject *index_nodemap(indexObje' | |||||
2733 |
|
2704 | |||
2734 | static void _index_clearcaches(indexObject *self) |
|
2705 | static void _index_clearcaches(indexObject *self) | |
2735 | { |
|
2706 | { | |
2736 | if (self->cache) { |
|
|||
2737 | Py_ssize_t i; |
|
|||
2738 |
|
||||
2739 | for (i = 0; i < self->raw_length; i++) |
|
|||
2740 | Py_CLEAR(self->cache[i]); |
|
|||
2741 | free(self->cache); |
|
|||
2742 | self->cache = NULL; |
|
|||
2743 | } |
|
|||
2744 | if (self->offsets) { |
|
2707 | if (self->offsets) { | |
2745 | PyMem_Free((void *)self->offsets); |
|
2708 | PyMem_Free((void *)self->offsets); | |
2746 | self->offsets = NULL; |
|
2709 | self->offsets = NULL; |
General Comments 0
You need to be logged in to leave comments.
Login now