Use const_strlen in a few different places

This may slightly improve performance by allowing the compiler greater
visibility into what is happing on top of not executing at runtime in
some hot paths, but more importantly, it gets rid of magic constants in a
few different places.
This commit is contained in:
Mahmoud Al-Qudsi
2021-02-08 15:09:10 -06:00
parent 5d4c24bae1
commit cb3ab80cab
9 changed files with 32 additions and 31 deletions

View File

@@ -63,7 +63,8 @@ static bool should_exit(wchar_t wc) {
std::fwprintf(stderr, L"Press [ctrl-%c] again to exit\n", shell_modes.c_cc[VEOF] + 0x40);
return false;
}
return std::memcmp(recent_chars, "exit", 4) == 0 || std::memcmp(recent_chars, "quit", 4) == 0;
return std::memcmp(recent_chars, "exit", const_strlen("exit")) == 0 ||
std::memcmp(recent_chars, "quit", const_strlen("quit")) == 0;
}
/// Return the name if the recent sequence of characters matches a known terminfo sequence.