[issue12751] Use macros for surrogates in unicodeobject.c

2011-08-16 Thread Benjamin Peterson
Changes by Benjamin Peterson : -- resolution: -> duplicate status: open -> closed superseder: -> Py_UNICODE_NEXT and other macros for surrogates ___ Python tracker ___

[issue12751] Use macros for surrogates in unicodeobject.c

2011-08-16 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Ezio Melotti wrote: > > Ezio Melotti added the comment: > > #10542 proposes the following macros to factor out common code: > #define _Py_UNICODE_ISSURROGATE > #define _Py_UNICODE_ISHIGHSURROGATE > #define _Py_UNICODE_ISLOWSURROGATE > #define _Py_UNIC

[issue12751] Use macros for surrogates in unicodeobject.c

2011-08-16 Thread Ezio Melotti
Ezio Melotti added the comment: #10542 proposes the following macros to factor out common code: #define _Py_UNICODE_ISSURROGATE #define _Py_UNICODE_ISHIGHSURROGATE #define _Py_UNICODE_ISLOWSURROGATE #define _Py_UNICODE_JOIN_SURROGATES and to avoid checking for narrow/wide builds and recombin

[issue12751] Use macros for surrogates in unicodeobject.c

2011-08-15 Thread STINNER Victor
STINNER Victor added the comment: > This has been proposed already in #10542 (the issue also has patches). The two issues are different: this issue is only a refactoring, whereas #10542 adds a new "feature" (function/macro: Py_UNICODE_NEXT). -- ___

[issue12751] Use macros for surrogates in unicodeobject.c

2011-08-15 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +belopolsky ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue12751] Use macros for surrogates in unicodeobject.c

2011-08-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: > HIGH_SURROGATE and LOW_SURROGATE require that their ordinal argument > has been preproceed to fit in [0; 0x]. I added this requirement in > the comment of these macros. The macros should preprocess the argument themselves. It will make the code even simpl

[issue12751] Use macros for surrogates in unicodeobject.c

2011-08-15 Thread Ezio Melotti
Ezio Melotti added the comment: This has been proposed already in #10542 (the issue also has patches). -- ___ Python tracker ___ ___

[issue12751] Use macros for surrogates in unicodeobject.c

2011-08-15 Thread STINNER Victor
STINNER Victor added the comment: We may use the following unlikely macro for IS_SURROGATE, IS_HIGH_SURROGATE and IS_LOW_SURROGATE: #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) I suppose that we should use microbenchmarks to validate th

[issue12751] Use macros for surrogates in unicodeobject.c

2011-08-15 Thread STINNER Victor
New submission from STINNER Victor : A lot of code is duplicated in unicodeobject.c to manipulate ("encode/decode") surrogates. Each function has from one to three different implementations. The new decode_ucs4() function adds a new implementation. Attached patch replaces this code by macros.