mirror of https://github.com/AxioDL/metaforce.git
CCharLayoutInfo: Use heterogenous lookup with std::map
Allows using std::string_view with std::map without the need to construct a completely new std::string instance. Making the lookups via GetSegIdFromString() completely non-allocating. Notably, this also allows it to properly function with non-null-terminated string_view instances.
This commit is contained in:
parent
18382e5bb6
commit
e7b0470f55
|
@ -19,9 +19,11 @@ zeus::CVector3f CCharLayoutInfo::GetFromRootUnrotated(const CSegId& id) const {
|
|||
}
|
||||
|
||||
CSegId CCharLayoutInfo::GetSegIdFromString(std::string_view name) const {
|
||||
auto it = x18_segIdMap.find(name.data());
|
||||
if (it == x18_segIdMap.end())
|
||||
const auto it = x18_segIdMap.find(name);
|
||||
|
||||
if (it == x18_segIdMap.cend()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
class CCharLayoutInfo {
|
||||
std::shared_ptr<CCharLayoutNode> x0_node;
|
||||
CSegIdList x8_segIdList;
|
||||
std::map<std::string, CSegId> x18_segIdMap;
|
||||
std::map<std::string, CSegId, std::less<>> x18_segIdMap;
|
||||
|
||||
public:
|
||||
CCharLayoutInfo(CInputStream& in);
|
||||
|
|
Loading…
Reference in New Issue