Skip to content

Conversation

vstinner
Copy link
Member

Convert unicodeobject.h macros to static inline functions:

  • PyUnicode_MAX_CHAR_VALUE()
  • PyUnicode_READ()
  • PyUnicode_READY()
  • PyUnicode_READ_CHAR()
  • PyUnicode_WRITE()

Move PyUnicode_READY() after _PyUnicode_Ready(), since it uses
_PyUnicode_Ready().

Static inline functions are wrapped by macros which casts arguments
with _PyObject_CAST() and casts 'kind' arguments to "unsigned int" to
prevent introducing new compiler warnings when passing "const
PyObject*".

Convert unicodeobject.h macros to static inline functions:

* PyUnicode_MAX_CHAR_VALUE()
* PyUnicode_READ()
* PyUnicode_READY()
* PyUnicode_READ_CHAR()
* PyUnicode_WRITE()

Move PyUnicode_READY() after _PyUnicode_Ready(), since it uses
_PyUnicode_Ready().

Static inline functions are wrapped by macros which casts arguments
with _PyObject_CAST() and casts 'kind' arguments to "unsigned int" to
prevent introducing new compiler warnings when passing "const
PyObject*".
@vstinner
Copy link
Member Author

cc @erlend-aasland

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Increased readability and maintainability 🎉🥳

⚠️⛏️ nitpick ⛏️ ⚠️
  • I'd remove the last elses in your if-else-ladders
  • I'd use an if-else ladder instead of a switch in PyUnicode_WRITE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants