1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Performance improvement: Use std::list instead of std::vector for request_media, Server::getModNames, Environment::m_simple_objects.

* Also remove unused Server::m_modspaths
This commit is contained in:
Loic Blot 2015-03-05 10:43:08 +01:00
parent b214cde5b4
commit 365e4ae0fa
8 changed files with 16 additions and 21 deletions

View file

@ -367,13 +367,14 @@ int ModApiServer::l_get_modnames(lua_State *L)
NO_MAP_LOCK_REQUIRED;
// Get a list of mods
std::list<std::string> mods_unsorted, mods_sorted;
std::vector<std::string> mods_unsorted;
std::list<std::string> mods_sorted;
getServer(L)->getModNames(mods_unsorted);
// Take unsorted items from mods_unsorted and sort them into
// mods_sorted; not great performance but the number of mods on a
// server will likely be small.
for(std::list<std::string>::iterator i = mods_unsorted.begin();
for(std::vector<std::string>::iterator i = mods_unsorted.begin();
i != mods_unsorted.end(); ++i) {
bool added = false;
for(std::list<std::string>::iterator x = mods_sorted.begin();