Codechange: Construct string_view with first+last. (#12568)

Avoids needing to calculate size when we already have last.
This commit is contained in:
Peter Nelson 2024-04-24 21:29:33 +01:00 committed by GitHub
parent 6a3f50aa72
commit 1dc94d0670
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -99,7 +99,7 @@ static uint16_t ParseCode(const char *start, const char *end)
assert(start <= end);
while (start < end && *start == ' ') start++;
while (end > start && *end == ' ') end--;
std::string_view str{start, static_cast<size_t>(end - start)};
std::string_view str{start, end};
for (const auto &kn : _keycode_to_name) {
if (StrEqualsIgnoreCase(str, kn.name)) {
return kn.keycode;

View File

@ -68,7 +68,7 @@ public:
SlObject(lc, this->GetLoadDescription());
if (IsSavegameVersionBefore(SLV_STRING_GAMELOG)) {
static_cast<LoggedChangeRevision *>(lc)->text = StrMakeValid(std::string_view(SlGamelogRevision::revision_text, lengthof(SlGamelogRevision::revision_text)));
static_cast<LoggedChangeRevision *>(lc)->text = StrMakeValid(std::string_view(std::begin(SlGamelogRevision::revision_text), std::end(SlGamelogRevision::revision_text)));
}
}