1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-06 09:07:19 +02:00

Convert functions to unordered_map and use reserve

This commit is contained in:
Filip Gawin 2018-12-09 15:10:06 +01:00
parent 4063fabe52
commit 84c09d93ce
3 changed files with 10 additions and 5 deletions

View File

@ -1,8 +1,8 @@
#ifndef _LIBRW_RW_FORWARD_HPP_
#define _LIBRW_RW_FORWARD_HPP_
#include <memory>
#include <unordered_map>
#include <memory>
#include <vector>
// Forward Declarations

View File

@ -2,13 +2,12 @@
#define _RWENGINE_SCRIPTMODULE_HPP_
#include <cstddef>
#include <map>
#include <string>
#include <unordered_map>
#include <script/ScriptTypes.hpp>
#include "ScriptMachine.hpp"
#include <string>
namespace script_bind {
template <class T>
struct arg_traits {
@ -172,9 +171,13 @@ public:
bool findOpcode(ScriptFunctionID id, ScriptFunctionMeta** out);
void reserveFunctions(size_t nr) {
functions.reserve(nr);
}
private:
const std::string name;
std::map<ScriptFunctionID, ScriptFunctionMeta> functions;
std::unordered_map<ScriptFunctionID, ScriptFunctionMeta> functions;
};
#endif

View File

@ -14,6 +14,8 @@
#include "GTA3ModuleImpl.inl"
GTA3Module::GTA3Module() : ScriptModule("GTA3") {
reserveFunctions(903);
bind(0x0000, 0, opcode_0000);
bind(0x0001, 1, opcode_0001);
bind(0x0002, 1, opcode_0002);