No need for .c_str() with keywordDict lookups (#1505)

This commit is contained in:
Sylvie
2024-09-18 06:23:05 -04:00
committed by GitHub
parent 9b3d19c3f2
commit 197f6cb0ba

View File

@@ -1170,7 +1170,7 @@ static Token readIdentifier(char firstChar, bool raw) {
// Attempt to check for a keyword if the identifier is not raw // Attempt to check for a keyword if the identifier is not raw
if (!raw) { if (!raw) {
if (auto search = keywordDict.find(identifier.c_str()); search != keywordDict.end()) if (auto search = keywordDict.find(identifier); search != keywordDict.end())
return Token(search->second); return Token(search->second);
} }
@@ -1231,7 +1231,7 @@ static std::shared_ptr<std::string> readInterpolation(size_t depth) {
if (fmtBuf.starts_with('#')) { if (fmtBuf.starts_with('#')) {
// Skip a '#' raw identifier prefix, but after expanding any nested interpolations. // Skip a '#' raw identifier prefix, but after expanding any nested interpolations.
fmtBuf.erase(0, 1); fmtBuf.erase(0, 1);
} else if (keywordDict.find(fmtBuf.c_str()) != keywordDict.end()) { } else if (keywordDict.find(fmtBuf) != keywordDict.end()) {
// Don't allow symbols that alias keywords without a '#' prefix. // Don't allow symbols that alias keywords without a '#' prefix.
error( error(
"Interpolated symbol \"%s\" is a reserved keyword; add a '#' prefix to use it as a raw " "Interpolated symbol \"%s\" is a reserved keyword; add a '#' prefix to use it as a raw "