Skip to content

Commit cecd269

Browse files
committed
Don't use a separate string object to store the query string
Just start reversing after the initial size offset
1 parent 4ac7d25 commit cecd269

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎src/Multirole/YGOPro/CardDatabase.cpp‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class OpsToSqlQueryEmitter
9292
{
9393
public:
9494
OpsToSqlQueryEmitter(uint64_t const* ops, std::string& stmt) noexcept :
95-
ops(ops), ogStmt(stmt) {}
95+
ops(ops), offset(stmt.size()), stmt(stmt) {}
9696

9797
int Parse(int opsSize) noexcept
9898
{
@@ -103,16 +103,14 @@ class OpsToSqlQueryEmitter
103103
Emit("((datas.type&0x4000)==0)AND");
104104
if(!allowAliases)
105105
Emit("(datas.alias!=0)AND");
106-
Emit(ogStmt);
107-
std::reverse(stmt.begin(), stmt.end());
108-
ogStmt.swap(stmt);
106+
std::reverse(std::next(stmt.begin(), offset), stmt.end());
109107
return r;
110108
}
111109

112110
private:
113111
uint64_t const* ops;
114-
std::string& ogStmt;
115-
std::string stmt;
112+
size_t offset;
113+
std::string& stmt;
116114
bool allowAliases = false;
117115
bool allowTokens = false;
118116

0 commit comments

Comments
 (0)