use unordered_map

master
Daniel Kolesa 2017-01-31 19:28:34 +01:00
parent 58bf658409
commit d88e9de11a
4 changed files with 15 additions and 18 deletions

View File

@ -9,11 +9,11 @@
#include "cubescript_conf.hh"
#include <ostd/platform.hh>
#include <ostd/memory.hh>
#include <ostd/types.hh>
#include <ostd/type_traits.hh>
#include <ostd/string.hh>
#include <ostd/vector.hh>
#include <ostd/map.hh>
#include <ostd/range.hh>
#include <ostd/utility.hh>
#include <ostd/io.hh>

View File

@ -2,12 +2,8 @@
#define LIBCUBESCRIPT_CUBESCRIPT_CONF_HH
#include <limits.h>
#include <ostd/types.hh>
#include <ostd/memory.hh>
#include <ostd/string.hh>
#include <ostd/vector.hh>
#include <ostd/map.hh>
#include <ostd/stream.hh>
#include <functional>
#include <ostd/range.hh>
/* do not modify */
namespace cscript {

View File

@ -4,11 +4,12 @@
#include <ostd/string.hh>
#include <ostd/utility.hh>
#include <ostd/type_traits.hh>
#include <ostd/unordered_map.hh>
namespace cscript {
template<typename K, typename V>
using CsMap = ostd::Map<K, V>;
using CsMap = std::unordered_map<K, V>;
template<typename T>
using CsVector = std::vector<T>;

View File

@ -398,7 +398,7 @@ CsState::~CsState() {
if (!p_state) {
return;
}
for (auto &p: p_state->idents.iter()) {
for (auto &p: p_state->idents) {
CsIdent *i = p.second;
CsAlias *a = i->get_alias();
if (a) {
@ -464,7 +464,7 @@ void CsState::clear_override(CsIdent &id) {
}
void CsState::clear_overrides() {
for (auto &p: p_state->idents.iter()) {
for (auto &p: p_state->idents) {
clear_override(*(p.second));
}
}
@ -511,23 +511,23 @@ CsIdent *CsState::force_ident(CsValue &v) {
}
CsIdent *CsState::get_ident(ostd::ConstCharRange name) {
CsIdent **id = p_state->idents.at(name);
if (!id) {
return nullptr;
auto id = p_state->idents.find(name);
if (id != p_state->idents.end()) {
return id->second;
}
return *id;
return nullptr;
}
CsAlias *CsState::get_alias(ostd::ConstCharRange name) {
CsIdent **id = p_state->idents.at(name);
if (!id || !(*id)->is_alias()) {
auto id = get_ident(name);
if (!id || !id->is_alias()) {
return nullptr;
}
return static_cast<CsAlias *>(*id);
return static_cast<CsAlias *>(id);
}
bool CsState::have_ident(ostd::ConstCharRange name) {
return p_state->idents.at(name) != nullptr;
return p_state->idents.find(name) != p_state->idents.end();
}
CsIdentRange CsState::get_idents() {