Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Turns maps (RB trees in C++) into unordered_maps (hash tables)
Browse files Browse the repository at this point in the history
Signed-off-by: ncordon <[email protected]>
  • Loading branch information
ncordon authored and dennwc committed Jul 29, 2019
1 parent 045697a commit e846a45
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/libuast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// C++ helpers to make it easier to implement NodeIface and work with Uast context.

#include "libuast.h"
#include <map>
#include <unordered_map>
#include <iostream>
#include <cstring>

Expand Down Expand Up @@ -271,12 +271,12 @@ namespace uast {
return n;
}

static std::map<UastHandle,RawContext*>& contexts() {
static std::map<UastHandle,RawContext*> v; return v;
static std::unordered_map<UastHandle,RawContext*>& contexts() {
static std::unordered_map<UastHandle,RawContext*> v; return v;
}

static std::map<UastHandle,RawContext*>& nativeContexts() {
static std::map<UastHandle,RawContext*> v; return v;
static std::unordered_map<UastHandle,RawContext*>& nativeContexts() {
static std::unordered_map<UastHandle,RawContext*> v; return v;
}

static RawContext* getContext(const Uast* ctx) {
Expand Down Expand Up @@ -306,14 +306,15 @@ namespace uast {
~RawContext() {
UastHandle nativeHandle = ctx->ctx;
UastFree(ctx);

ctx = nullptr;
if (handle == 0) {
nativeContexts().erase(nativeHandle);
} else {
contexts().erase(handle);
}

handle = 0;
delete(impl);
impl = nullptr;
}

Uast* rawPointer() { return ctx; }
Expand Down

0 comments on commit e846a45

Please sign in to comment.