/home/mdboom/Work/builds/cpython/Objects/stringlib/split.h
Line | Count | Source (jump to first uncovered line) |
1 | /* stringlib: split implementation */ |
2 | |
3 | #ifndef STRINGLIB_FASTSEARCH_H |
4 | #error must include "stringlib/fastsearch.h" before including this module |
5 | #endif |
6 | |
7 | /* Overallocate the initial list to reduce the number of reallocs for small |
8 | split sizes. Eg, "A A A A A A A A A A".split() (10 elements) has three |
9 | resizes, to sizes 4, 8, then 16. Most observed string splits are for human |
10 | text (roughly 11 words per line) and field delimited data (usually 1-10 |
11 | fields). For large strings the split algorithms are bandwidth limited |
12 | so increasing the preallocation likely will not improve things.*/ |
13 | |
14 | #define MAX_PREALLOC 12 |
15 | |
16 | /* 5 splits gives 6 elements */ |
17 | #define PREALLOC_SIZE(maxsplit) \ |
18 | (maxsplit >= MAX_PREALLOC ? MAX_PREALLOC1.45M : maxsplit+1312k ) |
19 | |
20 | #define SPLIT_APPEND(data, left, right) \ |
21 | sub = STRINGLIB_NEW((data) + (left), \ |
22 | (right) - (left)); \ |
23 | if (sub == NULL) \ |
24 | goto onError0 ; \ |
25 | if (PyList_Append(list, sub)) { \ |
26 | Py_DECREF(sub); \ |
27 | goto onError; \ |
28 | } \ |
29 | else \ |
30 | Py_DECREF(sub); |
31 | |
32 | #define SPLIT_ADD(data, left, right) { \ |
33 | sub = STRINGLIB_NEW((data) + (left), \ |
34 | (right) - (left)); \ |
35 | if (sub == NULL) \ |
36 | goto onError0 ; \ |
37 | if (count < MAX_PREALLOC) { \ |
38 | PyList_SET_ITEM(list, count, sub); \ |
39 | } else { \ |
40 | if (PyList_Append(list, sub)) { \ |
41 | Py_DECREF(sub); \ |
42 | goto onError; \ |
43 | } \ |
44 | else \ |
45 | Py_DECREF(sub); \ |
46 | } \ |
47 | count++; } |
48 | |
49 | |
50 | /* Always force the list to the expected size. */ |
51 | #define FIX_PREALLOC_SIZE(list) Py_SET_SIZE(list, count) |
52 | |
53 | Py_LOCAL_INLINE(PyObject *) |
54 | STRINGLIB(split_whitespace)(PyObject* str_obj, |
55 | const STRINGLIB_CHAR* str, Py_ssize_t str_len, |
56 | Py_ssize_t maxcount) |
57 | { |
58 | Py_ssize_t i, j, count=0; |
59 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); |
60 | PyObject *sub; |
61 | |
62 | if (list == NULL) Branch (62:9): [True: 0, False: 45]
Branch (62:9): [True: 0, False: 146]
Branch (62:9): [True: 0, False: 55.2k]
Branch (62:9): [True: 0, False: 9]
Branch (62:9): [True: 0, False: 1]
Branch (62:9): [True: 0, False: 0]
|
63 | return NULL; |
64 | |
65 | i = j = 0; |
66 | while (maxcount-- > 0) { Branch (66:12): [True: 212, False: 20]
Branch (66:12): [True: 6.40k, False: 20]
Branch (66:12): [True: 189k, False: 409]
Branch (66:12): [True: 19, False: 0]
Branch (66:12): [True: 1, False: 0]
Branch (66:12): [True: 0, False: 0]
|
67 | while (i < str_len && STRINGLIB_ISSPACE340k (str[i])315k ) Branch (67:16): [True: 5.68k, False: 25]
Branch (67:16): [True: 19.6k, False: 122]
Branch (67:16): [True: 315k, False: 41.6k]
Branch (67:31): [True: 167k, False: 147k]
Branch (67:16): [True: 25, False: 5]
Branch (67:31): [True: 11, False: 14]
Branch (67:16): [True: 1, False: 0]
Branch (67:31): [True: 0, False: 1]
Branch (67:16): [True: 0, False: 0]
Branch (67:31): [True: 0, False: 0]
|
68 | i++; |
69 | if (i == str_len) break41.8k ; Branch (69:13): [True: 25, False: 187]
Branch (69:13): [True: 122, False: 6.27k]
Branch (69:13): [True: 41.6k, False: 147k]
Branch (69:13): [True: 5, False: 14]
Branch (69:13): [True: 0, False: 1]
Branch (69:13): [True: 0, False: 0]
|
70 | j = i; i++; |
71 | while (i < str_len && !10.9k STRINGLIB_ISSPACE1.12M (str[i])) Branch (71:16): [True: 269, False: 24]
Branch (71:31): [True: 106, False: 163]
Branch (71:16): [True: 10.6k, False: 121]
Branch (71:31): [True: 4.47k, False: 6.15k]
Branch (71:16): [True: 1.11M, False: 40.8k]
Branch (71:31): [True: 1.00M, False: 106k]
Branch (71:16): [True: 258, False: 6]
Branch (71:31): [True: 250, False: 8]
Branch (71:16): [True: 17, False: 1]
Branch (71:31): [True: 17, False: 0]
Branch (71:16): [True: 0, False: 0]
Branch (71:31): [True: 0, False: 0]
|
72 | i++; |
73 | #if !STRINGLIB_MUTABLE |
74 | if (j == 0 && i == str_len49.8k && STRINGLIB_CHECK_EXACT13.1k (str_obj)) { Branch (74:13): [True: 81, False: 6.19k]
Branch (74:23): [True: 4, False: 77]
Branch (74:13): [True: 49.7k, False: 97.7k]
Branch (74:23): [True: 13.1k, False: 36.5k]
Branch (74:13): [True: 9, False: 5]
Branch (74:23): [True: 4, False: 5]
Branch (74:13): [True: 1, False: 0]
Branch (74:23): [True: 1, False: 0]
Branch (74:13): [True: 0, False: 0]
Branch (74:23): [True: 0, False: 0]
|
75 | /* No whitespace in str_obj, so just use it as list[0] */ |
76 | Py_INCREF(str_obj); |
77 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); |
78 | count++; |
79 | break; |
80 | } |
81 | #endif |
82 | SPLIT_ADD140k (str, j, i); |
83 | } |
84 | |
85 | if (i < str_len) { Branch (85:9): [True: 14, False: 31]
Branch (85:9): [True: 14, False: 132]
Branch (85:9): [True: 397, False: 54.8k]
Branch (85:9): [True: 0, False: 9]
Branch (85:9): [True: 0, False: 1]
Branch (85:9): [True: 0, False: 0]
|
86 | /* Only occurs when maxcount was reached */ |
87 | /* Skip any remaining whitespace and copy to end of string */ |
88 | while (i < str_len && STRINGLIB_ISSPACE904 (str[i])822 ) Branch (88:16): [True: 41, False: 1]
Branch (88:16): [True: 41, False: 1]
Branch (88:16): [True: 822, False: 4]
Branch (88:31): [True: 429, False: 393]
Branch (88:16): [True: 0, False: 0]
Branch (88:31): [True: 0, False: 0]
Branch (88:16): [True: 0, False: 0]
Branch (88:31): [True: 0, False: 0]
Branch (88:16): [True: 0, False: 0]
Branch (88:31): [True: 0, False: 0]
|
89 | i++; |
90 | if (i != str_len) Branch (90:13): [True: 13, False: 1]
Branch (90:13): [True: 13, False: 1]
Branch (90:13): [True: 393, False: 4]
Branch (90:13): [True: 0, False: 0]
Branch (90:13): [True: 0, False: 0]
Branch (90:13): [True: 0, False: 0]
|
91 | SPLIT_ADD419 (str, i, str_len); |
92 | } |
93 | FIX_PREALLOC_SIZE(list); |
94 | return list; |
95 | |
96 | onError: |
97 | Py_DECREF(list); |
98 | return NULL; |
99 | } bytearrayobject.c:stringlib_split_whitespace Line | Count | Source | 57 | { | 58 | Py_ssize_t i, j, count=0; | 59 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 60 | PyObject *sub; | 61 | | 62 | if (list == NULL) Branch (62:9): [True: 0, False: 45]
| 63 | return NULL; | 64 | | 65 | i = j = 0; | 66 | while (maxcount-- > 0) { Branch (66:12): [True: 212, False: 20]
| 67 | while (i < str_len && STRINGLIB_ISSPACE5.68k (str[i])) Branch (67:16): [True: 5.68k, False: 25]
| 68 | i++; | 69 | if (i == str_len) break25 ; Branch (69:13): [True: 25, False: 187]
| 70 | j = i; i++; | 71 | while (i < str_len && !269 STRINGLIB_ISSPACE269 (str[i])) Branch (71:16): [True: 269, False: 24]
Branch (71:31): [True: 106, False: 163]
| 72 | i++; | 73 | #if !STRINGLIB_MUTABLE | 74 | if (j == 0 && i == str_len && STRINGLIB_CHECK_EXACT(str_obj)) { | 75 | /* No whitespace in str_obj, so just use it as list[0] */ | 76 | Py_INCREF(str_obj); | 77 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 78 | count++; | 79 | break; | 80 | } | 81 | #endif | 82 | SPLIT_ADD187 (str, j, i); | 83 | } | 84 | | 85 | if (i < str_len) { Branch (85:9): [True: 14, False: 31]
| 86 | /* Only occurs when maxcount was reached */ | 87 | /* Skip any remaining whitespace and copy to end of string */ | 88 | while (i < str_len && STRINGLIB_ISSPACE41 (str[i])) Branch (88:16): [True: 41, False: 1]
| 89 | i++; | 90 | if (i != str_len) Branch (90:13): [True: 13, False: 1]
| 91 | SPLIT_ADD13 (str, i, str_len); | 92 | } | 93 | FIX_PREALLOC_SIZE(list); | 94 | return list; | 95 | | 96 | onError: | 97 | Py_DECREF(list); | 98 | return NULL; | 99 | } |
bytesobject.c:stringlib_split_whitespace Line | Count | Source | 57 | { | 58 | Py_ssize_t i, j, count=0; | 59 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 60 | PyObject *sub; | 61 | | 62 | if (list == NULL) Branch (62:9): [True: 0, False: 146]
| 63 | return NULL; | 64 | | 65 | i = j = 0; | 66 | while (maxcount-- > 0) { Branch (66:12): [True: 6.40k, False: 20]
| 67 | while (i < str_len && STRINGLIB_ISSPACE19.6k (str[i])) Branch (67:16): [True: 19.6k, False: 122]
| 68 | i++; | 69 | if (i == str_len) break122 ; Branch (69:13): [True: 122, False: 6.27k]
| 70 | j = i; i++; | 71 | while (i < str_len && !10.6k STRINGLIB_ISSPACE10.6k (str[i])) Branch (71:16): [True: 10.6k, False: 121]
Branch (71:31): [True: 4.47k, False: 6.15k]
| 72 | i++; | 73 | #if !STRINGLIB_MUTABLE | 74 | if (j == 0 && i == str_len81 && STRINGLIB_CHECK_EXACT4 (str_obj)) { Branch (74:13): [True: 81, False: 6.19k]
Branch (74:23): [True: 4, False: 77]
| 75 | /* No whitespace in str_obj, so just use it as list[0] */ | 76 | Py_INCREF(str_obj); | 77 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 78 | count++; | 79 | break; | 80 | } | 81 | #endif | 82 | SPLIT_ADD6.27k (str, j, i); | 83 | } | 84 | | 85 | if (i < str_len) { Branch (85:9): [True: 14, False: 132]
| 86 | /* Only occurs when maxcount was reached */ | 87 | /* Skip any remaining whitespace and copy to end of string */ | 88 | while (i < str_len && STRINGLIB_ISSPACE41 (str[i])) Branch (88:16): [True: 41, False: 1]
| 89 | i++; | 90 | if (i != str_len) Branch (90:13): [True: 13, False: 1]
| 91 | SPLIT_ADD13 (str, i, str_len); | 92 | } | 93 | FIX_PREALLOC_SIZE(list); | 94 | return list; | 95 | | 96 | onError: | 97 | Py_DECREF(list); | 98 | return NULL; | 99 | } |
unicodeobject.c:asciilib_split_whitespace Line | Count | Source | 57 | { | 58 | Py_ssize_t i, j, count=0; | 59 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 60 | PyObject *sub; | 61 | | 62 | if (list == NULL) Branch (62:9): [True: 0, False: 55.2k]
| 63 | return NULL; | 64 | | 65 | i = j = 0; | 66 | while (maxcount-- > 0) { Branch (66:12): [True: 189k, False: 409]
| 67 | while (i < str_len && STRINGLIB_ISSPACE315k (str[i])315k ) Branch (67:16): [True: 315k, False: 41.6k]
Branch (67:31): [True: 167k, False: 147k]
| 68 | i++; | 69 | if (i == str_len) break41.6k ; Branch (69:13): [True: 41.6k, False: 147k]
| 70 | j = i; i++; | 71 | while (i < str_len && !1.11M STRINGLIB_ISSPACE1.11M (str[i])) Branch (71:16): [True: 1.11M, False: 40.8k]
Branch (71:31): [True: 1.00M, False: 106k]
| 72 | i++; | 73 | #if !STRINGLIB_MUTABLE | 74 | if (j == 0 && i == str_len49.7k && STRINGLIB_CHECK_EXACT13.1k (str_obj)) { Branch (74:13): [True: 49.7k, False: 97.7k]
Branch (74:23): [True: 13.1k, False: 36.5k]
| 75 | /* No whitespace in str_obj, so just use it as list[0] */ | 76 | Py_INCREF(str_obj); | 77 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 78 | count++; | 79 | break; | 80 | } | 81 | #endif | 82 | SPLIT_ADD134k (str, j, i); | 83 | } | 84 | | 85 | if (i < str_len) { Branch (85:9): [True: 397, False: 54.8k]
| 86 | /* Only occurs when maxcount was reached */ | 87 | /* Skip any remaining whitespace and copy to end of string */ | 88 | while (i < str_len && STRINGLIB_ISSPACE822 (str[i])822 ) Branch (88:16): [True: 822, False: 4]
Branch (88:31): [True: 429, False: 393]
| 89 | i++; | 90 | if (i != str_len) Branch (90:13): [True: 393, False: 4]
| 91 | SPLIT_ADD393 (str, i, str_len); | 92 | } | 93 | FIX_PREALLOC_SIZE(list); | 94 | return list; | 95 | | 96 | onError: | 97 | Py_DECREF(list); | 98 | return NULL; | 99 | } |
unicodeobject.c:ucs1lib_split_whitespace Line | Count | Source | 57 | { | 58 | Py_ssize_t i, j, count=0; | 59 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 60 | PyObject *sub; | 61 | | 62 | if (list == NULL) Branch (62:9): [True: 0, False: 9]
| 63 | return NULL; | 64 | | 65 | i = j = 0; | 66 | while (maxcount-- > 0) { Branch (66:12): [True: 19, False: 0]
| 67 | while (i < str_len && STRINGLIB_ISSPACE25 (str[i])25 ) Branch (67:16): [True: 25, False: 5]
Branch (67:31): [True: 11, False: 14]
| 68 | i++; | 69 | if (i == str_len) break5 ; Branch (69:13): [True: 5, False: 14]
| 70 | j = i; i++; | 71 | while (i < str_len && !258 STRINGLIB_ISSPACE258 (str[i])) Branch (71:16): [True: 258, False: 6]
Branch (71:31): [True: 250, False: 8]
| 72 | i++; | 73 | #if !STRINGLIB_MUTABLE | 74 | if (j == 0 && i == str_len9 && STRINGLIB_CHECK_EXACT4 (str_obj)) { Branch (74:13): [True: 9, False: 5]
Branch (74:23): [True: 4, False: 5]
| 75 | /* No whitespace in str_obj, so just use it as list[0] */ | 76 | Py_INCREF(str_obj); | 77 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 78 | count++; | 79 | break; | 80 | } | 81 | #endif | 82 | SPLIT_ADD10 (str, j, i); | 83 | } | 84 | | 85 | if (i < str_len) { Branch (85:9): [True: 0, False: 9]
| 86 | /* Only occurs when maxcount was reached */ | 87 | /* Skip any remaining whitespace and copy to end of string */ | 88 | while (i < str_len && STRINGLIB_ISSPACE(str[i])) Branch (88:16): [True: 0, False: 0]
Branch (88:31): [True: 0, False: 0]
| 89 | i++; | 90 | if (i != str_len) Branch (90:13): [True: 0, False: 0]
| 91 | SPLIT_ADD(str, i, str_len); | 92 | } | 93 | FIX_PREALLOC_SIZE(list); | 94 | return list; | 95 | | 96 | onError: | 97 | Py_DECREF(list); | 98 | return NULL; | 99 | } |
unicodeobject.c:ucs2lib_split_whitespace Line | Count | Source | 57 | { | 58 | Py_ssize_t i, j, count=0; | 59 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 60 | PyObject *sub; | 61 | | 62 | if (list == NULL) Branch (62:9): [True: 0, False: 1]
| 63 | return NULL; | 64 | | 65 | i = j = 0; | 66 | while (maxcount-- > 0) { Branch (66:12): [True: 1, False: 0]
| 67 | while (i < str_len && STRINGLIB_ISSPACE(str[i])) Branch (67:16): [True: 1, False: 0]
Branch (67:31): [True: 0, False: 1]
| 68 | i++; | 69 | if (i == str_len) break0 ; Branch (69:13): [True: 0, False: 1]
| 70 | j = i; i++; | 71 | while (i < str_len && !17 STRINGLIB_ISSPACE17 (str[i])) Branch (71:16): [True: 17, False: 1]
Branch (71:31): [True: 17, False: 0]
| 72 | i++; | 73 | #if !STRINGLIB_MUTABLE | 74 | if (j == 0 && i == str_len && STRINGLIB_CHECK_EXACT(str_obj)) { Branch (74:13): [True: 1, False: 0]
Branch (74:23): [True: 1, False: 0]
| 75 | /* No whitespace in str_obj, so just use it as list[0] */ | 76 | Py_INCREF(str_obj); | 77 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 78 | count++; | 79 | break; | 80 | } | 81 | #endif | 82 | SPLIT_ADD(str, j, i); | 83 | } | 84 | | 85 | if (i < str_len) { Branch (85:9): [True: 0, False: 1]
| 86 | /* Only occurs when maxcount was reached */ | 87 | /* Skip any remaining whitespace and copy to end of string */ | 88 | while (i < str_len && STRINGLIB_ISSPACE(str[i])) Branch (88:16): [True: 0, False: 0]
Branch (88:31): [True: 0, False: 0]
| 89 | i++; | 90 | if (i != str_len) Branch (90:13): [True: 0, False: 0]
| 91 | SPLIT_ADD(str, i, str_len); | 92 | } | 93 | FIX_PREALLOC_SIZE(list); | 94 | return list; | 95 | | 96 | onError: | 97 | Py_DECREF(list); | 98 | return NULL; | 99 | } |
Unexecuted instantiation: unicodeobject.c:ucs4lib_split_whitespace |
100 | |
101 | Py_LOCAL_INLINE(PyObject *) |
102 | STRINGLIB(split_char)(PyObject* str_obj, |
103 | const STRINGLIB_CHAR* str, Py_ssize_t str_len, |
104 | const STRINGLIB_CHAR ch, |
105 | Py_ssize_t maxcount) |
106 | { |
107 | Py_ssize_t i, j, count=0; |
108 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); |
109 | PyObject *sub; |
110 | |
111 | if (list == NULL) Branch (111:9): [True: 0, False: 2.11k]
Branch (111:9): [True: 0, False: 6.91k]
Branch (111:9): [True: 0, False: 1.25M]
Branch (111:9): [True: 0, False: 1.63k]
Branch (111:9): [True: 0, False: 1.41k]
Branch (111:9): [True: 0, False: 16]
|
112 | return NULL; |
113 | |
114 | i = j = 0; |
115 | while ((j < str_len) && (maxcount-- > 0)2.49M ) { Branch (115:12): [True: 4.35k, False: 2.08k]
Branch (115:29): [True: 4.32k, False: 26]
Branch (115:12): [True: 23.6k, False: 3.04k]
Branch (115:29): [True: 19.7k, False: 3.87k]
Branch (115:12): [True: 2.45M, False: 1.00M]
Branch (115:29): [True: 2.20M, False: 243k]
Branch (115:12): [True: 8.19k, False: 1.60k]
Branch (115:29): [True: 8.16k, False: 32]
Branch (115:12): [True: 1.66k, False: 1.32k]
Branch (115:29): [True: 1.58k, False: 86]
Branch (115:12): [True: 21, False: 16]
Branch (115:29): [True: 21, False: 0]
|
116 | for(; j < str_len; j++12.9M ) { Branch (116:15): [True: 26.4k, False: 9]
Branch (116:15): [True: 155k, False: 2.82k]
Branch (116:15): [True: 13.9M, False: 995k]
Branch (116:15): [True: 81.1k, False: 1.54k]
Branch (116:15): [True: 10.4k, False: 1.31k]
Branch (116:15): [True: 165, False: 16]
|
117 | /* I found that using memchr makes no difference */ |
118 | if (str[j] == ch) { Branch (118:17): [True: 4.31k, False: 22.1k]
Branch (118:17): [True: 16.9k, False: 138k]
Branch (118:17): [True: 1.21M, False: 12.6M]
Branch (118:17): [True: 6.61k, False: 74.4k]
Branch (118:17): [True: 264, False: 10.1k]
Branch (118:17): [True: 5, False: 160]
|
119 | SPLIT_ADD(str, i, j); |
120 | i = j = j + 1; |
121 | break; |
122 | } |
123 | } |
124 | } |
125 | #if !STRINGLIB_MUTABLE |
126 | if (count == 0 && STRINGLIB_CHECK_EXACT308k (str_obj)) { Branch (126:9): [True: 824, False: 6.09k]
Branch (126:9): [True: 306k, False: 944k]
Branch (126:9): [True: 719, False: 913]
Branch (126:9): [True: 1.28k, False: 122]
Branch (126:9): [True: 11, False: 5]
|
127 | /* ch not in str_obj, so just use str_obj as list[0] */ |
128 | Py_INCREF(str_obj); |
129 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); |
130 | count++; |
131 | } else |
132 | #endif |
133 | if (951k i <= str_len) { Branch (133:9): [True: 2.11k, False: 0]
Branch (133:9): [True: 6.09k, False: 0]
Branch (133:9): [True: 944k, False: 0]
Branch (133:9): [True: 913, False: 0]
Branch (133:9): [True: 122, False: 0]
Branch (133:9): [True: 5, False: 0]
|
134 | SPLIT_ADD953k (str, i, str_len); |
135 | } |
136 | FIX_PREALLOC_SIZE(list); |
137 | return list; |
138 | |
139 | onError: |
140 | Py_DECREF(list); |
141 | return NULL; |
142 | } bytearrayobject.c:stringlib_split_char Line | Count | Source | 106 | { | 107 | Py_ssize_t i, j, count=0; | 108 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 109 | PyObject *sub; | 110 | | 111 | if (list == NULL) Branch (111:9): [True: 0, False: 2.11k]
| 112 | return NULL; | 113 | | 114 | i = j = 0; | 115 | while ((j < str_len) && (maxcount-- > 0)4.35k ) { Branch (115:12): [True: 4.35k, False: 2.08k]
Branch (115:29): [True: 4.32k, False: 26]
| 116 | for(; j < str_len; j++22.1k ) { Branch (116:15): [True: 26.4k, False: 9]
| 117 | /* I found that using memchr makes no difference */ | 118 | if (str[j] == ch) { Branch (118:17): [True: 4.31k, False: 22.1k]
| 119 | SPLIT_ADD(str, i, j); | 120 | i = j = j + 1; | 121 | break; | 122 | } | 123 | } | 124 | } | 125 | #if !STRINGLIB_MUTABLE | 126 | if (count == 0 && STRINGLIB_CHECK_EXACT(str_obj)) { | 127 | /* ch not in str_obj, so just use str_obj as list[0] */ | 128 | Py_INCREF(str_obj); | 129 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 130 | count++; | 131 | } else | 132 | #endif | 133 | if (i <= str_len) { Branch (133:9): [True: 2.11k, False: 0]
| 134 | SPLIT_ADD2.11k (str, i, str_len); | 135 | } | 136 | FIX_PREALLOC_SIZE(list); | 137 | return list; | 138 | | 139 | onError: | 140 | Py_DECREF(list); | 141 | return NULL; | 142 | } |
bytesobject.c:stringlib_split_char Line | Count | Source | 106 | { | 107 | Py_ssize_t i, j, count=0; | 108 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 109 | PyObject *sub; | 110 | | 111 | if (list == NULL) Branch (111:9): [True: 0, False: 6.91k]
| 112 | return NULL; | 113 | | 114 | i = j = 0; | 115 | while ((j < str_len) && (maxcount-- > 0)23.6k ) { Branch (115:12): [True: 23.6k, False: 3.04k]
Branch (115:29): [True: 19.7k, False: 3.87k]
| 116 | for(; j < str_len; j++138k ) { Branch (116:15): [True: 155k, False: 2.82k]
| 117 | /* I found that using memchr makes no difference */ | 118 | if (str[j] == ch) { Branch (118:17): [True: 16.9k, False: 138k]
| 119 | SPLIT_ADD(str, i, j); | 120 | i = j = j + 1; | 121 | break; | 122 | } | 123 | } | 124 | } | 125 | #if !STRINGLIB_MUTABLE | 126 | if (count == 0 && STRINGLIB_CHECK_EXACT824 (str_obj)) { Branch (126:9): [True: 824, False: 6.09k]
| 127 | /* ch not in str_obj, so just use str_obj as list[0] */ | 128 | Py_INCREF(str_obj); | 129 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 130 | count++; | 131 | } else | 132 | #endif | 133 | if (i <= str_len) { Branch (133:9): [True: 6.09k, False: 0]
| 134 | SPLIT_ADD6.09k (str, i, str_len); | 135 | } | 136 | FIX_PREALLOC_SIZE(list); | 137 | return list; | 138 | | 139 | onError: | 140 | Py_DECREF(list); | 141 | return NULL; | 142 | } |
unicodeobject.c:asciilib_split_char Line | Count | Source | 106 | { | 107 | Py_ssize_t i, j, count=0; | 108 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 109 | PyObject *sub; | 110 | | 111 | if (list == NULL) Branch (111:9): [True: 0, False: 1.25M]
| 112 | return NULL; | 113 | | 114 | i = j = 0; | 115 | while ((j < str_len) && (maxcount-- > 0)2.45M ) { Branch (115:12): [True: 2.45M, False: 1.00M]
Branch (115:29): [True: 2.20M, False: 243k]
| 116 | for(; j < str_len; j++12.6M ) { Branch (116:15): [True: 13.9M, False: 995k]
| 117 | /* I found that using memchr makes no difference */ | 118 | if (str[j] == ch) { Branch (118:17): [True: 1.21M, False: 12.6M]
| 119 | SPLIT_ADD(str, i, j); | 120 | i = j = j + 1; | 121 | break; | 122 | } | 123 | } | 124 | } | 125 | #if !STRINGLIB_MUTABLE | 126 | if (count == 0 && STRINGLIB_CHECK_EXACT306k (str_obj)) { Branch (126:9): [True: 306k, False: 944k]
| 127 | /* ch not in str_obj, so just use str_obj as list[0] */ | 128 | Py_INCREF(str_obj); | 129 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 130 | count++; | 131 | } else | 132 | #endif | 133 | if (i <= str_len) { Branch (133:9): [True: 944k, False: 0]
| 134 | SPLIT_ADD944k (str, i, str_len); | 135 | } | 136 | FIX_PREALLOC_SIZE(list); | 137 | return list; | 138 | | 139 | onError: | 140 | Py_DECREF(list); | 141 | return NULL; | 142 | } |
unicodeobject.c:ucs1lib_split_char Line | Count | Source | 106 | { | 107 | Py_ssize_t i, j, count=0; | 108 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 109 | PyObject *sub; | 110 | | 111 | if (list == NULL) Branch (111:9): [True: 0, False: 1.63k]
| 112 | return NULL; | 113 | | 114 | i = j = 0; | 115 | while ((j < str_len) && (maxcount-- > 0)8.19k ) { Branch (115:12): [True: 8.19k, False: 1.60k]
Branch (115:29): [True: 8.16k, False: 32]
| 116 | for(; j < str_len; j++74.4k ) { Branch (116:15): [True: 81.1k, False: 1.54k]
| 117 | /* I found that using memchr makes no difference */ | 118 | if (str[j] == ch) { Branch (118:17): [True: 6.61k, False: 74.4k]
| 119 | SPLIT_ADD(str, i, j); | 120 | i = j = j + 1; | 121 | break; | 122 | } | 123 | } | 124 | } | 125 | #if !STRINGLIB_MUTABLE | 126 | if (count == 0 && STRINGLIB_CHECK_EXACT719 (str_obj)) { Branch (126:9): [True: 719, False: 913]
| 127 | /* ch not in str_obj, so just use str_obj as list[0] */ | 128 | Py_INCREF(str_obj); | 129 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 130 | count++; | 131 | } else | 132 | #endif | 133 | if (i <= str_len) { Branch (133:9): [True: 913, False: 0]
| 134 | SPLIT_ADD913 (str, i, str_len); | 135 | } | 136 | FIX_PREALLOC_SIZE(list); | 137 | return list; | 138 | | 139 | onError: | 140 | Py_DECREF(list); | 141 | return NULL; | 142 | } |
unicodeobject.c:ucs2lib_split_char Line | Count | Source | 106 | { | 107 | Py_ssize_t i, j, count=0; | 108 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 109 | PyObject *sub; | 110 | | 111 | if (list == NULL) Branch (111:9): [True: 0, False: 1.41k]
| 112 | return NULL; | 113 | | 114 | i = j = 0; | 115 | while ((j < str_len) && (maxcount-- > 0)1.66k ) { Branch (115:12): [True: 1.66k, False: 1.32k]
Branch (115:29): [True: 1.58k, False: 86]
| 116 | for(; j < str_len; j++10.1k ) { Branch (116:15): [True: 10.4k, False: 1.31k]
| 117 | /* I found that using memchr makes no difference */ | 118 | if (str[j] == ch) { Branch (118:17): [True: 264, False: 10.1k]
| 119 | SPLIT_ADD(str, i, j); | 120 | i = j = j + 1; | 121 | break; | 122 | } | 123 | } | 124 | } | 125 | #if !STRINGLIB_MUTABLE | 126 | if (count == 0 && STRINGLIB_CHECK_EXACT1.28k (str_obj)) { Branch (126:9): [True: 1.28k, False: 122]
| 127 | /* ch not in str_obj, so just use str_obj as list[0] */ | 128 | Py_INCREF(str_obj); | 129 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 130 | count++; | 131 | } else | 132 | #endif | 133 | if (i <= str_len) { Branch (133:9): [True: 122, False: 0]
| 134 | SPLIT_ADD122 (str, i, str_len); | 135 | } | 136 | FIX_PREALLOC_SIZE(list); | 137 | return list; | 138 | | 139 | onError: | 140 | Py_DECREF(list); | 141 | return NULL; | 142 | } |
unicodeobject.c:ucs4lib_split_char Line | Count | Source | 106 | { | 107 | Py_ssize_t i, j, count=0; | 108 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 109 | PyObject *sub; | 110 | | 111 | if (list == NULL) Branch (111:9): [True: 0, False: 16]
| 112 | return NULL; | 113 | | 114 | i = j = 0; | 115 | while ((j < str_len) && (maxcount-- > 0)21 ) { Branch (115:12): [True: 21, False: 16]
Branch (115:29): [True: 21, False: 0]
| 116 | for(; j < str_len; j++160 ) { Branch (116:15): [True: 165, False: 16]
| 117 | /* I found that using memchr makes no difference */ | 118 | if (str[j] == ch) { Branch (118:17): [True: 5, False: 160]
| 119 | SPLIT_ADD(str, i, j); | 120 | i = j = j + 1; | 121 | break; | 122 | } | 123 | } | 124 | } | 125 | #if !STRINGLIB_MUTABLE | 126 | if (count == 0 && STRINGLIB_CHECK_EXACT11 (str_obj)) { Branch (126:9): [True: 11, False: 5]
| 127 | /* ch not in str_obj, so just use str_obj as list[0] */ | 128 | Py_INCREF(str_obj); | 129 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 130 | count++; | 131 | } else | 132 | #endif | 133 | if (i <= str_len) { Branch (133:9): [True: 5, False: 0]
| 134 | SPLIT_ADD5 (str, i, str_len); | 135 | } | 136 | FIX_PREALLOC_SIZE(list); | 137 | return list; | 138 | | 139 | onError: | 140 | Py_DECREF(list); | 141 | return NULL; | 142 | } |
|
143 | |
144 | Py_LOCAL_INLINE(PyObject *) |
145 | STRINGLIB(split)(PyObject* str_obj, |
146 | const STRINGLIB_CHAR* str, Py_ssize_t str_len, |
147 | const STRINGLIB_CHAR* sep, Py_ssize_t sep_len, |
148 | Py_ssize_t maxcount) |
149 | { |
150 | Py_ssize_t i, j, pos, count=0; |
151 | PyObject *list, *sub; |
152 | |
153 | if (sep_len == 0) { Branch (153:9): [True: 2, False: 2.13k]
Branch (153:9): [True: 2, False: 6.99k]
Branch (153:9): [True: 5, False: 1.69M]
Branch (153:9): [True: 0, False: 1.70k]
Branch (153:9): [True: 0, False: 1.42k]
Branch (153:9): [True: 0, False: 24]
|
154 | PyErr_SetString(PyExc_ValueError, "empty separator"); |
155 | return NULL; |
156 | } |
157 | else if (sep_len == 1) Branch (157:14): [True: 2.11k, False: 23]
Branch (157:14): [True: 6.91k, False: 78]
Branch (157:14): [True: 1.25M, False: 441k]
Branch (157:14): [True: 1.63k, False: 74]
Branch (157:14): [True: 1.41k, False: 14]
Branch (157:14): [True: 16, False: 8]
|
158 | return STRINGLIB(split_char)(str_obj, str, str_len, sep[0], maxcount); |
159 | |
160 | list = PyList_New(PREALLOC_SIZE(maxcount)); |
161 | if (list == NULL) Branch (161:9): [True: 0, False: 23]
Branch (161:9): [True: 0, False: 78]
Branch (161:9): [True: 0, False: 441k]
Branch (161:9): [True: 0, False: 74]
Branch (161:9): [True: 0, False: 14]
Branch (161:9): [True: 0, False: 8]
|
162 | return NULL; |
163 | |
164 | i = j = 0; |
165 | while (maxcount-- > 0) { Branch (165:12): [True: 98, False: 8]
Branch (165:12): [True: 464, False: 9]
Branch (165:12): [True: 777k, False: 162]
Branch (165:12): [True: 84, False: 66]
Branch (165:12): [True: 26, False: 5]
Branch (165:12): [True: 13, False: 0]
|
166 | pos = FASTSEARCH(str+i, str_len-i, sep, sep_len, -1, FAST_SEARCH); |
167 | if (pos < 0) Branch (167:13): [True: 15, False: 83]
Branch (167:13): [True: 69, False: 395]
Branch (167:13): [True: 440k, False: 336k]
Branch (167:13): [True: 8, False: 76]
Branch (167:13): [True: 9, False: 17]
Branch (167:13): [True: 8, False: 5]
|
168 | break; |
169 | j = i + pos; |
170 | SPLIT_ADD337k (str, i, j); |
171 | i = j + sep_len; |
172 | } |
173 | #if !STRINGLIB_MUTABLE |
174 | if (count == 0 && STRINGLIB_CHECK_EXACT141k (str_obj)) { Branch (174:9): [True: 17, False: 61]
Branch (174:9): [True: 141k, False: 299k]
Branch (174:9): [True: 2, False: 72]
Branch (174:9): [True: 4, False: 10]
Branch (174:9): [True: 3, False: 5]
|
175 | /* No match in str_obj, so just use it as list[0] */ |
176 | Py_INCREF(str_obj); |
177 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); |
178 | count++; |
179 | } else |
180 | #endif |
181 | { |
182 | SPLIT_ADD299k (str, i, str_len); |
183 | } |
184 | FIX_PREALLOC_SIZE(list); |
185 | return list; |
186 | |
187 | onError: |
188 | Py_DECREF(list); |
189 | return NULL; |
190 | } bytearrayobject.c:stringlib_split Line | Count | Source | 149 | { | 150 | Py_ssize_t i, j, pos, count=0; | 151 | PyObject *list, *sub; | 152 | | 153 | if (sep_len == 0) { Branch (153:9): [True: 2, False: 2.13k]
| 154 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 155 | return NULL; | 156 | } | 157 | else if (sep_len == 1) Branch (157:14): [True: 2.11k, False: 23]
| 158 | return STRINGLIB(split_char)(str_obj, str, str_len, sep[0], maxcount); | 159 | | 160 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 161 | if (list == NULL) Branch (161:9): [True: 0, False: 23]
| 162 | return NULL; | 163 | | 164 | i = j = 0; | 165 | while (maxcount-- > 0) { Branch (165:12): [True: 98, False: 8]
| 166 | pos = FASTSEARCH(str+i, str_len-i, sep, sep_len, -1, FAST_SEARCH); | 167 | if (pos < 0) Branch (167:13): [True: 15, False: 83]
| 168 | break; | 169 | j = i + pos; | 170 | SPLIT_ADD83 (str, i, j); | 171 | i = j + sep_len; | 172 | } | 173 | #if !STRINGLIB_MUTABLE | 174 | if (count == 0 && STRINGLIB_CHECK_EXACT(str_obj)) { | 175 | /* No match in str_obj, so just use it as list[0] */ | 176 | Py_INCREF(str_obj); | 177 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 178 | count++; | 179 | } else | 180 | #endif | 181 | { | 182 | SPLIT_ADD(str, i, str_len); | 183 | } | 184 | FIX_PREALLOC_SIZE(list); | 185 | return list; | 186 | | 187 | onError: | 188 | Py_DECREF(list); | 189 | return NULL; | 190 | } |
bytesobject.c:stringlib_split Line | Count | Source | 149 | { | 150 | Py_ssize_t i, j, pos, count=0; | 151 | PyObject *list, *sub; | 152 | | 153 | if (sep_len == 0) { Branch (153:9): [True: 2, False: 6.99k]
| 154 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 155 | return NULL; | 156 | } | 157 | else if (sep_len == 1) Branch (157:14): [True: 6.91k, False: 78]
| 158 | return STRINGLIB(split_char)(str_obj, str, str_len, sep[0], maxcount); | 159 | | 160 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 161 | if (list == NULL) Branch (161:9): [True: 0, False: 78]
| 162 | return NULL; | 163 | | 164 | i = j = 0; | 165 | while (maxcount-- > 0) { Branch (165:12): [True: 464, False: 9]
| 166 | pos = FASTSEARCH(str+i, str_len-i, sep, sep_len, -1, FAST_SEARCH); | 167 | if (pos < 0) Branch (167:13): [True: 69, False: 395]
| 168 | break; | 169 | j = i + pos; | 170 | SPLIT_ADD395 (str, i, j); | 171 | i = j + sep_len; | 172 | } | 173 | #if !STRINGLIB_MUTABLE | 174 | if (count == 0 && STRINGLIB_CHECK_EXACT17 (str_obj)) { Branch (174:9): [True: 17, False: 61]
| 175 | /* No match in str_obj, so just use it as list[0] */ | 176 | Py_INCREF(str_obj); | 177 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 178 | count++; | 179 | } else | 180 | #endif | 181 | { | 182 | SPLIT_ADD61 (str, i, str_len); | 183 | } | 184 | FIX_PREALLOC_SIZE(list); | 185 | return list; | 186 | | 187 | onError: | 188 | Py_DECREF(list); | 189 | return NULL; | 190 | } |
unicodeobject.c:asciilib_split Line | Count | Source | 149 | { | 150 | Py_ssize_t i, j, pos, count=0; | 151 | PyObject *list, *sub; | 152 | | 153 | if (sep_len == 0) { Branch (153:9): [True: 5, False: 1.69M]
| 154 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 155 | return NULL; | 156 | } | 157 | else if (sep_len == 1) Branch (157:14): [True: 1.25M, False: 441k]
| 158 | return STRINGLIB(split_char)(str_obj, str, str_len, sep[0], maxcount); | 159 | | 160 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 161 | if (list == NULL) Branch (161:9): [True: 0, False: 441k]
| 162 | return NULL; | 163 | | 164 | i = j = 0; | 165 | while (maxcount-- > 0) { Branch (165:12): [True: 777k, False: 162]
| 166 | pos = FASTSEARCH(str+i, str_len-i, sep, sep_len, -1, FAST_SEARCH); | 167 | if (pos < 0) Branch (167:13): [True: 440k, False: 336k]
| 168 | break; | 169 | j = i + pos; | 170 | SPLIT_ADD336k (str, i, j); | 171 | i = j + sep_len; | 172 | } | 173 | #if !STRINGLIB_MUTABLE | 174 | if (count == 0 && STRINGLIB_CHECK_EXACT141k (str_obj)) { Branch (174:9): [True: 141k, False: 299k]
| 175 | /* No match in str_obj, so just use it as list[0] */ | 176 | Py_INCREF(str_obj); | 177 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 178 | count++; | 179 | } else | 180 | #endif | 181 | { | 182 | SPLIT_ADD299k (str, i, str_len); | 183 | } | 184 | FIX_PREALLOC_SIZE(list); | 185 | return list; | 186 | | 187 | onError: | 188 | Py_DECREF(list); | 189 | return NULL; | 190 | } |
unicodeobject.c:ucs1lib_split Line | Count | Source | 149 | { | 150 | Py_ssize_t i, j, pos, count=0; | 151 | PyObject *list, *sub; | 152 | | 153 | if (sep_len == 0) { Branch (153:9): [True: 0, False: 1.70k]
| 154 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 155 | return NULL; | 156 | } | 157 | else if (sep_len == 1) Branch (157:14): [True: 1.63k, False: 74]
| 158 | return STRINGLIB(split_char)(str_obj, str, str_len, sep[0], maxcount); | 159 | | 160 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 161 | if (list == NULL) Branch (161:9): [True: 0, False: 74]
| 162 | return NULL; | 163 | | 164 | i = j = 0; | 165 | while (maxcount-- > 0) { Branch (165:12): [True: 84, False: 66]
| 166 | pos = FASTSEARCH(str+i, str_len-i, sep, sep_len, -1, FAST_SEARCH); | 167 | if (pos < 0) Branch (167:13): [True: 8, False: 76]
| 168 | break; | 169 | j = i + pos; | 170 | SPLIT_ADD76 (str, i, j); | 171 | i = j + sep_len; | 172 | } | 173 | #if !STRINGLIB_MUTABLE | 174 | if (count == 0 && STRINGLIB_CHECK_EXACT2 (str_obj)) { Branch (174:9): [True: 2, False: 72]
| 175 | /* No match in str_obj, so just use it as list[0] */ | 176 | Py_INCREF(str_obj); | 177 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 178 | count++; | 179 | } else | 180 | #endif | 181 | { | 182 | SPLIT_ADD72 (str, i, str_len); | 183 | } | 184 | FIX_PREALLOC_SIZE(list); | 185 | return list; | 186 | | 187 | onError: | 188 | Py_DECREF(list); | 189 | return NULL; | 190 | } |
unicodeobject.c:ucs2lib_split Line | Count | Source | 149 | { | 150 | Py_ssize_t i, j, pos, count=0; | 151 | PyObject *list, *sub; | 152 | | 153 | if (sep_len == 0) { Branch (153:9): [True: 0, False: 1.42k]
| 154 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 155 | return NULL; | 156 | } | 157 | else if (sep_len == 1) Branch (157:14): [True: 1.41k, False: 14]
| 158 | return STRINGLIB(split_char)(str_obj, str, str_len, sep[0], maxcount); | 159 | | 160 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 161 | if (list == NULL) Branch (161:9): [True: 0, False: 14]
| 162 | return NULL; | 163 | | 164 | i = j = 0; | 165 | while (maxcount-- > 0) { Branch (165:12): [True: 26, False: 5]
| 166 | pos = FASTSEARCH(str+i, str_len-i, sep, sep_len, -1, FAST_SEARCH); | 167 | if (pos < 0) Branch (167:13): [True: 9, False: 17]
| 168 | break; | 169 | j = i + pos; | 170 | SPLIT_ADD17 (str, i, j); | 171 | i = j + sep_len; | 172 | } | 173 | #if !STRINGLIB_MUTABLE | 174 | if (count == 0 && STRINGLIB_CHECK_EXACT4 (str_obj)) { Branch (174:9): [True: 4, False: 10]
| 175 | /* No match in str_obj, so just use it as list[0] */ | 176 | Py_INCREF(str_obj); | 177 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 178 | count++; | 179 | } else | 180 | #endif | 181 | { | 182 | SPLIT_ADD10 (str, i, str_len); | 183 | } | 184 | FIX_PREALLOC_SIZE(list); | 185 | return list; | 186 | | 187 | onError: | 188 | Py_DECREF(list); | 189 | return NULL; | 190 | } |
unicodeobject.c:ucs4lib_split Line | Count | Source | 149 | { | 150 | Py_ssize_t i, j, pos, count=0; | 151 | PyObject *list, *sub; | 152 | | 153 | if (sep_len == 0) { Branch (153:9): [True: 0, False: 24]
| 154 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 155 | return NULL; | 156 | } | 157 | else if (sep_len == 1) Branch (157:14): [True: 16, False: 8]
| 158 | return STRINGLIB(split_char)(str_obj, str, str_len, sep[0], maxcount); | 159 | | 160 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 161 | if (list == NULL) Branch (161:9): [True: 0, False: 8]
| 162 | return NULL; | 163 | | 164 | i = j = 0; | 165 | while (maxcount-- > 0) { Branch (165:12): [True: 13, False: 0]
| 166 | pos = FASTSEARCH(str+i, str_len-i, sep, sep_len, -1, FAST_SEARCH); | 167 | if (pos < 0) Branch (167:13): [True: 8, False: 5]
| 168 | break; | 169 | j = i + pos; | 170 | SPLIT_ADD5 (str, i, j); | 171 | i = j + sep_len; | 172 | } | 173 | #if !STRINGLIB_MUTABLE | 174 | if (count == 0 && STRINGLIB_CHECK_EXACT3 (str_obj)) { Branch (174:9): [True: 3, False: 5]
| 175 | /* No match in str_obj, so just use it as list[0] */ | 176 | Py_INCREF(str_obj); | 177 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 178 | count++; | 179 | } else | 180 | #endif | 181 | { | 182 | SPLIT_ADD5 (str, i, str_len); | 183 | } | 184 | FIX_PREALLOC_SIZE(list); | 185 | return list; | 186 | | 187 | onError: | 188 | Py_DECREF(list); | 189 | return NULL; | 190 | } |
|
191 | |
192 | Py_LOCAL_INLINE(PyObject *) |
193 | STRINGLIB(rsplit_whitespace)(PyObject* str_obj, |
194 | const STRINGLIB_CHAR* str, Py_ssize_t str_len, |
195 | Py_ssize_t maxcount) |
196 | { |
197 | Py_ssize_t i, j, count=0; |
198 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); |
199 | PyObject *sub; |
200 | |
201 | if (list == NULL) Branch (201:9): [True: 0, False: 40]
Branch (201:9): [True: 0, False: 39]
Branch (201:9): [True: 0, False: 76]
Branch (201:9): [True: 0, False: 0]
Branch (201:9): [True: 0, False: 0]
Branch (201:9): [True: 0, False: 0]
|
202 | return NULL; |
203 | |
204 | i = j = str_len - 1; |
205 | while (maxcount-- > 0) { Branch (205:12): [True: 129, False: 20]
Branch (205:12): [True: 127, False: 20]
Branch (205:12): [True: 250, False: 40]
Branch (205:12): [True: 0, False: 0]
Branch (205:12): [True: 0, False: 0]
Branch (205:12): [True: 0, False: 0]
|
206 | while (i >= 0 && STRINGLIB_ISSPACE1.10k (str[i])544 ) Branch (206:16): [True: 279, False: 20]
Branch (206:16): [True: 278, False: 19]
Branch (206:16): [True: 544, False: 36]
Branch (206:26): [True: 330, False: 214]
Branch (206:16): [True: 0, False: 0]
Branch (206:26): [True: 0, False: 0]
Branch (206:16): [True: 0, False: 0]
Branch (206:26): [True: 0, False: 0]
Branch (206:16): [True: 0, False: 0]
Branch (206:26): [True: 0, False: 0]
|
207 | i--; |
208 | if (i < 0) break75 ; Branch (208:13): [True: 20, False: 109]
Branch (208:13): [True: 19, False: 108]
Branch (208:13): [True: 36, False: 214]
Branch (208:13): [True: 0, False: 0]
Branch (208:13): [True: 0, False: 0]
Branch (208:13): [True: 0, False: 0]
|
209 | j = i; i--; |
210 | while (i >= 0 && !373 STRINGLIB_ISSPACE735 (str[i])) Branch (210:16): [True: 188, False: 20]
Branch (210:26): [True: 99, False: 89]
Branch (210:16): [True: 185, False: 19]
Branch (210:26): [True: 96, False: 89]
Branch (210:16): [True: 362, False: 38]
Branch (210:26): [True: 186, False: 176]
Branch (210:16): [True: 0, False: 0]
Branch (210:26): [True: 0, False: 0]
Branch (210:16): [True: 0, False: 0]
Branch (210:26): [True: 0, False: 0]
Branch (210:16): [True: 0, False: 0]
Branch (210:26): [True: 0, False: 0]
|
211 | i--; |
212 | #if !STRINGLIB_MUTABLE |
213 | if (j == str_len - 1 && i < 070 && STRINGLIB_CHECK_EXACT0 (str_obj)) { Branch (213:13): [True: 24, False: 84]
Branch (213:33): [True: 0, False: 24]
Branch (213:13): [True: 46, False: 168]
Branch (213:33): [True: 0, False: 46]
Branch (213:13): [True: 0, False: 0]
Branch (213:33): [True: 0, False: 0]
Branch (213:13): [True: 0, False: 0]
Branch (213:33): [True: 0, False: 0]
Branch (213:13): [True: 0, False: 0]
Branch (213:33): [True: 0, False: 0]
|
214 | /* No whitespace in str_obj, so just use it as list[0] */ |
215 | Py_INCREF(str_obj); |
216 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); |
217 | count++; |
218 | break; |
219 | } |
220 | #endif |
221 | SPLIT_ADD431 (str, i + 1, j + 1); |
222 | } |
223 | |
224 | if (i >= 0) { Branch (224:9): [True: 14, False: 26]
Branch (224:9): [True: 14, False: 25]
Branch (224:9): [True: 28, False: 48]
Branch (224:9): [True: 0, False: 0]
Branch (224:9): [True: 0, False: 0]
Branch (224:9): [True: 0, False: 0]
|
225 | /* Only occurs when maxcount was reached */ |
226 | /* Skip any remaining whitespace and copy to beginning of string */ |
227 | while (i >= 0 && STRINGLIB_ISSPACE164 (str[i])82 ) Branch (227:16): [True: 41, False: 1]
Branch (227:16): [True: 41, False: 1]
Branch (227:16): [True: 82, False: 2]
Branch (227:26): [True: 56, False: 26]
Branch (227:16): [True: 0, False: 0]
Branch (227:26): [True: 0, False: 0]
Branch (227:16): [True: 0, False: 0]
Branch (227:26): [True: 0, False: 0]
Branch (227:16): [True: 0, False: 0]
Branch (227:26): [True: 0, False: 0]
|
228 | i--; |
229 | if (i >= 0) Branch (229:13): [True: 13, False: 1]
Branch (229:13): [True: 13, False: 1]
Branch (229:13): [True: 26, False: 2]
Branch (229:13): [True: 0, False: 0]
Branch (229:13): [True: 0, False: 0]
Branch (229:13): [True: 0, False: 0]
|
230 | SPLIT_ADD52 (str, 0, i + 1); |
231 | } |
232 | FIX_PREALLOC_SIZE(list); |
233 | if (PyList_Reverse(list) < 0) Branch (233:9): [True: 0, False: 40]
Branch (233:9): [True: 0, False: 39]
Branch (233:9): [True: 0, False: 76]
Branch (233:9): [True: 0, False: 0]
Branch (233:9): [True: 0, False: 0]
Branch (233:9): [True: 0, False: 0]
|
234 | goto onError; |
235 | return list; |
236 | |
237 | onError: |
238 | Py_DECREF(list); |
239 | return NULL; |
240 | } bytearrayobject.c:stringlib_rsplit_whitespace Line | Count | Source | 196 | { | 197 | Py_ssize_t i, j, count=0; | 198 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 199 | PyObject *sub; | 200 | | 201 | if (list == NULL) Branch (201:9): [True: 0, False: 40]
| 202 | return NULL; | 203 | | 204 | i = j = str_len - 1; | 205 | while (maxcount-- > 0) { Branch (205:12): [True: 129, False: 20]
| 206 | while (i >= 0 && STRINGLIB_ISSPACE279 (str[i])) Branch (206:16): [True: 279, False: 20]
| 207 | i--; | 208 | if (i < 0) break20 ; Branch (208:13): [True: 20, False: 109]
| 209 | j = i; i--; | 210 | while (i >= 0 && !188 STRINGLIB_ISSPACE188 (str[i])) Branch (210:16): [True: 188, False: 20]
Branch (210:26): [True: 99, False: 89]
| 211 | i--; | 212 | #if !STRINGLIB_MUTABLE | 213 | if (j == str_len - 1 && i < 0 && STRINGLIB_CHECK_EXACT(str_obj)) { | 214 | /* No whitespace in str_obj, so just use it as list[0] */ | 215 | Py_INCREF(str_obj); | 216 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 217 | count++; | 218 | break; | 219 | } | 220 | #endif | 221 | SPLIT_ADD109 (str, i + 1, j + 1); | 222 | } | 223 | | 224 | if (i >= 0) { Branch (224:9): [True: 14, False: 26]
| 225 | /* Only occurs when maxcount was reached */ | 226 | /* Skip any remaining whitespace and copy to beginning of string */ | 227 | while (i >= 0 && STRINGLIB_ISSPACE41 (str[i])) Branch (227:16): [True: 41, False: 1]
| 228 | i--; | 229 | if (i >= 0) Branch (229:13): [True: 13, False: 1]
| 230 | SPLIT_ADD13 (str, 0, i + 1); | 231 | } | 232 | FIX_PREALLOC_SIZE(list); | 233 | if (PyList_Reverse(list) < 0) Branch (233:9): [True: 0, False: 40]
| 234 | goto onError; | 235 | return list; | 236 | | 237 | onError: | 238 | Py_DECREF(list); | 239 | return NULL; | 240 | } |
bytesobject.c:stringlib_rsplit_whitespace Line | Count | Source | 196 | { | 197 | Py_ssize_t i, j, count=0; | 198 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 199 | PyObject *sub; | 200 | | 201 | if (list == NULL) Branch (201:9): [True: 0, False: 39]
| 202 | return NULL; | 203 | | 204 | i = j = str_len - 1; | 205 | while (maxcount-- > 0) { Branch (205:12): [True: 127, False: 20]
| 206 | while (i >= 0 && STRINGLIB_ISSPACE278 (str[i])) Branch (206:16): [True: 278, False: 19]
| 207 | i--; | 208 | if (i < 0) break19 ; Branch (208:13): [True: 19, False: 108]
| 209 | j = i; i--; | 210 | while (i >= 0 && !185 STRINGLIB_ISSPACE185 (str[i])) Branch (210:16): [True: 185, False: 19]
Branch (210:26): [True: 96, False: 89]
| 211 | i--; | 212 | #if !STRINGLIB_MUTABLE | 213 | if (j == str_len - 1 && i < 024 && STRINGLIB_CHECK_EXACT0 (str_obj)) { Branch (213:13): [True: 24, False: 84]
Branch (213:33): [True: 0, False: 24]
| 214 | /* No whitespace in str_obj, so just use it as list[0] */ | 215 | Py_INCREF(str_obj); | 216 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 217 | count++; | 218 | break; | 219 | } | 220 | #endif | 221 | SPLIT_ADD108 (str, i + 1, j + 1); | 222 | } | 223 | | 224 | if (i >= 0) { Branch (224:9): [True: 14, False: 25]
| 225 | /* Only occurs when maxcount was reached */ | 226 | /* Skip any remaining whitespace and copy to beginning of string */ | 227 | while (i >= 0 && STRINGLIB_ISSPACE41 (str[i])) Branch (227:16): [True: 41, False: 1]
| 228 | i--; | 229 | if (i >= 0) Branch (229:13): [True: 13, False: 1]
| 230 | SPLIT_ADD13 (str, 0, i + 1); | 231 | } | 232 | FIX_PREALLOC_SIZE(list); | 233 | if (PyList_Reverse(list) < 0) Branch (233:9): [True: 0, False: 39]
| 234 | goto onError; | 235 | return list; | 236 | | 237 | onError: | 238 | Py_DECREF(list); | 239 | return NULL; | 240 | } |
unicodeobject.c:asciilib_rsplit_whitespace Line | Count | Source | 196 | { | 197 | Py_ssize_t i, j, count=0; | 198 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 199 | PyObject *sub; | 200 | | 201 | if (list == NULL) Branch (201:9): [True: 0, False: 76]
| 202 | return NULL; | 203 | | 204 | i = j = str_len - 1; | 205 | while (maxcount-- > 0) { Branch (205:12): [True: 250, False: 40]
| 206 | while (i >= 0 && STRINGLIB_ISSPACE544 (str[i])544 ) Branch (206:16): [True: 544, False: 36]
Branch (206:26): [True: 330, False: 214]
| 207 | i--; | 208 | if (i < 0) break36 ; Branch (208:13): [True: 36, False: 214]
| 209 | j = i; i--; | 210 | while (i >= 0 && !362 STRINGLIB_ISSPACE362 (str[i])) Branch (210:16): [True: 362, False: 38]
Branch (210:26): [True: 186, False: 176]
| 211 | i--; | 212 | #if !STRINGLIB_MUTABLE | 213 | if (j == str_len - 1 && i < 046 && STRINGLIB_CHECK_EXACT0 (str_obj)) { Branch (213:13): [True: 46, False: 168]
Branch (213:33): [True: 0, False: 46]
| 214 | /* No whitespace in str_obj, so just use it as list[0] */ | 215 | Py_INCREF(str_obj); | 216 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 217 | count++; | 218 | break; | 219 | } | 220 | #endif | 221 | SPLIT_ADD214 (str, i + 1, j + 1); | 222 | } | 223 | | 224 | if (i >= 0) { Branch (224:9): [True: 28, False: 48]
| 225 | /* Only occurs when maxcount was reached */ | 226 | /* Skip any remaining whitespace and copy to beginning of string */ | 227 | while (i >= 0 && STRINGLIB_ISSPACE82 (str[i])82 ) Branch (227:16): [True: 82, False: 2]
Branch (227:26): [True: 56, False: 26]
| 228 | i--; | 229 | if (i >= 0) Branch (229:13): [True: 26, False: 2]
| 230 | SPLIT_ADD26 (str, 0, i + 1); | 231 | } | 232 | FIX_PREALLOC_SIZE(list); | 233 | if (PyList_Reverse(list) < 0) Branch (233:9): [True: 0, False: 76]
| 234 | goto onError; | 235 | return list; | 236 | | 237 | onError: | 238 | Py_DECREF(list); | 239 | return NULL; | 240 | } |
Unexecuted instantiation: unicodeobject.c:ucs1lib_rsplit_whitespace Unexecuted instantiation: unicodeobject.c:ucs2lib_rsplit_whitespace Unexecuted instantiation: unicodeobject.c:ucs4lib_rsplit_whitespace |
241 | |
242 | Py_LOCAL_INLINE(PyObject *) |
243 | STRINGLIB(rsplit_char)(PyObject* str_obj, |
244 | const STRINGLIB_CHAR* str, Py_ssize_t str_len, |
245 | const STRINGLIB_CHAR ch, |
246 | Py_ssize_t maxcount) |
247 | { |
248 | Py_ssize_t i, j, count=0; |
249 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); |
250 | PyObject *sub; |
251 | |
252 | if (list == NULL) Branch (252:9): [True: 0, False: 20]
Branch (252:9): [True: 0, False: 21]
Branch (252:9): [True: 0, False: 3.11k]
Branch (252:9): [True: 0, False: 3]
Branch (252:9): [True: 0, False: 5]
Branch (252:9): [True: 0, False: 8]
|
253 | return NULL; |
254 | |
255 | i = j = str_len - 1; |
256 | while ((i >= 0) && (maxcount-- > 0)6.48k ) { Branch (256:12): [True: 80, False: 10]
Branch (256:24): [True: 70, False: 10]
Branch (256:12): [True: 82, False: 11]
Branch (256:24): [True: 72, False: 10]
Branch (256:12): [True: 6.29k, False: 38]
Branch (256:24): [True: 3.21k, False: 3.07k]
Branch (256:12): [True: 6, False: 0]
Branch (256:24): [True: 3, False: 3]
Branch (256:12): [True: 8, False: 5]
Branch (256:24): [True: 8, False: 0]
Branch (256:12): [True: 13, False: 8]
Branch (256:24): [True: 13, False: 0]
|
257 | for(; i >= 0; i--23.6k ) { Branch (257:15): [True: 156, False: 7]
Branch (257:15): [True: 159, False: 8]
Branch (257:15): [True: 26.4k, False: 34]
Branch (257:15): [True: 10, False: 0]
Branch (257:15): [True: 93, False: 5]
Branch (257:15): [True: 149, False: 8]
|
258 | if (str[i] == ch) { Branch (258:17): [True: 63, False: 93]
Branch (258:17): [True: 64, False: 95]
Branch (258:17): [True: 3.18k, False: 23.2k]
Branch (258:17): [True: 3, False: 7]
Branch (258:17): [True: 3, False: 90]
Branch (258:17): [True: 5, False: 144]
|
259 | SPLIT_ADD(str, i + 1, j + 1); |
260 | j = i = i - 1; |
261 | break; |
262 | } |
263 | } |
264 | } |
265 | #if !STRINGLIB_MUTABLE |
266 | if (count == 0 && STRINGLIB_CHECK_EXACT48 (str_obj)) { Branch (266:9): [True: 3, False: 18]
Branch (266:9): [True: 40, False: 3.07k]
Branch (266:9): [True: 0, False: 3]
Branch (266:9): [True: 2, False: 3]
Branch (266:9): [True: 3, False: 5]
|
267 | /* ch not in str_obj, so just use str_obj as list[0] */ |
268 | Py_INCREF(str_obj); |
269 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); |
270 | count++; |
271 | } else |
272 | #endif |
273 | if (3.10k j >= -1) { Branch (273:9): [True: 20, False: 0]
Branch (273:9): [True: 18, False: 0]
Branch (273:9): [True: 3.07k, False: 0]
Branch (273:9): [True: 3, False: 0]
Branch (273:9): [True: 3, False: 0]
Branch (273:9): [True: 5, False: 0]
|
274 | SPLIT_ADD3.12k (str, 0, j + 1); |
275 | } |
276 | FIX_PREALLOC_SIZE(list); |
277 | if (PyList_Reverse(list) < 0) Branch (277:9): [True: 0, False: 20]
Branch (277:9): [True: 0, False: 21]
Branch (277:9): [True: 0, False: 3.11k]
Branch (277:9): [True: 0, False: 3]
Branch (277:9): [True: 0, False: 5]
Branch (277:9): [True: 0, False: 8]
|
278 | goto onError; |
279 | return list; |
280 | |
281 | onError: |
282 | Py_DECREF(list); |
283 | return NULL; |
284 | } bytearrayobject.c:stringlib_rsplit_char Line | Count | Source | 247 | { | 248 | Py_ssize_t i, j, count=0; | 249 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 250 | PyObject *sub; | 251 | | 252 | if (list == NULL) Branch (252:9): [True: 0, False: 20]
| 253 | return NULL; | 254 | | 255 | i = j = str_len - 1; | 256 | while ((i >= 0) && (maxcount-- > 0)80 ) { Branch (256:12): [True: 80, False: 10]
Branch (256:24): [True: 70, False: 10]
| 257 | for(; i >= 0; i--93 ) { Branch (257:15): [True: 156, False: 7]
| 258 | if (str[i] == ch) { Branch (258:17): [True: 63, False: 93]
| 259 | SPLIT_ADD(str, i + 1, j + 1); | 260 | j = i = i - 1; | 261 | break; | 262 | } | 263 | } | 264 | } | 265 | #if !STRINGLIB_MUTABLE | 266 | if (count == 0 && STRINGLIB_CHECK_EXACT(str_obj)) { | 267 | /* ch not in str_obj, so just use str_obj as list[0] */ | 268 | Py_INCREF(str_obj); | 269 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 270 | count++; | 271 | } else | 272 | #endif | 273 | if (j >= -1) { Branch (273:9): [True: 20, False: 0]
| 274 | SPLIT_ADD20 (str, 0, j + 1); | 275 | } | 276 | FIX_PREALLOC_SIZE(list); | 277 | if (PyList_Reverse(list) < 0) Branch (277:9): [True: 0, False: 20]
| 278 | goto onError; | 279 | return list; | 280 | | 281 | onError: | 282 | Py_DECREF(list); | 283 | return NULL; | 284 | } |
bytesobject.c:stringlib_rsplit_char Line | Count | Source | 247 | { | 248 | Py_ssize_t i, j, count=0; | 249 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 250 | PyObject *sub; | 251 | | 252 | if (list == NULL) Branch (252:9): [True: 0, False: 21]
| 253 | return NULL; | 254 | | 255 | i = j = str_len - 1; | 256 | while ((i >= 0) && (maxcount-- > 0)82 ) { Branch (256:12): [True: 82, False: 11]
Branch (256:24): [True: 72, False: 10]
| 257 | for(; i >= 0; i--95 ) { Branch (257:15): [True: 159, False: 8]
| 258 | if (str[i] == ch) { Branch (258:17): [True: 64, False: 95]
| 259 | SPLIT_ADD(str, i + 1, j + 1); | 260 | j = i = i - 1; | 261 | break; | 262 | } | 263 | } | 264 | } | 265 | #if !STRINGLIB_MUTABLE | 266 | if (count == 0 && STRINGLIB_CHECK_EXACT3 (str_obj)) { Branch (266:9): [True: 3, False: 18]
| 267 | /* ch not in str_obj, so just use str_obj as list[0] */ | 268 | Py_INCREF(str_obj); | 269 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 270 | count++; | 271 | } else | 272 | #endif | 273 | if (j >= -1) { Branch (273:9): [True: 18, False: 0]
| 274 | SPLIT_ADD18 (str, 0, j + 1); | 275 | } | 276 | FIX_PREALLOC_SIZE(list); | 277 | if (PyList_Reverse(list) < 0) Branch (277:9): [True: 0, False: 21]
| 278 | goto onError; | 279 | return list; | 280 | | 281 | onError: | 282 | Py_DECREF(list); | 283 | return NULL; | 284 | } |
unicodeobject.c:asciilib_rsplit_char Line | Count | Source | 247 | { | 248 | Py_ssize_t i, j, count=0; | 249 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 250 | PyObject *sub; | 251 | | 252 | if (list == NULL) Branch (252:9): [True: 0, False: 3.11k]
| 253 | return NULL; | 254 | | 255 | i = j = str_len - 1; | 256 | while ((i >= 0) && (maxcount-- > 0)6.29k ) { Branch (256:12): [True: 6.29k, False: 38]
Branch (256:24): [True: 3.21k, False: 3.07k]
| 257 | for(; i >= 0; i--23.2k ) { Branch (257:15): [True: 26.4k, False: 34]
| 258 | if (str[i] == ch) { Branch (258:17): [True: 3.18k, False: 23.2k]
| 259 | SPLIT_ADD(str, i + 1, j + 1); | 260 | j = i = i - 1; | 261 | break; | 262 | } | 263 | } | 264 | } | 265 | #if !STRINGLIB_MUTABLE | 266 | if (count == 0 && STRINGLIB_CHECK_EXACT40 (str_obj)) { Branch (266:9): [True: 40, False: 3.07k]
| 267 | /* ch not in str_obj, so just use str_obj as list[0] */ | 268 | Py_INCREF(str_obj); | 269 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 270 | count++; | 271 | } else | 272 | #endif | 273 | if (j >= -1) { Branch (273:9): [True: 3.07k, False: 0]
| 274 | SPLIT_ADD3.07k (str, 0, j + 1); | 275 | } | 276 | FIX_PREALLOC_SIZE(list); | 277 | if (PyList_Reverse(list) < 0) Branch (277:9): [True: 0, False: 3.11k]
| 278 | goto onError; | 279 | return list; | 280 | | 281 | onError: | 282 | Py_DECREF(list); | 283 | return NULL; | 284 | } |
unicodeobject.c:ucs1lib_rsplit_char Line | Count | Source | 247 | { | 248 | Py_ssize_t i, j, count=0; | 249 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 250 | PyObject *sub; | 251 | | 252 | if (list == NULL) Branch (252:9): [True: 0, False: 3]
| 253 | return NULL; | 254 | | 255 | i = j = str_len - 1; | 256 | while ((i >= 0) && (maxcount-- > 0)) { Branch (256:12): [True: 6, False: 0]
Branch (256:24): [True: 3, False: 3]
| 257 | for(; i >= 0; i--7 ) { Branch (257:15): [True: 10, False: 0]
| 258 | if (str[i] == ch) { Branch (258:17): [True: 3, False: 7]
| 259 | SPLIT_ADD(str, i + 1, j + 1); | 260 | j = i = i - 1; | 261 | break; | 262 | } | 263 | } | 264 | } | 265 | #if !STRINGLIB_MUTABLE | 266 | if (count == 0 && STRINGLIB_CHECK_EXACT0 (str_obj)) { Branch (266:9): [True: 0, False: 3]
| 267 | /* ch not in str_obj, so just use str_obj as list[0] */ | 268 | Py_INCREF(str_obj); | 269 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 270 | count++; | 271 | } else | 272 | #endif | 273 | if (j >= -1) { Branch (273:9): [True: 3, False: 0]
| 274 | SPLIT_ADD3 (str, 0, j + 1); | 275 | } | 276 | FIX_PREALLOC_SIZE(list); | 277 | if (PyList_Reverse(list) < 0) Branch (277:9): [True: 0, False: 3]
| 278 | goto onError; | 279 | return list; | 280 | | 281 | onError: | 282 | Py_DECREF(list); | 283 | return NULL; | 284 | } |
unicodeobject.c:ucs2lib_rsplit_char Line | Count | Source | 247 | { | 248 | Py_ssize_t i, j, count=0; | 249 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 250 | PyObject *sub; | 251 | | 252 | if (list == NULL) Branch (252:9): [True: 0, False: 5]
| 253 | return NULL; | 254 | | 255 | i = j = str_len - 1; | 256 | while ((i >= 0) && (maxcount-- > 0)8 ) { Branch (256:12): [True: 8, False: 5]
Branch (256:24): [True: 8, False: 0]
| 257 | for(; i >= 0; i--90 ) { Branch (257:15): [True: 93, False: 5]
| 258 | if (str[i] == ch) { Branch (258:17): [True: 3, False: 90]
| 259 | SPLIT_ADD(str, i + 1, j + 1); | 260 | j = i = i - 1; | 261 | break; | 262 | } | 263 | } | 264 | } | 265 | #if !STRINGLIB_MUTABLE | 266 | if (count == 0 && STRINGLIB_CHECK_EXACT2 (str_obj)) { Branch (266:9): [True: 2, False: 3]
| 267 | /* ch not in str_obj, so just use str_obj as list[0] */ | 268 | Py_INCREF(str_obj); | 269 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 270 | count++; | 271 | } else | 272 | #endif | 273 | if (j >= -1) { Branch (273:9): [True: 3, False: 0]
| 274 | SPLIT_ADD3 (str, 0, j + 1); | 275 | } | 276 | FIX_PREALLOC_SIZE(list); | 277 | if (PyList_Reverse(list) < 0) Branch (277:9): [True: 0, False: 5]
| 278 | goto onError; | 279 | return list; | 280 | | 281 | onError: | 282 | Py_DECREF(list); | 283 | return NULL; | 284 | } |
unicodeobject.c:ucs4lib_rsplit_char Line | Count | Source | 247 | { | 248 | Py_ssize_t i, j, count=0; | 249 | PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); | 250 | PyObject *sub; | 251 | | 252 | if (list == NULL) Branch (252:9): [True: 0, False: 8]
| 253 | return NULL; | 254 | | 255 | i = j = str_len - 1; | 256 | while ((i >= 0) && (maxcount-- > 0)13 ) { Branch (256:12): [True: 13, False: 8]
Branch (256:24): [True: 13, False: 0]
| 257 | for(; i >= 0; i--144 ) { Branch (257:15): [True: 149, False: 8]
| 258 | if (str[i] == ch) { Branch (258:17): [True: 5, False: 144]
| 259 | SPLIT_ADD(str, i + 1, j + 1); | 260 | j = i = i - 1; | 261 | break; | 262 | } | 263 | } | 264 | } | 265 | #if !STRINGLIB_MUTABLE | 266 | if (count == 0 && STRINGLIB_CHECK_EXACT3 (str_obj)) { Branch (266:9): [True: 3, False: 5]
| 267 | /* ch not in str_obj, so just use str_obj as list[0] */ | 268 | Py_INCREF(str_obj); | 269 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 270 | count++; | 271 | } else | 272 | #endif | 273 | if (j >= -1) { Branch (273:9): [True: 5, False: 0]
| 274 | SPLIT_ADD5 (str, 0, j + 1); | 275 | } | 276 | FIX_PREALLOC_SIZE(list); | 277 | if (PyList_Reverse(list) < 0) Branch (277:9): [True: 0, False: 8]
| 278 | goto onError; | 279 | return list; | 280 | | 281 | onError: | 282 | Py_DECREF(list); | 283 | return NULL; | 284 | } |
|
285 | |
286 | Py_LOCAL_INLINE(PyObject *) |
287 | STRINGLIB(rsplit)(PyObject* str_obj, |
288 | const STRINGLIB_CHAR* str, Py_ssize_t str_len, |
289 | const STRINGLIB_CHAR* sep, Py_ssize_t sep_len, |
290 | Py_ssize_t maxcount) |
291 | { |
292 | Py_ssize_t j, pos, count=0; |
293 | PyObject *list, *sub; |
294 | |
295 | if (sep_len == 0) { Branch (295:9): [True: 2, False: 43]
Branch (295:9): [True: 2, False: 44]
Branch (295:9): [True: 4, False: 3.16k]
Branch (295:9): [True: 0, False: 3]
Branch (295:9): [True: 0, False: 10]
Branch (295:9): [True: 0, False: 16]
|
296 | PyErr_SetString(PyExc_ValueError, "empty separator"); |
297 | return NULL; |
298 | } |
299 | else if (sep_len == 1) Branch (299:14): [True: 20, False: 23]
Branch (299:14): [True: 21, False: 23]
Branch (299:14): [True: 3.11k, False: 44]
Branch (299:14): [True: 3, False: 0]
Branch (299:14): [True: 5, False: 5]
Branch (299:14): [True: 8, False: 8]
|
300 | return STRINGLIB(rsplit_char)(str_obj, str, str_len, sep[0], maxcount); |
301 | |
302 | list = PyList_New(PREALLOC_SIZE(maxcount)); |
303 | if (list == NULL) Branch (303:9): [True: 0, False: 23]
Branch (303:9): [True: 0, False: 23]
Branch (303:9): [True: 0, False: 44]
Branch (303:9): [True: 0, False: 0]
Branch (303:9): [True: 0, False: 5]
Branch (303:9): [True: 0, False: 8]
|
304 | return NULL; |
305 | |
306 | j = str_len; |
307 | while (maxcount-- > 0) { Branch (307:12): [True: 98, False: 8]
Branch (307:12): [True: 98, False: 8]
Branch (307:12): [True: 195, False: 16]
Branch (307:12): [True: 0, False: 0]
Branch (307:12): [True: 8, False: 0]
Branch (307:12): [True: 13, False: 0]
|
308 | pos = FASTSEARCH(str, j, sep, sep_len, -1, FAST_RSEARCH); |
309 | if (pos < 0) Branch (309:13): [True: 15, False: 83]
Branch (309:13): [True: 15, False: 83]
Branch (309:13): [True: 28, False: 167]
Branch (309:13): [True: 0, False: 0]
Branch (309:13): [True: 5, False: 3]
Branch (309:13): [True: 8, False: 5]
|
310 | break; |
311 | SPLIT_ADD341 (str, pos + sep_len, j); |
312 | j = pos; |
313 | } |
314 | #if !STRINGLIB_MUTABLE |
315 | if (count == 0 && STRINGLIB_CHECK_EXACT17 (str_obj)) { Branch (315:9): [True: 5, False: 18]
Branch (315:9): [True: 7, False: 37]
Branch (315:9): [True: 0, False: 0]
Branch (315:9): [True: 2, False: 3]
Branch (315:9): [True: 3, False: 5]
|
316 | /* No match in str_obj, so just use it as list[0] */ |
317 | Py_INCREF(str_obj); |
318 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); |
319 | count++; |
320 | } else |
321 | #endif |
322 | { |
323 | SPLIT_ADD86 (str, 0, j); |
324 | } |
325 | FIX_PREALLOC_SIZE(list); |
326 | if (PyList_Reverse(list) < 0) Branch (326:9): [True: 0, False: 23]
Branch (326:9): [True: 0, False: 23]
Branch (326:9): [True: 0, False: 44]
Branch (326:9): [True: 0, False: 0]
Branch (326:9): [True: 0, False: 5]
Branch (326:9): [True: 0, False: 8]
|
327 | goto onError; |
328 | return list; |
329 | |
330 | onError: |
331 | Py_DECREF(list); |
332 | return NULL; |
333 | } bytearrayobject.c:stringlib_rsplit Line | Count | Source | 291 | { | 292 | Py_ssize_t j, pos, count=0; | 293 | PyObject *list, *sub; | 294 | | 295 | if (sep_len == 0) { Branch (295:9): [True: 2, False: 43]
| 296 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 297 | return NULL; | 298 | } | 299 | else if (sep_len == 1) Branch (299:14): [True: 20, False: 23]
| 300 | return STRINGLIB(rsplit_char)(str_obj, str, str_len, sep[0], maxcount); | 301 | | 302 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 303 | if (list == NULL) Branch (303:9): [True: 0, False: 23]
| 304 | return NULL; | 305 | | 306 | j = str_len; | 307 | while (maxcount-- > 0) { Branch (307:12): [True: 98, False: 8]
| 308 | pos = FASTSEARCH(str, j, sep, sep_len, -1, FAST_RSEARCH); | 309 | if (pos < 0) Branch (309:13): [True: 15, False: 83]
| 310 | break; | 311 | SPLIT_ADD83 (str, pos + sep_len, j); | 312 | j = pos; | 313 | } | 314 | #if !STRINGLIB_MUTABLE | 315 | if (count == 0 && STRINGLIB_CHECK_EXACT(str_obj)) { | 316 | /* No match in str_obj, so just use it as list[0] */ | 317 | Py_INCREF(str_obj); | 318 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 319 | count++; | 320 | } else | 321 | #endif | 322 | { | 323 | SPLIT_ADD23 (str, 0, j); | 324 | } | 325 | FIX_PREALLOC_SIZE(list); | 326 | if (PyList_Reverse(list) < 023 ) Branch (326:9): [True: 0, False: 23]
| 327 | goto onError; | 328 | return list; | 329 | | 330 | onError: | 331 | Py_DECREF(list); | 332 | return NULL; | 333 | } |
bytesobject.c:stringlib_rsplit Line | Count | Source | 291 | { | 292 | Py_ssize_t j, pos, count=0; | 293 | PyObject *list, *sub; | 294 | | 295 | if (sep_len == 0) { Branch (295:9): [True: 2, False: 44]
| 296 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 297 | return NULL; | 298 | } | 299 | else if (sep_len == 1) Branch (299:14): [True: 21, False: 23]
| 300 | return STRINGLIB(rsplit_char)(str_obj, str, str_len, sep[0], maxcount); | 301 | | 302 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 303 | if (list == NULL) Branch (303:9): [True: 0, False: 23]
| 304 | return NULL; | 305 | | 306 | j = str_len; | 307 | while (maxcount-- > 0) { Branch (307:12): [True: 98, False: 8]
| 308 | pos = FASTSEARCH(str, j, sep, sep_len, -1, FAST_RSEARCH); | 309 | if (pos < 0) Branch (309:13): [True: 15, False: 83]
| 310 | break; | 311 | SPLIT_ADD83 (str, pos + sep_len, j); | 312 | j = pos; | 313 | } | 314 | #if !STRINGLIB_MUTABLE | 315 | if (count == 0 && STRINGLIB_CHECK_EXACT5 (str_obj)) { Branch (315:9): [True: 5, False: 18]
| 316 | /* No match in str_obj, so just use it as list[0] */ | 317 | Py_INCREF(str_obj); | 318 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 319 | count++; | 320 | } else | 321 | #endif | 322 | { | 323 | SPLIT_ADD18 (str, 0, j); | 324 | } | 325 | FIX_PREALLOC_SIZE(list); | 326 | if (PyList_Reverse(list) < 0) Branch (326:9): [True: 0, False: 23]
| 327 | goto onError; | 328 | return list; | 329 | | 330 | onError: | 331 | Py_DECREF(list); | 332 | return NULL; | 333 | } |
unicodeobject.c:asciilib_rsplit Line | Count | Source | 291 | { | 292 | Py_ssize_t j, pos, count=0; | 293 | PyObject *list, *sub; | 294 | | 295 | if (sep_len == 0) { Branch (295:9): [True: 4, False: 3.16k]
| 296 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 297 | return NULL; | 298 | } | 299 | else if (sep_len == 1) Branch (299:14): [True: 3.11k, False: 44]
| 300 | return STRINGLIB(rsplit_char)(str_obj, str, str_len, sep[0], maxcount); | 301 | | 302 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 303 | if (list == NULL) Branch (303:9): [True: 0, False: 44]
| 304 | return NULL; | 305 | | 306 | j = str_len; | 307 | while (maxcount-- > 0) { Branch (307:12): [True: 195, False: 16]
| 308 | pos = FASTSEARCH(str, j, sep, sep_len, -1, FAST_RSEARCH); | 309 | if (pos < 0) Branch (309:13): [True: 28, False: 167]
| 310 | break; | 311 | SPLIT_ADD167 (str, pos + sep_len, j); | 312 | j = pos; | 313 | } | 314 | #if !STRINGLIB_MUTABLE | 315 | if (count == 0 && STRINGLIB_CHECK_EXACT7 (str_obj)) { Branch (315:9): [True: 7, False: 37]
| 316 | /* No match in str_obj, so just use it as list[0] */ | 317 | Py_INCREF(str_obj); | 318 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 319 | count++; | 320 | } else | 321 | #endif | 322 | { | 323 | SPLIT_ADD37 (str, 0, j); | 324 | } | 325 | FIX_PREALLOC_SIZE(list); | 326 | if (PyList_Reverse(list) < 0) Branch (326:9): [True: 0, False: 44]
| 327 | goto onError; | 328 | return list; | 329 | | 330 | onError: | 331 | Py_DECREF(list); | 332 | return NULL; | 333 | } |
unicodeobject.c:ucs1lib_rsplit Line | Count | Source | 291 | { | 292 | Py_ssize_t j, pos, count=0; | 293 | PyObject *list, *sub; | 294 | | 295 | if (sep_len == 0) { Branch (295:9): [True: 0, False: 3]
| 296 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 297 | return NULL; | 298 | } | 299 | else if (sep_len == 1) Branch (299:14): [True: 3, False: 0]
| 300 | return STRINGLIB(rsplit_char)(str_obj, str, str_len, sep[0], maxcount); | 301 | | 302 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 303 | if (list == NULL) Branch (303:9): [True: 0, False: 0]
| 304 | return NULL; | 305 | | 306 | j = str_len; | 307 | while (maxcount-- > 0) { Branch (307:12): [True: 0, False: 0]
| 308 | pos = FASTSEARCH(str, j, sep, sep_len, -1, FAST_RSEARCH); | 309 | if (pos < 0) Branch (309:13): [True: 0, False: 0]
| 310 | break; | 311 | SPLIT_ADD(str, pos + sep_len, j); | 312 | j = pos; | 313 | } | 314 | #if !STRINGLIB_MUTABLE | 315 | if (count == 0 && STRINGLIB_CHECK_EXACT(str_obj)) { Branch (315:9): [True: 0, False: 0]
| 316 | /* No match in str_obj, so just use it as list[0] */ | 317 | Py_INCREF(str_obj); | 318 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 319 | count++; | 320 | } else | 321 | #endif | 322 | { | 323 | SPLIT_ADD(str, 0, j); | 324 | } | 325 | FIX_PREALLOC_SIZE(list); | 326 | if (PyList_Reverse(list) < 0) Branch (326:9): [True: 0, False: 0]
| 327 | goto onError; | 328 | return list; | 329 | | 330 | onError: | 331 | Py_DECREF(list); | 332 | return NULL; | 333 | } |
unicodeobject.c:ucs2lib_rsplit Line | Count | Source | 291 | { | 292 | Py_ssize_t j, pos, count=0; | 293 | PyObject *list, *sub; | 294 | | 295 | if (sep_len == 0) { Branch (295:9): [True: 0, False: 10]
| 296 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 297 | return NULL; | 298 | } | 299 | else if (sep_len == 1) Branch (299:14): [True: 5, False: 5]
| 300 | return STRINGLIB(rsplit_char)(str_obj, str, str_len, sep[0], maxcount); | 301 | | 302 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 303 | if (list == NULL) Branch (303:9): [True: 0, False: 5]
| 304 | return NULL; | 305 | | 306 | j = str_len; | 307 | while (maxcount-- > 0) { Branch (307:12): [True: 8, False: 0]
| 308 | pos = FASTSEARCH(str, j, sep, sep_len, -1, FAST_RSEARCH); | 309 | if (pos < 0) Branch (309:13): [True: 5, False: 3]
| 310 | break; | 311 | SPLIT_ADD3 (str, pos + sep_len, j); | 312 | j = pos; | 313 | } | 314 | #if !STRINGLIB_MUTABLE | 315 | if (count == 0 && STRINGLIB_CHECK_EXACT2 (str_obj)) { Branch (315:9): [True: 2, False: 3]
| 316 | /* No match in str_obj, so just use it as list[0] */ | 317 | Py_INCREF(str_obj); | 318 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 319 | count++; | 320 | } else | 321 | #endif | 322 | { | 323 | SPLIT_ADD3 (str, 0, j); | 324 | } | 325 | FIX_PREALLOC_SIZE(list); | 326 | if (PyList_Reverse(list) < 0) Branch (326:9): [True: 0, False: 5]
| 327 | goto onError; | 328 | return list; | 329 | | 330 | onError: | 331 | Py_DECREF(list); | 332 | return NULL; | 333 | } |
unicodeobject.c:ucs4lib_rsplit Line | Count | Source | 291 | { | 292 | Py_ssize_t j, pos, count=0; | 293 | PyObject *list, *sub; | 294 | | 295 | if (sep_len == 0) { Branch (295:9): [True: 0, False: 16]
| 296 | PyErr_SetString(PyExc_ValueError, "empty separator"); | 297 | return NULL; | 298 | } | 299 | else if (sep_len == 1) Branch (299:14): [True: 8, False: 8]
| 300 | return STRINGLIB(rsplit_char)(str_obj, str, str_len, sep[0], maxcount); | 301 | | 302 | list = PyList_New(PREALLOC_SIZE(maxcount)); | 303 | if (list == NULL) Branch (303:9): [True: 0, False: 8]
| 304 | return NULL; | 305 | | 306 | j = str_len; | 307 | while (maxcount-- > 0) { Branch (307:12): [True: 13, False: 0]
| 308 | pos = FASTSEARCH(str, j, sep, sep_len, -1, FAST_RSEARCH); | 309 | if (pos < 0) Branch (309:13): [True: 8, False: 5]
| 310 | break; | 311 | SPLIT_ADD5 (str, pos + sep_len, j); | 312 | j = pos; | 313 | } | 314 | #if !STRINGLIB_MUTABLE | 315 | if (count == 0 && STRINGLIB_CHECK_EXACT3 (str_obj)) { Branch (315:9): [True: 3, False: 5]
| 316 | /* No match in str_obj, so just use it as list[0] */ | 317 | Py_INCREF(str_obj); | 318 | PyList_SET_ITEM(list, 0, (PyObject *)str_obj); | 319 | count++; | 320 | } else | 321 | #endif | 322 | { | 323 | SPLIT_ADD5 (str, 0, j); | 324 | } | 325 | FIX_PREALLOC_SIZE(list); | 326 | if (PyList_Reverse(list) < 0) Branch (326:9): [True: 0, False: 8]
| 327 | goto onError; | 328 | return list; | 329 | | 330 | onError: | 331 | Py_DECREF(list); | 332 | return NULL; | 333 | } |
|
334 | |
335 | Py_LOCAL_INLINE(PyObject *) |
336 | STRINGLIB(splitlines)(PyObject* str_obj, |
337 | const STRINGLIB_CHAR* str, Py_ssize_t str_len, |
338 | int keepends) |
339 | { |
340 | /* This does not use the preallocated list because splitlines is |
341 | usually run with hundreds of newlines. The overhead of |
342 | switching between PyList_SET_ITEM and append causes about a |
343 | 2-3% slowdown for that common case. A smarter implementation |
344 | could move the if check out, so the SET_ITEMs are done first |
345 | and the appends only done when the prealloc buffer is full. |
346 | That's too much work for little gain.*/ |
347 | |
348 | Py_ssize_t i; |
349 | Py_ssize_t j; |
350 | PyObject *list = PyList_New(0); |
351 | PyObject *sub; |
352 | |
353 | if (list == NULL) Branch (353:9): [True: 0, False: 20]
Branch (353:9): [True: 0, False: 659]
Branch (353:9): [True: 0, False: 157k]
Branch (353:9): [True: 0, False: 765]
Branch (353:9): [True: 0, False: 168k]
Branch (353:9): [True: 0, False: 795]
|
354 | return NULL; |
355 | |
356 | for (i = j = 0; 328k i < str_len; ) { Branch (356:21): [True: 260, False: 20]
Branch (356:21): [True: 33.8k, False: 476]
Branch (356:21): [True: 305k, False: 119k]
Branch (356:21): [True: 7.94k, False: 530]
Branch (356:21): [True: 241k, False: 28.9k]
Branch (356:21): [True: 1.90k, False: 380]
|
357 | Py_ssize_t eol; |
358 | |
359 | /* Find a line and append it */ |
360 | while (i < str_len && !13.2M STRINGLIB_ISLINEBREAK13.2M (str[i])) Branch (360:16): [True: 7.59k, False: 4]
Branch (360:16): [True: 1.19M, False: 182]
Branch (360:16): [True: 8.06M, False: 56.9k]
Branch (360:31): [True: 7.81M, False: 248k]
Branch (360:16): [True: 348k, False: 615]
Branch (360:31): [True: 340k, False: 7.33k]
Branch (360:16): [True: 3.59M, False: 153k]
Branch (360:31): [True: 3.50M, False: 87.6k]
Branch (360:16): [True: 66.1k, False: 286]
Branch (360:31): [True: 64.5k, False: 1.62k]
|
361 | i++; |
362 | |
363 | /* Skip the line break reading CRLF as one line break */ |
364 | eol = i; |
365 | if (i < str_len) { Branch (365:13): [True: 256, False: 4]
Branch (365:13): [True: 33.6k, False: 182]
Branch (365:13): [True: 248k, False: 56.9k]
Branch (365:13): [True: 7.33k, False: 615]
Branch (365:13): [True: 87.6k, False: 153k]
Branch (365:13): [True: 1.62k, False: 286]
|
366 | if (str[i] == '\r' && i + 1 < str_len58.9k && str[i+1] == '\n'49.9k ) Branch (366:17): [True: 124, False: 132]
Branch (366:35): [True: 118, False: 6]
Branch (366:54): [True: 117, False: 1]
Branch (366:17): [True: 2.26k, False: 31.3k]
Branch (366:35): [True: 2.25k, False: 6]
Branch (366:54): [True: 2.24k, False: 13]
Branch (366:17): [True: 56.4k, False: 192k]
Branch (366:35): [True: 47.4k, False: 8.94k]
Branch (366:54): [True: 28.7k, False: 18.7k]
Branch (366:17): [True: 0, False: 7.33k]
Branch (366:35): [True: 0, False: 0]
Branch (366:54): [True: 0, False: 0]
Branch (366:17): [True: 132, False: 87.5k]
Branch (366:35): [True: 121, False: 11]
Branch (366:54): [True: 55, False: 66]
Branch (366:17): [True: 0, False: 1.62k]
Branch (366:35): [True: 0, False: 0]
Branch (366:54): [True: 0, False: 0]
|
367 | i += 2; |
368 | else |
369 | i++; |
370 | if (keepends) Branch (370:17): [True: 10, False: 246]
Branch (370:17): [True: 32.5k, False: 1.09k]
Branch (370:17): [True: 162k, False: 86.4k]
Branch (370:17): [True: 3.36k, False: 3.96k]
Branch (370:17): [True: 50.0k, False: 37.6k]
Branch (370:17): [True: 1.52k, False: 97]
|
371 | eol = i; |
372 | } |
373 | #if !STRINGLIB_MUTABLE |
374 | if (j == 0 && eol == str_len325k && STRINGLIB_CHECK_EXACT178k (str_obj)) { Branch (374:13): [True: 655, False: 33.1k]
Branch (374:23): [True: 183, False: 472]
Branch (374:13): [True: 154k, False: 151k]
Branch (374:23): [True: 38.3k, False: 116k]
Branch (374:13): [True: 765, False: 7.18k]
Branch (374:23): [True: 235, False: 530]
Branch (374:13): [True: 168k, False: 72.5k]
Branch (374:23): [True: 139k, False: 28.9k]
Branch (374:13): [True: 795, False: 1.11k]
Branch (374:23): [True: 415, False: 380]
|
375 | /* No linebreak in str_obj, so just use it as list[0] */ |
376 | if (PyList_Append(list, str_obj)) Branch (376:17): [True: 0, False: 183]
Branch (376:17): [True: 0, False: 38.3k]
Branch (376:17): [True: 0, False: 235]
Branch (376:17): [True: 0, False: 139k]
Branch (376:17): [True: 0, False: 415]
|
377 | goto onError; |
378 | break; |
379 | } |
380 | #endif |
381 | SPLIT_APPEND412k (str, j, eol); |
382 | j = i; |
383 | } |
384 | return list; |
385 | |
386 | onError: |
387 | Py_DECREF(list); |
388 | return NULL; |
389 | } bytearrayobject.c:stringlib_splitlines Line | Count | Source | 339 | { | 340 | /* This does not use the preallocated list because splitlines is | 341 | usually run with hundreds of newlines. The overhead of | 342 | switching between PyList_SET_ITEM and append causes about a | 343 | 2-3% slowdown for that common case. A smarter implementation | 344 | could move the if check out, so the SET_ITEMs are done first | 345 | and the appends only done when the prealloc buffer is full. | 346 | That's too much work for little gain.*/ | 347 | | 348 | Py_ssize_t i; | 349 | Py_ssize_t j; | 350 | PyObject *list = PyList_New(0); | 351 | PyObject *sub; | 352 | | 353 | if (list == NULL) Branch (353:9): [True: 0, False: 20]
| 354 | return NULL; | 355 | | 356 | for (i = j = 0; 20 i < str_len; ) { Branch (356:21): [True: 260, False: 20]
| 357 | Py_ssize_t eol; | 358 | | 359 | /* Find a line and append it */ | 360 | while (i < str_len && !7.59k STRINGLIB_ISLINEBREAK7.59k (str[i])) Branch (360:16): [True: 7.59k, False: 4]
| 361 | i++; | 362 | | 363 | /* Skip the line break reading CRLF as one line break */ | 364 | eol = i; | 365 | if (i < str_len) { Branch (365:13): [True: 256, False: 4]
| 366 | if (str[i] == '\r' && i + 1 < str_len124 && str[i+1] == '\n'118 ) Branch (366:17): [True: 124, False: 132]
Branch (366:35): [True: 118, False: 6]
Branch (366:54): [True: 117, False: 1]
| 367 | i += 2; | 368 | else | 369 | i++; | 370 | if (keepends) Branch (370:17): [True: 10, False: 246]
| 371 | eol = i; | 372 | } | 373 | #if !STRINGLIB_MUTABLE | 374 | if (j == 0 && eol == str_len && STRINGLIB_CHECK_EXACT(str_obj)) { | 375 | /* No linebreak in str_obj, so just use it as list[0] */ | 376 | if (PyList_Append(list, str_obj)) | 377 | goto onError; | 378 | break; | 379 | } | 380 | #endif | 381 | SPLIT_APPEND(str, j, eol); | 382 | j = i; | 383 | } | 384 | return list; | 385 | | 386 | onError: | 387 | Py_DECREF(list); | 388 | return NULL; | 389 | } |
bytesobject.c:stringlib_splitlines Line | Count | Source | 339 | { | 340 | /* This does not use the preallocated list because splitlines is | 341 | usually run with hundreds of newlines. The overhead of | 342 | switching between PyList_SET_ITEM and append causes about a | 343 | 2-3% slowdown for that common case. A smarter implementation | 344 | could move the if check out, so the SET_ITEMs are done first | 345 | and the appends only done when the prealloc buffer is full. | 346 | That's too much work for little gain.*/ | 347 | | 348 | Py_ssize_t i; | 349 | Py_ssize_t j; | 350 | PyObject *list = PyList_New(0); | 351 | PyObject *sub; | 352 | | 353 | if (list == NULL) Branch (353:9): [True: 0, False: 659]
| 354 | return NULL; | 355 | | 356 | for (i = j = 0; 659 i < str_len; ) { Branch (356:21): [True: 33.8k, False: 476]
| 357 | Py_ssize_t eol; | 358 | | 359 | /* Find a line and append it */ | 360 | while (i < str_len && !1.19M STRINGLIB_ISLINEBREAK1.19M (str[i])) Branch (360:16): [True: 1.19M, False: 182]
| 361 | i++; | 362 | | 363 | /* Skip the line break reading CRLF as one line break */ | 364 | eol = i; | 365 | if (i < str_len) { Branch (365:13): [True: 33.6k, False: 182]
| 366 | if (str[i] == '\r' && i + 1 < str_len2.26k && str[i+1] == '\n'2.25k ) Branch (366:17): [True: 2.26k, False: 31.3k]
Branch (366:35): [True: 2.25k, False: 6]
Branch (366:54): [True: 2.24k, False: 13]
| 367 | i += 2; | 368 | else | 369 | i++; | 370 | if (keepends) Branch (370:17): [True: 32.5k, False: 1.09k]
| 371 | eol = i; | 372 | } | 373 | #if !STRINGLIB_MUTABLE | 374 | if (j == 0 && eol == str_len655 && STRINGLIB_CHECK_EXACT183 (str_obj)) { Branch (374:13): [True: 655, False: 33.1k]
Branch (374:23): [True: 183, False: 472]
| 375 | /* No linebreak in str_obj, so just use it as list[0] */ | 376 | if (PyList_Append(list, str_obj)) Branch (376:17): [True: 0, False: 183]
| 377 | goto onError; | 378 | break; | 379 | } | 380 | #endif | 381 | SPLIT_APPEND33.6k (str, j, eol); | 382 | j = i; | 383 | } | 384 | return list; | 385 | | 386 | onError: | 387 | Py_DECREF(list); | 388 | return NULL; | 389 | } |
unicodeobject.c:asciilib_splitlines Line | Count | Source | 339 | { | 340 | /* This does not use the preallocated list because splitlines is | 341 | usually run with hundreds of newlines. The overhead of | 342 | switching between PyList_SET_ITEM and append causes about a | 343 | 2-3% slowdown for that common case. A smarter implementation | 344 | could move the if check out, so the SET_ITEMs are done first | 345 | and the appends only done when the prealloc buffer is full. | 346 | That's too much work for little gain.*/ | 347 | | 348 | Py_ssize_t i; | 349 | Py_ssize_t j; | 350 | PyObject *list = PyList_New(0); | 351 | PyObject *sub; | 352 | | 353 | if (list == NULL) Branch (353:9): [True: 0, False: 157k]
| 354 | return NULL; | 355 | | 356 | for (i = j = 0; 157k i < str_len; ) { Branch (356:21): [True: 305k, False: 119k]
| 357 | Py_ssize_t eol; | 358 | | 359 | /* Find a line and append it */ | 360 | while (i < str_len && !8.06M STRINGLIB_ISLINEBREAK8.06M (str[i])) Branch (360:16): [True: 8.06M, False: 56.9k]
Branch (360:31): [True: 7.81M, False: 248k]
| 361 | i++; | 362 | | 363 | /* Skip the line break reading CRLF as one line break */ | 364 | eol = i; | 365 | if (i < str_len) { Branch (365:13): [True: 248k, False: 56.9k]
| 366 | if (str[i] == '\r' && i + 1 < str_len56.4k && str[i+1] == '\n'47.4k ) Branch (366:17): [True: 56.4k, False: 192k]
Branch (366:35): [True: 47.4k, False: 8.94k]
Branch (366:54): [True: 28.7k, False: 18.7k]
| 367 | i += 2; | 368 | else | 369 | i++; | 370 | if (keepends) Branch (370:17): [True: 162k, False: 86.4k]
| 371 | eol = i; | 372 | } | 373 | #if !STRINGLIB_MUTABLE | 374 | if (j == 0 && eol == str_len154k && STRINGLIB_CHECK_EXACT38.3k (str_obj)) { Branch (374:13): [True: 154k, False: 151k]
Branch (374:23): [True: 38.3k, False: 116k]
| 375 | /* No linebreak in str_obj, so just use it as list[0] */ | 376 | if (PyList_Append(list, str_obj)) Branch (376:17): [True: 0, False: 38.3k]
| 377 | goto onError; | 378 | break; | 379 | } | 380 | #endif | 381 | SPLIT_APPEND267k (str, j, eol); | 382 | j = i; | 383 | } | 384 | return list; | 385 | | 386 | onError: | 387 | Py_DECREF(list); | 388 | return NULL; | 389 | } |
unicodeobject.c:ucs1lib_splitlines Line | Count | Source | 339 | { | 340 | /* This does not use the preallocated list because splitlines is | 341 | usually run with hundreds of newlines. The overhead of | 342 | switching between PyList_SET_ITEM and append causes about a | 343 | 2-3% slowdown for that common case. A smarter implementation | 344 | could move the if check out, so the SET_ITEMs are done first | 345 | and the appends only done when the prealloc buffer is full. | 346 | That's too much work for little gain.*/ | 347 | | 348 | Py_ssize_t i; | 349 | Py_ssize_t j; | 350 | PyObject *list = PyList_New(0); | 351 | PyObject *sub; | 352 | | 353 | if (list == NULL) Branch (353:9): [True: 0, False: 765]
| 354 | return NULL; | 355 | | 356 | for (i = j = 0; 765 i < str_len; ) { Branch (356:21): [True: 7.94k, False: 530]
| 357 | Py_ssize_t eol; | 358 | | 359 | /* Find a line and append it */ | 360 | while (i < str_len && !348k STRINGLIB_ISLINEBREAK348k (str[i])) Branch (360:16): [True: 348k, False: 615]
Branch (360:31): [True: 340k, False: 7.33k]
| 361 | i++; | 362 | | 363 | /* Skip the line break reading CRLF as one line break */ | 364 | eol = i; | 365 | if (i < str_len) { Branch (365:13): [True: 7.33k, False: 615]
| 366 | if (str[i] == '\r' && i + 1 < str_len0 && str[i+1] == '\n'0 ) Branch (366:17): [True: 0, False: 7.33k]
Branch (366:35): [True: 0, False: 0]
Branch (366:54): [True: 0, False: 0]
| 367 | i += 2; | 368 | else | 369 | i++; | 370 | if (keepends) Branch (370:17): [True: 3.36k, False: 3.96k]
| 371 | eol = i; | 372 | } | 373 | #if !STRINGLIB_MUTABLE | 374 | if (j == 0 && eol == str_len765 && STRINGLIB_CHECK_EXACT235 (str_obj)) { Branch (374:13): [True: 765, False: 7.18k]
Branch (374:23): [True: 235, False: 530]
| 375 | /* No linebreak in str_obj, so just use it as list[0] */ | 376 | if (PyList_Append(list, str_obj)) Branch (376:17): [True: 0, False: 235]
| 377 | goto onError; | 378 | break; | 379 | } | 380 | #endif | 381 | SPLIT_APPEND7.71k (str, j, eol); | 382 | j = i; | 383 | } | 384 | return list; | 385 | | 386 | onError: | 387 | Py_DECREF(list); | 388 | return NULL; | 389 | } |
unicodeobject.c:ucs2lib_splitlines Line | Count | Source | 339 | { | 340 | /* This does not use the preallocated list because splitlines is | 341 | usually run with hundreds of newlines. The overhead of | 342 | switching between PyList_SET_ITEM and append causes about a | 343 | 2-3% slowdown for that common case. A smarter implementation | 344 | could move the if check out, so the SET_ITEMs are done first | 345 | and the appends only done when the prealloc buffer is full. | 346 | That's too much work for little gain.*/ | 347 | | 348 | Py_ssize_t i; | 349 | Py_ssize_t j; | 350 | PyObject *list = PyList_New(0); | 351 | PyObject *sub; | 352 | | 353 | if (list == NULL) Branch (353:9): [True: 0, False: 168k]
| 354 | return NULL; | 355 | | 356 | for (i = j = 0; 168k i < str_len; ) { Branch (356:21): [True: 241k, False: 28.9k]
| 357 | Py_ssize_t eol; | 358 | | 359 | /* Find a line and append it */ | 360 | while (i < str_len && !3.59M STRINGLIB_ISLINEBREAK3.59M (str[i])) Branch (360:16): [True: 3.59M, False: 153k]
Branch (360:31): [True: 3.50M, False: 87.6k]
| 361 | i++; | 362 | | 363 | /* Skip the line break reading CRLF as one line break */ | 364 | eol = i; | 365 | if (i < str_len) { Branch (365:13): [True: 87.6k, False: 153k]
| 366 | if (str[i] == '\r' && i + 1 < str_len132 && str[i+1] == '\n'121 ) Branch (366:17): [True: 132, False: 87.5k]
Branch (366:35): [True: 121, False: 11]
Branch (366:54): [True: 55, False: 66]
| 367 | i += 2; | 368 | else | 369 | i++; | 370 | if (keepends) Branch (370:17): [True: 50.0k, False: 37.6k]
| 371 | eol = i; | 372 | } | 373 | #if !STRINGLIB_MUTABLE | 374 | if (j == 0 && eol == str_len168k && STRINGLIB_CHECK_EXACT139k (str_obj)) { Branch (374:13): [True: 168k, False: 72.5k]
Branch (374:23): [True: 139k, False: 28.9k]
| 375 | /* No linebreak in str_obj, so just use it as list[0] */ | 376 | if (PyList_Append(list, str_obj)) Branch (376:17): [True: 0, False: 139k]
| 377 | goto onError; | 378 | break; | 379 | } | 380 | #endif | 381 | SPLIT_APPEND101k (str, j, eol); | 382 | j = i; | 383 | } | 384 | return list; | 385 | | 386 | onError: | 387 | Py_DECREF(list); | 388 | return NULL; | 389 | } |
unicodeobject.c:ucs4lib_splitlines Line | Count | Source | 339 | { | 340 | /* This does not use the preallocated list because splitlines is | 341 | usually run with hundreds of newlines. The overhead of | 342 | switching between PyList_SET_ITEM and append causes about a | 343 | 2-3% slowdown for that common case. A smarter implementation | 344 | could move the if check out, so the SET_ITEMs are done first | 345 | and the appends only done when the prealloc buffer is full. | 346 | That's too much work for little gain.*/ | 347 | | 348 | Py_ssize_t i; | 349 | Py_ssize_t j; | 350 | PyObject *list = PyList_New(0); | 351 | PyObject *sub; | 352 | | 353 | if (list == NULL) Branch (353:9): [True: 0, False: 795]
| 354 | return NULL; | 355 | | 356 | for (i = j = 0; 795 i < str_len; ) { Branch (356:21): [True: 1.90k, False: 380]
| 357 | Py_ssize_t eol; | 358 | | 359 | /* Find a line and append it */ | 360 | while (i < str_len && !66.1k STRINGLIB_ISLINEBREAK66.1k (str[i])) Branch (360:16): [True: 66.1k, False: 286]
Branch (360:31): [True: 64.5k, False: 1.62k]
| 361 | i++; | 362 | | 363 | /* Skip the line break reading CRLF as one line break */ | 364 | eol = i; | 365 | if (i < str_len) { Branch (365:13): [True: 1.62k, False: 286]
| 366 | if (str[i] == '\r' && i + 1 < str_len0 && str[i+1] == '\n'0 ) Branch (366:17): [True: 0, False: 1.62k]
Branch (366:35): [True: 0, False: 0]
Branch (366:54): [True: 0, False: 0]
| 367 | i += 2; | 368 | else | 369 | i++; | 370 | if (keepends) Branch (370:17): [True: 1.52k, False: 97]
| 371 | eol = i; | 372 | } | 373 | #if !STRINGLIB_MUTABLE | 374 | if (j == 0 && eol == str_len795 && STRINGLIB_CHECK_EXACT415 (str_obj)) { Branch (374:13): [True: 795, False: 1.11k]
Branch (374:23): [True: 415, False: 380]
| 375 | /* No linebreak in str_obj, so just use it as list[0] */ | 376 | if (PyList_Append(list, str_obj)) Branch (376:17): [True: 0, False: 415]
| 377 | goto onError; | 378 | break; | 379 | } | 380 | #endif | 381 | SPLIT_APPEND1.49k (str, j, eol); | 382 | j = i; | 383 | } | 384 | return list; | 385 | | 386 | onError: | 387 | Py_DECREF(list); | 388 | return NULL; | 389 | } |
|
390 | |