mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
refactor: avoid copying before vim_strup() if possible (#27830)
Current uses of vim_strup() calls memcpy()/strcpy() before calling vim_strup(). This results in 2 * strlen(string) operations. We can trivially convert to lowercase while copying the string instead.
This commit is contained in:
@@ -1149,9 +1149,8 @@ void do_highlight(const char *line, const bool forceit, const bool init)
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
memcpy(key, key_start, key_len);
|
||||
key[key_len] = NUL;
|
||||
vim_strup(key);
|
||||
vim_memcpy_up(key, key_start, key_len);
|
||||
key[key_len] = '\0';
|
||||
linep = skipwhite(linep);
|
||||
|
||||
if (strcmp(key, "NONE") == 0) {
|
||||
@@ -1943,9 +1942,8 @@ int syn_name2id_len(const char *name, size_t len)
|
||||
|
||||
// Avoid using stricmp() too much, it's slow on some systems */
|
||||
// Avoid alloc()/free(), these are slow too.
|
||||
memcpy(name_u, name, len);
|
||||
vim_memcpy_up(name_u, name, len);
|
||||
name_u[len] = '\0';
|
||||
vim_strup(name_u);
|
||||
|
||||
// map_get(..., int) returns 0 when no key is present, which is
|
||||
// the expected value for missing highlight group.
|
||||
|
Reference in New Issue
Block a user