mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 04:16:10 +08:00
Reuse std::locale() across calls within single ifind()
Instantiate the std:locale instance used within the character comparison callback outside the lambda and take a reference to it instead of creating the locale object for each character in the sequence. This is part of a very tight loop with lots of inputs during the evaluation of fuzzy string matches for completions/autosuggestions and is worth optimizing.
This commit is contained in:
parent
0d8334a31b
commit
17049ce919
@ -364,8 +364,8 @@ bool string_prefixes_string_case_insensitive(const wcstring &proposed_prefix,
|
||||
template <typename T>
|
||||
size_t ifind(const T &haystack, const T &needle) {
|
||||
using char_t = typename T::value_type;
|
||||
auto icase_eq = [](char_t c1, char_t c2) {
|
||||
auto locale = std::locale();
|
||||
auto locale = std::locale();
|
||||
auto icase_eq = [&locale](char_t c1, char_t c2) {
|
||||
return std::toupper(c1, locale) == std::toupper(c2, locale);
|
||||
};
|
||||
auto result =
|
||||
|
Loading…
x
Reference in New Issue
Block a user