Use constexpr.

This commit is contained in:
Stephen Anthony 2024-12-05 17:57:24 -03:30
parent e2f59ae9a4
commit 8d5eb28053
2 changed files with 3 additions and 3 deletions

View File

@ -252,7 +252,7 @@ namespace BSPF
// Find location (if any) of the second string within the first, // Find location (if any) of the second string within the first,
// starting from 'startpos' in the first string // starting from 'startpos' in the first string
static size_t findIgnoreCase(string_view s1, string_view s2, size_t startpos = 0) static constexpr size_t findIgnoreCase(string_view s1, string_view s2, size_t startpos = 0)
{ {
const auto pos = std::search(s1.cbegin()+startpos, s1.cend(), // NOLINT const auto pos = std::search(s1.cbegin()+startpos, s1.cend(), // NOLINT
s2.cbegin(), s2.cend(), [](char ch1, char ch2) { s2.cbegin(), s2.cend(), [](char ch1, char ch2) {
@ -262,7 +262,7 @@ namespace BSPF
} }
// Test whether the first string contains the second one (case insensitive) // Test whether the first string contains the second one (case insensitive)
inline bool containsIgnoreCase(string_view s1, string_view s2) inline constexpr bool containsIgnoreCase(string_view s1, string_view s2)
{ {
return findIgnoreCase(s1, s2) != string::npos; return findIgnoreCase(s1, s2) != string::npos;
} }

View File

@ -40,7 +40,7 @@ FSNodeWINDOWS::FSNodeWINDOWS(string_view p)
bool FSNodeWINDOWS::setFlags() bool FSNodeWINDOWS::setFlags()
{ {
// Get absolute path // Get absolute path
TCHAR buf[MAX_PATH]; static TCHAR buf[MAX_PATH];
if (GetFullPathName(_path.c_str(), MAX_PATH - 1, buf, NULL)) if (GetFullPathName(_path.c_str(), MAX_PATH - 1, buf, NULL))
_path = buf; _path = buf;