CSkeleton: Make BoneByName() use a string view

Same behavior, but without a mandatory allocating API.
This commit is contained in:
Lioncash 2020-06-18 07:29:16 -04:00
parent 671b8037b9
commit 60d003df88
2 changed files with 3 additions and 2 deletions

View File

@ -81,7 +81,7 @@ CBone* CSkeleton::BoneByID(uint32 BoneID) const
return iter->get();
}
CBone* CSkeleton::BoneByName(const TString& name) const
CBone* CSkeleton::BoneByName(std::string_view name) const
{
const auto iter = std::find_if(mBones.begin(), mBones.end(),
[&name](const auto& bone) { return bone->Name() == name; });

View File

@ -9,6 +9,7 @@
#include <Common/Math/CRay.h>
#include <Common/Math/CVector3f.h>
#include <memory>
#include <string_view>
class CBoneTransformData;
class CBone;
@ -37,7 +38,7 @@ public:
~CSkeleton() override;
void UpdateTransform(CBoneTransformData& rData, CAnimation *pAnim, float Time, bool AnchorRoot);
CBone* BoneByID(uint32 BoneID) const;
CBone* BoneByName(const TString& name) const;
CBone* BoneByName(std::string_view name) const;
uint32 MaxBoneID() const;
void Draw(FRenderOptions Options, const CBoneTransformData *pkData);