File tree Expand file tree Collapse file tree 1 file changed +16
-22
lines changed
Expand file tree Collapse file tree 1 file changed +16
-22
lines changed Original file line number Diff line number Diff line change @@ -96,27 +96,6 @@ _getrecord_ex(Py_UCS4 code)
9696 return & _PyUnicode_Database_Records [index ];
9797}
9898
99- static const char *
100- _getrecord_block (Py_UCS4 code )
101- {
102- int l = 0 , h = BLOCK_COUNT - 1 ;
103- while (l <= h ) {
104- int m = (l + h ) / 2 ;
105- if (code < _PyUnicode_Blocks [m ].s ) {
106- h = m - 1 ;
107- }
108- else if (code > _PyUnicode_Blocks [m ].e ) {
109- l = m + 1 ;
110- }
111- else {
112- return _PyUnicode_BlockNames [_PyUnicode_Blocks [m ].name ];
113- }
114- }
115- // Otherwise, return the deefault value per
116- // https://www.unicode.org/versions/latest/core-spec/chapter-3/#G64189
117- return "No_Block" ;
118- }
119-
12099typedef struct {
121100 PyObject * SegmentType ;
122101 PyObject * GraphemeBreakIteratorType ;
@@ -2101,7 +2080,22 @@ unicodedata_block_impl(PyObject *module, int chr)
21012080/*[clinic end generated code: output=5f8b40c49eaec75a input=0834cf2642d6eaae]*/
21022081{
21032082 Py_UCS4 c = (Py_UCS4 )chr ;
2104- return PyUnicode_FromString (_getrecord_block (c ));
2083+ int l = 0 , h = BLOCK_COUNT - 1 ;
2084+ while (l <= h ) {
2085+ int m = (l + h ) / 2 ;
2086+ if (c < _PyUnicode_Blocks [m ].s ) {
2087+ h = m - 1 ;
2088+ }
2089+ else if (c > _PyUnicode_Blocks [m ].e ) {
2090+ l = m + 1 ;
2091+ }
2092+ else {
2093+ return PyUnicode_FromString (_PyUnicode_BlockNames [_PyUnicode_Blocks [m ].name ]);
2094+ }
2095+ }
2096+ // Otherwise, return the deefault value per
2097+ // https://www.unicode.org/versions/latest/core-spec/chapter-3/#G64189
2098+ return PyUnicode_FromString ("No_Block" );
21052099}
21062100
21072101/*[clinic input]
You can’t perform that action at this time.
0 commit comments