mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Apply fixes and speedups
This commit is contained in:
parent
7521bf9e73
commit
725f4d79f6
36 changed files with 682 additions and 334 deletions
9
third_party/python/Modules/unicodedata.c
vendored
9
third_party/python/Modules/unicodedata.c
vendored
|
@ -5,6 +5,7 @@
|
|||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/nexgen32e/kompressor.h"
|
||||
#include "third_party/python/Include/floatobject.h"
|
||||
|
@ -404,7 +405,7 @@ unicodedata_UCD_decomposition_impl(PyObject *self, int chr)
|
|||
|
||||
/* high byte is number of hex bytes (usually one or two), low byte
|
||||
is prefix code (from*/
|
||||
count = _PyUnicode_Bextr(_PyUnicode_Decomp, index, _PyUnicode_DecompBits) >> 8;
|
||||
count = bextra(_PyUnicode_Decomp, index, _PyUnicode_DecompBits) >> 8;
|
||||
|
||||
/* XXX: could allocate the PyString up front instead
|
||||
(strlen(prefix) + 5 * count + 1 bytes) */
|
||||
|
@ -412,7 +413,7 @@ unicodedata_UCD_decomposition_impl(PyObject *self, int chr)
|
|||
/* Based on how index is calculated above and _PyUnicode_Decomp is
|
||||
generated from Tools/unicode/makeunicodedata.py, it should not be
|
||||
possible to overflow _PyUnicode_DecompPrefix. */
|
||||
prefix_index = _PyUnicode_Bextr(_PyUnicode_Decomp, index, _PyUnicode_DecompBits) & 255;
|
||||
prefix_index = bextra(_PyUnicode_Decomp, index, _PyUnicode_DecompBits) & 255;
|
||||
assert(prefix_index < Py_ARRAY_LENGTH(_PyUnicode_DecompPrefix));
|
||||
|
||||
/* copy prefix */
|
||||
|
@ -424,8 +425,8 @@ unicodedata_UCD_decomposition_impl(PyObject *self, int chr)
|
|||
decomp[i++] = ' ';
|
||||
assert(i < sizeof(decomp));
|
||||
PyOS_snprintf(decomp + i, sizeof(decomp) - i, "%04X",
|
||||
_PyUnicode_Bextr(_PyUnicode_Decomp, ++index,
|
||||
_PyUnicode_DecompBits));
|
||||
bextra(_PyUnicode_Decomp, ++index,
|
||||
_PyUnicode_DecompBits));
|
||||
i += strlen(decomp + i);
|
||||
}
|
||||
return PyUnicode_FromStringAndSize(decomp, i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue