Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55e5dc8

Browse files
author
Kristján Valur Jónsson
committed
Rearrange code to beat an optimizer bug affecting Release x64 on windows
with VS2010sp1
1 parent a3394bc commit 55e5dc8

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

Objects/unicodeobject.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12038,30 +12038,28 @@ unicode_repr(PyObject *unicode)
1203812038
(categories Z* and C* except ASCII space)
1203912039
*/
1204012040
if (!Py_UNICODE_ISPRINTABLE(ch)) {
12041+
PyUnicode_WRITE(okind, odata, o++, '\\');
1204112042
/* Map 8-bit characters to '\xhh' */
1204212043
if (ch <= 0xff) {
12043-
PyUnicode_WRITE(okind, odata, o++, '\\');
1204412044
PyUnicode_WRITE(okind, odata, o++, 'x');
1204512045
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 4) & 0x000F]);
1204612046
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[ch & 0x000F]);
1204712047
}
12048-
/* Map 21-bit characters to '\U00xxxxxx' */
12049-
else if (ch >= 0x10000) {
12050-
PyUnicode_WRITE(okind, odata, o++, '\\');
12051-
PyUnicode_WRITE(okind, odata, o++, 'U');
12052-
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 28) & 0xF]);
12053-
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 24) & 0xF]);
12054-
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 20) & 0xF]);
12055-
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 16) & 0xF]);
12048+
/* Map 16-bit characters to '\uxxxx' */
12049+
else if (ch <= 0xffff) {
12050+
PyUnicode_WRITE(okind, odata, o++, 'u');
1205612051
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 12) & 0xF]);
1205712052
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 8) & 0xF]);
1205812053
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 4) & 0xF]);
1205912054
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[ch & 0xF]);
1206012055
}
12061-
/* Map 16-bit characters to '\uxxxx' */
12056+
/* Map 21-bit characters to '\U00xxxxxx' */
1206212057
else {
12063-
PyUnicode_WRITE(okind, odata, o++, '\\');
12064-
PyUnicode_WRITE(okind, odata, o++, 'u');
12058+
PyUnicode_WRITE(okind, odata, o++, 'U');
12059+
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 28) & 0xF]);
12060+
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 24) & 0xF]);
12061+
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 20) & 0xF]);
12062+
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 16) & 0xF]);
1206512063
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 12) & 0xF]);
1206612064
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 8) & 0xF]);
1206712065
PyUnicode_WRITE(okind, odata, o++, Py_hexdigits[(ch >> 4) & 0xF]);

0 commit comments

Comments
 (0)