Show More
@@ -470,8 +470,10 b' static void _index_clearcaches(indexObje' | |||
|
470 | 470 | Py_ssize_t i; |
|
471 | 471 | |
|
472 | 472 | for (i = 0; i < self->raw_length; i++) { |
|
473 |
|
|
|
474 |
self->cache[i] |
|
|
473 | if (self->cache[i]) { | |
|
474 | Py_DECREF(self->cache[i]); | |
|
475 | self->cache[i] = NULL; | |
|
476 | } | |
|
475 | 477 | } |
|
476 | 478 | free(self->cache); |
|
477 | 479 | self->cache = NULL; |
@@ -957,9 +959,19 b' static long inline_scan(indexObject *sel' | |||
|
957 | 959 | return len; |
|
958 | 960 | } |
|
959 | 961 | |
|
960 |
static int index_ |
|
|
961 | PyObject *inlined_obj, PyObject *data_obj) | |
|
962 | static int index_init(indexObject *self, PyObject *args) | |
|
962 | 963 | { |
|
964 | PyObject *data_obj, *inlined_obj; | |
|
965 | Py_ssize_t size; | |
|
966 | ||
|
967 | if (!PyArg_ParseTuple(args, "OO", &data_obj, &inlined_obj)) | |
|
968 | return -1; | |
|
969 | if (!PyString_Check(data_obj)) { | |
|
970 | PyErr_SetString(PyExc_TypeError, "data is not a string"); | |
|
971 | return -1; | |
|
972 | } | |
|
973 | size = PyString_GET_SIZE(data_obj); | |
|
974 | ||
|
963 | 975 | self->inlined = inlined_obj && PyObject_IsTrue(inlined_obj); |
|
964 | 976 | self->data = data_obj; |
|
965 | 977 | self->cache = NULL; |
@@ -971,7 +983,6 b' static int index_real_init(indexObject *' | |||
|
971 | 983 | self->ntdepth = self->ntsplits = 0; |
|
972 | 984 | self->ntlookups = self->ntmisses = 0; |
|
973 | 985 | self->ntrev = -1; |
|
974 | Py_INCREF(self->data); | |
|
975 | 986 | |
|
976 | 987 | if (self->inlined) { |
|
977 | 988 | long len = inline_scan(self, NULL); |
@@ -987,27 +998,16 b' static int index_real_init(indexObject *' | |||
|
987 | 998 | self->raw_length = size / 64; |
|
988 | 999 | self->length = self->raw_length + 1; |
|
989 | 1000 | } |
|
1001 | Py_INCREF(self->data); | |
|
990 | 1002 | |
|
991 | 1003 | return 0; |
|
992 | 1004 | bail: |
|
993 | 1005 | return -1; |
|
994 | 1006 | } |
|
995 | 1007 | |
|
996 | static int index_init(indexObject *self, PyObject *args, PyObject *kwds) | |
|
997 | { | |
|
998 | const char *data; | |
|
999 | int size; | |
|
1000 | PyObject *inlined_obj; | |
|
1001 | ||
|
1002 | if (!PyArg_ParseTuple(args, "s#O", &data, &size, &inlined_obj)) | |
|
1003 | return -1; | |
|
1004 | ||
|
1005 | return index_real_init(self, data, size, inlined_obj, | |
|
1006 | PyTuple_GET_ITEM(args, 0)); | |
|
1007 | } | |
|
1008 | ||
|
1009 | 1008 | static PyObject *index_nodemap(indexObject *self) |
|
1010 | 1009 | { |
|
1010 | Py_INCREF(self); | |
|
1011 | 1011 | return (PyObject *)self; |
|
1012 | 1012 | } |
|
1013 | 1013 | |
@@ -1106,26 +1106,19 b' static PyTypeObject indexType = {' | |||
|
1106 | 1106 | */ |
|
1107 | 1107 | static PyObject *parse_index2(PyObject *self, PyObject *args) |
|
1108 | 1108 | { |
|
1109 | const char *data; | |
|
1110 | int size, ret; | |
|
1111 | PyObject *inlined_obj, *tuple = NULL, *cache = NULL; | |
|
1109 | PyObject *tuple = NULL, *cache = NULL; | |
|
1112 | 1110 | indexObject *idx; |
|
1113 | ||
|
1114 | if (!PyArg_ParseTuple(args, "s#O", &data, &size, &inlined_obj)) | |
|
1115 | return NULL; | |
|
1111 | int ret; | |
|
1116 | 1112 | |
|
1117 | 1113 | idx = PyObject_New(indexObject, &indexType); |
|
1118 | ||
|
1119 | 1114 | if (idx == NULL) |
|
1120 | 1115 | goto bail; |
|
1121 | 1116 | |
|
1122 |
ret = index_ |
|
|
1123 | PyTuple_GET_ITEM(args, 0)); | |
|
1124 | if (ret) | |
|
1117 | ret = index_init(idx, args); | |
|
1118 | if (ret == -1) | |
|
1125 | 1119 | goto bail; |
|
1126 | 1120 | |
|
1127 | 1121 | if (idx->inlined) { |
|
1128 | Py_INCREF(idx->data); | |
|
1129 | 1122 | cache = Py_BuildValue("iO", 0, idx->data); |
|
1130 | 1123 | if (cache == NULL) |
|
1131 | 1124 | goto bail; |
@@ -1134,8 +1127,6 b' static PyObject *parse_index2(PyObject *' | |||
|
1134 | 1127 | Py_INCREF(cache); |
|
1135 | 1128 | } |
|
1136 | 1129 | |
|
1137 | Py_INCREF(idx); | |
|
1138 | ||
|
1139 | 1130 | tuple = Py_BuildValue("NN", idx, cache); |
|
1140 | 1131 | if (!tuple) |
|
1141 | 1132 | goto bail; |
General Comments 0
You need to be logged in to leave comments.
Login now