Remove some unnecessary string copy related to substr.

Patch By: phosit
Differential Revision: https://code.wildfiregames.com/D4772
This was SVN commit r27271.
This commit is contained in:
vladislavbelov
2022-12-04 19:56:12 +00:00
parent b2f529c655
commit 2ef801f5d0
13 changed files with 73 additions and 40 deletions
+3 -1
View File
@@ -28,6 +28,7 @@
#include "scriptinterface/ScriptInterface.h"
#include <libxml/parser.h>
#include <string_view>
#include <unordered_map>
const char* XMBStorage::HeaderMagicStr = "XMB0";
@@ -235,7 +236,8 @@ bool JSNodeData::Setup(XMBStorageWriter& xmb, JS::HandleValue value)
std::string_view name = prop;
if (!attrib && !prop.empty() && prop.back() == '@')
{
size_t idx = prop.substr(0, prop.size()-1).find_last_of('@');
const size_t idx = std::string_view{prop}.substr(0, prop.size() - 1)
.find_last_of('@');
if (idx == std::string::npos)
{
LOGERROR("Object key name cannot end with an '@' unless it is an index specifier.");