File tree 1 file changed +9
-9
lines changed
1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -436,17 +436,17 @@ static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *op)
436
436
if (PyUnicode_IS_ASCII (op)) {
437
437
return 0x7fU ;
438
438
}
439
-
439
+ static const Py_UCS4 max_char_values[] = {
440
+ [PyUnicode_1BYTE_KIND] = 0xffU ,
441
+ [PyUnicode_2BYTE_KIND] = 0xffffU ,
442
+ [PyUnicode_4BYTE_KIND] = 0x10ffffU ,
443
+ };
440
444
unsigned int kind = PyUnicode_KIND (op);
441
- if (kind == PyUnicode_1BYTE_KIND) {
442
- return 0xffU ;
443
- }
444
- if (kind == PyUnicode_2BYTE_KIND) {
445
- return 0xffffU ;
446
- }
447
- assert (kind == PyUnicode_4BYTE_KIND);
448
- return 0x10ffffU ;
445
+ const Py_UCS4 value = max_char_values[kind];
446
+ assert (value);
447
+ return value;
449
448
}
449
+
450
450
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
451
451
# define PyUnicode_MAX_CHAR_VALUE (op ) \
452
452
PyUnicode_MAX_CHAR_VALUE (_PyObject_CAST(op))
You can’t perform that action at this time.
0 commit comments