2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 07:07:42 +00:00

CGameOptions: Make use of std::string_view where applicable

Enforces the use of valid strings in the interface. Also reduces c_str()
noise a little bit.
This commit is contained in:
Lioncash
2020-03-14 19:59:58 -04:00
parent df4487bae8
commit 659b8a43d3
5 changed files with 37 additions and 27 deletions

View File

@@ -31,12 +31,12 @@ CGameHintInfo::SHintLocation::SHintLocation(CInputStream& in, s32)
, x8_areaId(in.readUint32Big())
, xc_stringId(in.readUint32Big()) {}
int CGameHintInfo::FindHintIndex(const char* str) {
int CGameHintInfo::FindHintIndex(std::string_view str) {
const std::vector<CGameHint>& gameHints = g_MemoryCardSys->GetHints();
const auto& it = std::find_if(gameHints.begin(), gameHints.end(),
[&str](const CGameHint& gh) -> bool { return gh.GetName() == str; });
const auto it =
std::find_if(gameHints.cbegin(), gameHints.cend(), [&str](const CGameHint& gh) { return gh.GetName() == str; });
return (it != gameHints.end() ? it - gameHints.begin() : -1);
return it != gameHints.cend() ? it - gameHints.cbegin() : -1;
}
CFactoryFnReturn FHintFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer, CObjectReference*) {