Skip to content

Commit cad3d55

Browse files
committed
Small loader performance improvements
1 parent e01a72b commit cad3d55

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ElunaLoader.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ void ElunaLoader::LoadScripts()
166166

167167
int ElunaLoader::LoadBytecodeChunk(lua_State* /*L*/, uint8* bytes, size_t len, BytecodeBuffer* buffer)
168168
{
169-
for (size_t i = 0; i < len; i++)
170-
buffer->push_back(bytes[i]);
171-
169+
buffer->reserve(buffer->size() + len);
170+
buffer->insert(buffer->end(), bytes, bytes + len);
172171
return 0;
173172
}
174173

@@ -338,8 +337,10 @@ void ElunaLoader::CombineLists()
338337
m_scripts.sort(ScriptPathComparator);
339338

340339
m_scriptCache.clear();
341-
m_scriptCache.insert(m_scriptCache.end(), m_extensions.begin(), m_extensions.end());
342-
m_scriptCache.insert(m_scriptCache.end(), m_scripts.begin(), m_scripts.end());
340+
m_scriptCache.reserve(m_extensions.size() + m_scripts.size());
341+
342+
std::move(m_extensions.begin(), m_extensions.end(), std::back_inserter(m_scriptCache));
343+
std::move(m_scripts.begin(), m_scripts.end(), std::back_inserter(m_scriptCache));
343344

344345
m_extensions.clear();
345346
m_scripts.clear();

0 commit comments

Comments
 (0)