From 60d003df880ffe00c73b68fbbf9649480f39c8d4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Jun 2020 07:29:16 -0400 Subject: [PATCH] CSkeleton: Make BoneByName() use a string view Same behavior, but without a mandatory allocating API. --- src/Core/Resource/Animation/CSkeleton.cpp | 2 +- src/Core/Resource/Animation/CSkeleton.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Core/Resource/Animation/CSkeleton.cpp b/src/Core/Resource/Animation/CSkeleton.cpp index f5c0b14d..30733e3c 100644 --- a/src/Core/Resource/Animation/CSkeleton.cpp +++ b/src/Core/Resource/Animation/CSkeleton.cpp @@ -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; }); diff --git a/src/Core/Resource/Animation/CSkeleton.h b/src/Core/Resource/Animation/CSkeleton.h index 43635f23..f98ab5cc 100644 --- a/src/Core/Resource/Animation/CSkeleton.h +++ b/src/Core/Resource/Animation/CSkeleton.h @@ -9,6 +9,7 @@ #include #include #include +#include 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);