mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
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:
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user