]> granicus.if.org Git - python/commitdiff
Simplify PyUnicode_MAX_CHAR_VALUE
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 12 Oct 2011 23:12:01 +0000 (01:12 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 12 Oct 2011 23:12:01 +0000 (01:12 +0200)
Use PyUnicode_IS_ASCII instead of PyUnicode_IS_COMPACT_ASCII, so the following
test can be removed:

   PyUnicode_DATA(op) == (((PyCompactUnicodeObject *)(op))->utf8)

Include/unicodeobject.h

index 8fbad0999e2b6f438b3e4944e23a24214b9f1f52..524ce8ab9ad35734c91af62a1aef1af5fc84546e 100644 (file)
@@ -548,14 +548,13 @@ enum PyUnicode_Kind {
    than iterating over the string. */
 #define PyUnicode_MAX_CHAR_VALUE(op) \
     (assert(PyUnicode_IS_READY(op)),                                    \
-     (PyUnicode_IS_COMPACT_ASCII(op) ? 0x7f:                            \
+     (PyUnicode_IS_ASCII(op) ?                                          \
+      (0x7f) :                                                          \
       (PyUnicode_KIND(op) == PyUnicode_1BYTE_KIND ?                     \
-       (PyUnicode_DATA(op) == (((PyCompactUnicodeObject *)(op))->utf8) ? \
-        (0x7fU) : (0xffU)                                                 \
-           ) :                                                          \
+       (0xffU) :                                                        \
        (PyUnicode_KIND(op) == PyUnicode_2BYTE_KIND ?                    \
-        (0xffffU) : (0x10ffffU)                                           \
-           ))))
+        (0xffffU) :                                                     \
+        (0x10ffffU)))))
 
 #endif