Skip to content

Commit e80bac4

Browse files
Remove helper
1 parent a4421f5 commit e80bac4

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

Modules/unicodedata.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff 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-
12099
typedef 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]

0 commit comments

Comments
 (0)