Make pow10_array const

This commit is contained in:
Kovid Goyal 2021-05-07 14:13:49 +05:30
parent 1865570390
commit 053c2ed2b9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -18,7 +18,7 @@
extern PyTypeObject Screen_Type;
// utils {{{
static uint64_t pow10_array[] = {
const static uint64_t pow_10_array[] = {
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000
};
@ -35,9 +35,9 @@ utoi(const uint32_t *buf, unsigned int sz) {
if (*p == '0') { p++; sz--; }
else break;
}
if (sz < sizeof(pow10_array)/sizeof(pow10_array[0])) {
if (sz < sizeof(pow_10_array)/sizeof(pow_10_array[0])) {
for (int i = sz-1, j=0; i >= 0; i--, j++) {
ans += (p[i] - '0') * pow10_array[j];
ans += (p[i] - '0') * pow_10_array[j];
}
}
return ans * mult;