Use our own function to parse int

This commit is contained in:
topjohnwu
2019-03-07 20:31:35 -05:00
parent bbe4b69c8d
commit d2cb638fcd
6 changed files with 29 additions and 22 deletions

View File

@@ -230,3 +230,18 @@ char *rtrim(char *str) {
str[len] = '\0';
return str;
}
/*
* Bionic's atoi runs through strtol().
* Use our own implementation for faster conversion.
*/
int parse_int(const char *s) {
int val = 0;
char c;
while ((c = *(s++))) {
if (c > '9' || c < '0')
return -1;
val = val * 10 + c - '0';
}
return val;
}