use hash_map for paths; much faster builds
authorEvan Martin <martine@danga.com>
Fri, 17 Dec 2010 23:00:47 +0000 (15:00 -0800)
committerEvan Martin <martine@danga.com>
Fri, 17 Dec 2010 23:00:47 +0000 (15:00 -0800)
src/eval_env.h
src/hash_map.h [new file with mode: 0644]
src/ninja.h

index a630e7a..cc61a38 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef NINJA_EVAL_ENV_H_
 #define NINJA_EVAL_ENV_H_
 
+#include <map>
+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 (file)
index 0000000..820f773
--- /dev/null
@@ -0,0 +1,12 @@
+#include <ext/hash_map>
+
+using __gnu_cxx::hash_map;
+
+namespace __gnu_cxx {
+template<>
+struct hash<std::string> {
+  size_t operator()(const std::string& s) const {
+    return hash<const char*>()(s.c_str());
+  }
+};
+}
index ecfb2d0..fb0b7fb 100644 (file)
@@ -2,7 +2,6 @@
 #define NINJA_NINJA_H_
 
 #include <algorithm>
-#include <map>
 #include <queue>
 #include <set>
 #include <string>
@@ -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<string, FileStat*> Paths;
+  typedef hash_map<string, FileStat*> Paths;
   Paths paths_;
   FileStat* GetFile(const string& path);
   void Dump();