From: Evan Martin Date: Fri, 17 Dec 2010 23:00:47 +0000 (-0800) Subject: use hash_map for paths; much faster builds X-Git-Tag: release-120715~570 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0f931f18d4ce98ebbc712d0caa8368b68137028;p=platform%2Fupstream%2Fninja.git use hash_map for paths; much faster builds --- diff --git a/src/eval_env.h b/src/eval_env.h index a630e7a..cc61a38 100644 --- a/src/eval_env.h +++ b/src/eval_env.h @@ -1,6 +1,9 @@ #ifndef NINJA_EVAL_ENV_H_ #define NINJA_EVAL_ENV_H_ +#include +using namespace std; + // A scope for variable lookups. struct Env { virtual string LookupVariable(const string& var) = 0; diff --git a/src/hash_map.h b/src/hash_map.h new file mode 100644 index 0000000..820f773 --- /dev/null +++ b/src/hash_map.h @@ -0,0 +1,12 @@ +#include + +using __gnu_cxx::hash_map; + +namespace __gnu_cxx { +template<> +struct hash { + size_t operator()(const std::string& s) const { + return hash()(s.c_str()); + } +}; +} diff --git a/src/ninja.h b/src/ninja.h index ecfb2d0..fb0b7fb 100644 --- a/src/ninja.h +++ b/src/ninja.h @@ -2,7 +2,6 @@ #define NINJA_NINJA_H_ #include -#include #include #include #include @@ -13,6 +12,7 @@ using namespace std; #include "eval_env.h" +#include "hash_map.h" int ReadFile(const string& path, string* contents, string* err); @@ -135,7 +135,7 @@ struct Edge { }; struct StatCache { - typedef map Paths; + typedef hash_map Paths; Paths paths_; FileStat* GetFile(const string& path); void Dump();