comparison configmix/_speedups.c @ 556:3d5ef056134c

Comment
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 04 Jan 2022 20:53:55 +0100
parents b7434a34a1f4
children ba8f1295e1e2
comparison
equal deleted inserted replaced
555:b7434a34a1f4 556:3d5ef056134c
164 return -1; 164 return -1;
165 } 165 }
166 } 166 }
167 /* 167 /*
168 * Figure out how many bytes the result will require. Turn any 168 * Figure out how many bytes the result will require. Turn any
169 * illegally large UTF32 things (> Plane 17) into replacement chars. 169 * illegally large UTF32 things (> Plane 17) into errors (exceptions).
170 */ 170 */
171 if (ch < (Py_UCS4)0x80) { 171 if (ch < (Py_UCS4)0x80) {
172 bytesToWrite = 1; 172 bytesToWrite = 1;
173 } else if (ch < (Py_UCS4)0x800) { 173 } else if (ch < (Py_UCS4)0x800) {
174 bytesToWrite = 2; 174 bytesToWrite = 2;
778 /* 778 /*
779 * The first item may be also the empty string if `s' starts with 779 * The first item may be also the empty string if `s' starts with
780 * an interpolation token. 780 * an interpolation token.
781 */ 781 */
782 first_part_is_empty = PyObject_Not(tmp); 782 first_part_is_empty = PyObject_Not(tmp);
783 Py_INCREF(tmp); /* because PyList_SetItem steals -- and o is borrowed */ 783 Py_INCREF(tmp); /* because PyList_SetItem steals -- and tmp is borrowed */
784 PyList_SetItem(res_parts, 0, tmp); /* steals -- cannot fail */ 784 PyList_SetItem(res_parts, 0, tmp); /* steals -- cannot fail here */
785 tmp = NULL; 785 tmp = NULL;
786 786
787 for (i=1; i<parts_len; i++) { 787 for (i=1; i<parts_len; i++) {
788 pb = PyList_GetItem(parts, i); /* borrowed */ 788 pb = PyList_GetItem(parts, i); /* borrowed */
789 pb_len = PyUnicode_GetLength(pb); 789 pb_len = PyUnicode_GetLength(pb);