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

Replace various std::map with UNORDERED_MAP + various cleanups

This is part 2 for 5f084cd98d

Other improvements:

* Use the defined ItemGroupList when used
* make Client::checkPrivilege const
* inline some trivial functions
* Add ActiveObjectMap typedef
* Add SettingsEntries typedef
This commit is contained in:
Loic Blot 2016-10-05 09:03:55 +02:00 committed by Ner'zhul
parent 5f084cd98d
commit 613797a304
23 changed files with 110 additions and 167 deletions

View file

@ -1063,8 +1063,7 @@ void push_flags_string(lua_State *L, FlagDesc *flagdesc, u32 flags, u32 flagmask
/******************************************************************************/
/******************************************************************************/
void read_groups(lua_State *L, int index,
std::map<std::string, int> &result)
void read_groups(lua_State *L, int index, ItemGroupList &result)
{
if (!lua_istable(L,index))
return;
@ -1083,11 +1082,10 @@ void read_groups(lua_State *L, int index,
}
/******************************************************************************/
void push_groups(lua_State *L, const std::map<std::string, int> &groups)
void push_groups(lua_State *L, const ItemGroupList &groups)
{
lua_newtable(L);
std::map<std::string, int>::const_iterator it;
for (it = groups.begin(); it != groups.end(); ++it) {
for (ItemGroupList::const_iterator it = groups.begin(); it != groups.end(); ++it) {
lua_pushnumber(L, it->second);
lua_setfield(L, -2, it->first.c_str());
}

View file

@ -33,11 +33,11 @@ extern "C" {
}
#include <iostream>
#include <map>
#include <vector>
#include "irrlichttypes_bloated.h"
#include "util/string.h"
#include "itemgroup.h"
namespace Json { class Value; }
@ -106,10 +106,10 @@ void pushnode (lua_State *L, const MapNode &n,
NodeBox read_nodebox (lua_State *L, int index);
void read_groups (lua_State *L, int index,
std::map<std::string, int> &result);
ItemGroupList &result);
void push_groups (lua_State *L,
const std::map<std::string, int> &groups);
const ItemGroupList &groups);
//TODO rename to "read_enum_field"
int getenumfield (lua_State *L, int table,

View file

@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define C_CONVERTER_H_
#include <vector>
#include <map>
#include "util/cpp11_container.h"
#include "irrlichttypes_bloated.h"
#include "common/c_types.h"
@ -60,7 +60,7 @@ bool getintfield(lua_State *L, int table,
bool getintfield(lua_State *L, int table,
const char *fieldname, u32 &result);
void read_groups(lua_State *L, int index,
std::map<std::string, int> &result);
UNORDERED_MAP<std::string, int> &result);
bool getboolfield(lua_State *L, int table,
const char *fieldname, bool &result);
bool getfloatfield(lua_State *L, int table,