File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44#error must include "stringlib/fastsearch.h" before including this module
55#endif
66
7+ #include "pycore_list.h" // _PyList_AppendTakeRef()
8+
79/* Overallocate the initial list to reduce the number of reallocs for small
810 split sizes. Eg, "A A A A A A A A A A".split() (10 elements) has three
911 resizes, to sizes 4, 8, then 16. Most observed string splits are for human
2224 (right) - (left)); \
2325 if (sub == NULL) \
2426 goto onError; \
25- if (PyList_Append(list, sub)) { \
26- Py_DECREF(sub); \
27- goto onError; \
28- } \
29- else \
30- Py_DECREF(sub);
27+ if (_PyList_AppendTakeRef((PyListObject *)list, sub)) \
28+ goto onError;
3129
3230#define SPLIT_ADD (data , left , right ) { \
3331 sub = STRINGLIB_NEW((data) + (left), \
3735 if (count < MAX_PREALLOC) { \
3836 PyList_SET_ITEM(list, count, sub); \
3937 } else { \
40- if (PyList_Append(list, sub)) { \
41- Py_DECREF(sub); \
38+ if (_PyList_AppendTakeRef((PyListObject *)list, sub)) \
4239 goto onError; \
43- } \
44- else \
45- Py_DECREF(sub); \
4640 } \
4741 count++; }
4842
You can’t perform that action at this time.
0 commit comments