##// END OF EJS Templates
revlog: don't cache parsed tuples in the C module...
Joerg Sonnenberger -
r46402:9c6f9a1a default draft
parent child Browse files
Show More
@@ -81,7 +81,6 b' struct indexObjectStruct {'
81 81 /* Type-specific fields go here. */
82 82 PyObject *data; /* raw bytes of index */
83 83 Py_buffer buf; /* buffer of data */
84 PyObject **cache; /* cached tuples */
85 84 const char **offsets; /* populated on demand */
86 85 Py_ssize_t raw_length; /* original number of elements */
87 86 Py_ssize_t length; /* current number of elements */
@@ -327,7 +326,6 b' static PyObject *index_get(indexObject *'
327 326 const char *c_node_id;
328 327 const char *data;
329 328 Py_ssize_t length = index_length(self);
330 PyObject *entry;
331 329
332 330 if (pos == nullrev) {
333 331 Py_INCREF(nullentry);
@@ -346,17 +344,6 b' static PyObject *index_get(indexObject *'
346 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 347 data = index_deref(self, pos);
361 348 if (data == NULL)
362 349 return NULL;
@@ -377,18 +364,9 b' static PyObject *index_get(indexObject *'
377 364 parent_2 = getbe32(data + 28);
378 365 c_node_id = data + 32;
379 366
380 entry = Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len,
381 base_rev, link_rev, parent_1, parent_2, c_node_id,
382 (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;
367 return Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len,
368 base_rev, link_rev, parent_1, parent_2, c_node_id,
369 (Py_ssize_t)20);
392 370 }
393 371
394 372 /*
@@ -2578,14 +2556,8 b' static int index_slice_del(indexObject *'
2578 2556 }
2579 2557
2580 2558 self->length = start;
2581 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 }
2559 if (start < self->raw_length)
2587 2560 self->raw_length = start;
2588 }
2589 2561 goto done;
2590 2562 }
2591 2563
@@ -2677,7 +2649,6 b' static int index_init(indexObject *self,'
2677 2649 */
2678 2650 self->raw_length = 0;
2679 2651 self->added = NULL;
2680 self->cache = NULL;
2681 2652 self->data = NULL;
2682 2653 memset(&self->buf, 0, sizeof(self->buf));
2683 2654 self->headrevs = NULL;
@@ -2733,14 +2704,6 b' static PyObject *index_nodemap(indexObje'
2733 2704
2734 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 2707 if (self->offsets) {
2745 2708 PyMem_Free((void *)self->offsets);
2746 2709 self->offsets = NULL;
General Comments 0
You need to be logged in to leave comments. Login now