mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Construct string_view with first+last. (#12568)
Avoids needing to calculate size when we already have last.
This commit is contained in:
parent
6a3f50aa72
commit
1dc94d0670
|
@ -99,7 +99,7 @@ static uint16_t ParseCode(const char *start, const char *end)
|
||||||
assert(start <= end);
|
assert(start <= end);
|
||||||
while (start < end && *start == ' ') start++;
|
while (start < end && *start == ' ') start++;
|
||||||
while (end > start && *end == ' ') end--;
|
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) {
|
for (const auto &kn : _keycode_to_name) {
|
||||||
if (StrEqualsIgnoreCase(str, kn.name)) {
|
if (StrEqualsIgnoreCase(str, kn.name)) {
|
||||||
return kn.keycode;
|
return kn.keycode;
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
SlObject(lc, this->GetLoadDescription());
|
SlObject(lc, this->GetLoadDescription());
|
||||||
|
|
||||||
if (IsSavegameVersionBefore(SLV_STRING_GAMELOG)) {
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue