mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 03:58:32 +00:00
vim-patch:9.1.1184: Unnecessary use of vim_tolower() in vim_strnicmp_asc() (#32792)
Problem: Unnecessary use of vim_tolower() in vim_strnicmp_asc().
Solution: Use TOLOWER_ASC() instead (zeertzjq).
It was passing *s1 and *s2 to vim_tolower(). When char is signed, which
is the case on most platforms, c < 0x80 is always true, so it already
behaves the same as TOLOWER_ASC().
closes: vim/vim#16826
b7dc5d3b61
Use this function for hashy case-insensitive lookup, as it's ASCII-only.
Note that this function doesn't cast TOLOWER_ASC() argument to uint8_t,
so it'll treat a UTF-8 byte as smaller than NUL. It doesn't matter, as
one of the strings being compared is ASCII-only, and its behavior still
leads to consistent ordering.
This commit is contained in:
@@ -129,14 +129,14 @@ function M.hashy_hash(name, strings, access, lower)
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
]]):format(lower and 'mb_strnicmp' or 'memcmp', access('i')))
|
||||
]]):format(lower and 'vim_strnicmp_asc' or 'memcmp', access('i')))
|
||||
else
|
||||
put(([[
|
||||
if (low < 0 || %s(str, %s, len)) {
|
||||
return -1;
|
||||
}
|
||||
return low;
|
||||
]]):format(lower and 'mb_strnicmp' or 'memcmp', access('low')))
|
||||
]]):format(lower and 'vim_strnicmp_asc' or 'memcmp', access('low')))
|
||||
end
|
||||
put '}\n\n'
|
||||
return neworder, table.concat(stats)
|
||||
|
Reference in New Issue
Block a user