Skip to content

Commit b8fe3b6

Browse files
committed
post-merge
1 parent dd36c99 commit b8fe3b6

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

Python/codecs.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,18 +730,34 @@ codec_handler_write_unicode_hex(Py_UCS1 **p, Py_UCS4 ch)
730730
}
731731

732732

733-
/* Determine the number of digits for a decimal representation of codepoint ch
733+
/*
734+
* Determine the number of digits for a decimal representation of Unicode
735+
* codepoint 'ch' (by design, Unicode codepoints are limited to 7 digits).
734736
*/
735737
static inline int
736738
n_decimal_digits_for_codepoint(Py_UCS4 ch)
737739
{
738-
if (ch < 10) return 1;
739-
if (ch < 100) return 2;
740-
if (ch < 1000) return 3;
741-
if (ch < 10000) return 4;
742-
if (ch < 100000) return 5;
743-
if (ch < 1000000) return 6;
744-
if (ch < 10000000) return 7;
740+
if (ch < 10) {
741+
return 1;
742+
}
743+
if (ch < 100) {
744+
return 2;
745+
}
746+
if (ch < 1000) {
747+
return 3;
748+
}
749+
if (ch < 10000) {
750+
return 4;
751+
}
752+
if (ch < 100000) {
753+
return 5;
754+
}
755+
if (ch < 1000000) {
756+
return 6;
757+
}
758+
if (ch < 10000000) {
759+
return 7;
760+
}
745761
// Unicode codepoints are limited to 1114111 (7 decimal digits)
746762
Py_UNREACHABLE();
747763
}

0 commit comments

Comments
 (0)