The copy loop hand-rolls a per-character branch on the 'lower' flag. Split it into a straight memcpy() followed by an optional strlower() so the common path is a single copy and the lowercase case is obvious.
Signed-off-by: Simon Glass <[email protected]> --- boot/pxe_utils.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 419ab1f1b0e..098ee9bbbfe 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -950,7 +950,7 @@ enum lex_state { static char *get_string(char **p, struct token *t, char delim, int lower) { char *b, *e; - size_t len, i; + size_t len; /* * b and e both start at the beginning of the input stream. @@ -976,14 +976,10 @@ static char *get_string(char **p, struct token *t, char delim, int lower) if (!t->val) return NULL; - for (i = 0; i < len; i++, b++) { - if (lower) - t->val[i] = tolower(*b); - else - t->val[i] = *b; - } - + memcpy(t->val, b, len); t->val[len] = '\0'; + if (lower) + strlower(t->val); /* Update *p so the caller knows where to continue scanning */ *p = e; -- 2.43.0

