| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Convert unicodeobject.h macros to static inline functions: * Reorder functions to declare functions before their first usage. * PyUnicode_READ_CHAR() and PyUnicode_MAX_CHAR_VALUE() now only call PyUnicode_KIND() once. * Simplify PyUnicode_GET_SIZE(). * PyUnicode_READ_CHAR() now uses PyUnicode_1BYTE_DATA(), PyUnicode_2BYTE_DATA() and PyUnicode_4BYTE_DATA(). * Remove redundant PyUnicode_Check() assertions. Static inline functions are wrapped into macros which casts pointer types (PyObject*, void*) to prevent introducing new compiler warnings when passing const pointers (ex: PyUnicode_WRITE). PyUnicode_KIND() return type is "unsigned int" rather than "enum PyUnicode_Kind" to prevent introducing new compiler warnings.
|
Changes since my #31221 POC:
I will re-do some on these changes (like deprecate functions) as separated PRs once this PR is merged. |
Sorry, something went wrong.
|
Ah, and I also updated comments :-) @erlend-aasland @gpshead: Would yo mind to review this PR? |
Sorry, something went wrong.
|
@erlend-aasland: Tell me if you prefer that I split this PR into smaller PRs. |
Sorry, something went wrong.
Oh. It seems like it's wrong. The following code emits a new compiler warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]. int skind = PyUnicode_KIND(self);
...
int rkind = skind;
...
assert(PyUnicode_KIND(u) == rkind);
|
Sorry, something went wrong.
I would prefer that, yes :) |
Sorry, something went wrong.
Here is a shorter PR: #91705 |
Sorry, something went wrong.
|
I splitted this PR into smaller PRs. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Convert unicodeobject.h macros to static inline functions:
PyUnicode_KIND() once.
PyUnicode_2BYTE_DATA() and PyUnicode_4BYTE_DATA().
Static inline functions are wrapped into macros which casts pointer
types (PyObject*, void*) to prevent introducing new compiler warnings
when passing const pointers (ex: PyUnicode_WRITE).
PyUnicode_KIND() return type is "unsigned int" rather than "enum
PyUnicode_Kind" to prevent introducing new compiler warnings.