forked from Mirrorlandia_minetest/minetest
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:
parent
b214cde5b4
commit
365e4ae0fa
@ -778,7 +778,7 @@ void Client::deletingPeer(con::Peer *peer, bool timeout)
|
|||||||
string name
|
string name
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void Client::request_media(const std::list<std::string> &file_requests)
|
void Client::request_media(const std::vector<std::string> &file_requests)
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios_base::binary);
|
std::ostringstream os(std::ios_base::binary);
|
||||||
writeU16(os, TOSERVER_REQUEST_MEDIA);
|
writeU16(os, TOSERVER_REQUEST_MEDIA);
|
||||||
@ -790,7 +790,7 @@ void Client::request_media(const std::list<std::string> &file_requests)
|
|||||||
|
|
||||||
*pkt << (u16) (file_requests_size & 0xFFFF);
|
*pkt << (u16) (file_requests_size & 0xFFFF);
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator i = file_requests.begin();
|
for(std::vector<std::string>::const_iterator i = file_requests.begin();
|
||||||
i != file_requests.end(); ++i) {
|
i != file_requests.end(); ++i) {
|
||||||
*pkt << (*i);
|
*pkt << (*i);
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@ public:
|
|||||||
// Insert a media file appropriately into the appropriate manager
|
// Insert a media file appropriately into the appropriate manager
|
||||||
bool loadMedia(const std::string &data, const std::string &filename);
|
bool loadMedia(const std::string &data, const std::string &filename);
|
||||||
// Send a request for conventional media transfer
|
// Send a request for conventional media transfer
|
||||||
void request_media(const std::list<std::string> &file_requests);
|
void request_media(const std::vector<std::string> &file_requests);
|
||||||
// Send a notification that no conventional media transfer is needed
|
// Send a notification that no conventional media transfer is needed
|
||||||
void received_media();
|
void received_media();
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ void ClientMediaDownloader::startConventionalTransfers(Client *client)
|
|||||||
if (m_uncached_received_count != m_uncached_count) {
|
if (m_uncached_received_count != m_uncached_count) {
|
||||||
// Some media files have not been received yet, use the
|
// Some media files have not been received yet, use the
|
||||||
// conventional slow method (minetest protocol) to get them
|
// conventional slow method (minetest protocol) to get them
|
||||||
std::list<std::string> file_requests;
|
std::vector<std::string> file_requests;
|
||||||
for (std::map<std::string, FileStatus*>::iterator
|
for (std::map<std::string, FileStatus*>::iterator
|
||||||
it = m_files.begin();
|
it = m_files.begin();
|
||||||
it != m_files.end(); ++it) {
|
it != m_files.end(); ++it) {
|
||||||
|
@ -2025,9 +2025,8 @@ ClientEnvironment::~ClientEnvironment()
|
|||||||
delete i->second;
|
delete i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<ClientSimpleObject*>::iterator
|
for(std::vector<ClientSimpleObject*>::iterator
|
||||||
i = m_simple_objects.begin(); i != m_simple_objects.end(); ++i)
|
i = m_simple_objects.begin(); i != m_simple_objects.end(); ++i) {
|
||||||
{
|
|
||||||
delete *i;
|
delete *i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2382,11 +2381,10 @@ void ClientEnvironment::step(float dtime)
|
|||||||
Step and handle simple objects
|
Step and handle simple objects
|
||||||
*/
|
*/
|
||||||
g_profiler->avg("CEnv: num of simple objects", m_simple_objects.size());
|
g_profiler->avg("CEnv: num of simple objects", m_simple_objects.size());
|
||||||
for(std::list<ClientSimpleObject*>::iterator
|
for(std::vector<ClientSimpleObject*>::iterator
|
||||||
i = m_simple_objects.begin(); i != m_simple_objects.end();)
|
i = m_simple_objects.begin(); i != m_simple_objects.end();) {
|
||||||
{
|
|
||||||
ClientSimpleObject *simple = *i;
|
ClientSimpleObject *simple = *i;
|
||||||
std::list<ClientSimpleObject*>::iterator cur = i;
|
std::vector<ClientSimpleObject*>::iterator cur = i;
|
||||||
++i;
|
++i;
|
||||||
simple->step(dtime);
|
simple->step(dtime);
|
||||||
if(simple->m_to_be_removed){
|
if(simple->m_to_be_removed){
|
||||||
|
@ -521,7 +521,7 @@ private:
|
|||||||
IGameDef *m_gamedef;
|
IGameDef *m_gamedef;
|
||||||
IrrlichtDevice *m_irr;
|
IrrlichtDevice *m_irr;
|
||||||
std::map<u16, ClientActiveObject*> m_active_objects;
|
std::map<u16, ClientActiveObject*> m_active_objects;
|
||||||
std::list<ClientSimpleObject*> m_simple_objects;
|
std::vector<ClientSimpleObject*> m_simple_objects;
|
||||||
std::list<ClientEnvEvent> m_client_event_queue;
|
std::list<ClientEnvEvent> m_client_event_queue;
|
||||||
IntervalLimiter m_active_object_light_update_interval;
|
IntervalLimiter m_active_object_light_update_interval;
|
||||||
IntervalLimiter m_lava_hurt_interval;
|
IntervalLimiter m_lava_hurt_interval;
|
||||||
|
@ -367,13 +367,14 @@ int ModApiServer::l_get_modnames(lua_State *L)
|
|||||||
NO_MAP_LOCK_REQUIRED;
|
NO_MAP_LOCK_REQUIRED;
|
||||||
|
|
||||||
// Get a list of mods
|
// 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);
|
getServer(L)->getModNames(mods_unsorted);
|
||||||
|
|
||||||
// Take unsorted items from mods_unsorted and sort them into
|
// Take unsorted items from mods_unsorted and sort them into
|
||||||
// mods_sorted; not great performance but the number of mods on a
|
// mods_sorted; not great performance but the number of mods on a
|
||||||
// server will likely be small.
|
// 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) {
|
i != mods_unsorted.end(); ++i) {
|
||||||
bool added = false;
|
bool added = false;
|
||||||
for(std::list<std::string>::iterator x = mods_sorted.begin();
|
for(std::list<std::string>::iterator x = mods_sorted.begin();
|
||||||
|
@ -3188,10 +3188,9 @@ const ModSpec* Server::getModSpec(const std::string &modname)
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
void Server::getModNames(std::list<std::string> &modlist)
|
void Server::getModNames(std::vector<std::string> &modlist)
|
||||||
{
|
|
||||||
for(std::vector<ModSpec>::iterator i = m_mods.begin(); i != m_mods.end(); i++)
|
|
||||||
{
|
{
|
||||||
|
for(std::vector<ModSpec>::iterator i = m_mods.begin(); i != m_mods.end(); i++) {
|
||||||
modlist.push_back(i->name);
|
modlist.push_back(i->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ public:
|
|||||||
IWritableCraftDefManager* getWritableCraftDefManager();
|
IWritableCraftDefManager* getWritableCraftDefManager();
|
||||||
|
|
||||||
const ModSpec* getModSpec(const std::string &modname);
|
const ModSpec* getModSpec(const std::string &modname);
|
||||||
void getModNames(std::list<std::string> &modlist);
|
void getModNames(std::vector<std::string> &modlist);
|
||||||
std::string getBuiltinLuaPath();
|
std::string getBuiltinLuaPath();
|
||||||
inline std::string getWorldPath()
|
inline std::string getWorldPath()
|
||||||
{ return m_path_world; }
|
{ return m_path_world; }
|
||||||
@ -588,9 +588,6 @@ private:
|
|||||||
Random stuff
|
Random stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Mod parent directory paths
|
|
||||||
std::list<std::string> m_modspaths;
|
|
||||||
|
|
||||||
bool m_shutdown_requested;
|
bool m_shutdown_requested;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user