aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/module.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-04-18 14:39:13 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-04-19 04:12:34 +0200
commit950a84c337f317388cf39a3820125e049c598b8d (patch)
treea5c095027d5bf81bf8a33b745ad2ea3be2219771 /libbuild2/cc/module.hxx
parent77fc9816696ebed3cc8685a8fdee464799f2a157 (diff)
Optimize header cache some more by storing hash in key
Diffstat (limited to 'libbuild2/cc/module.hxx')
-rw-r--r--libbuild2/cc/module.hxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/libbuild2/cc/module.hxx b/libbuild2/cc/module.hxx
index ee9349a..2a8611b 100644
--- a/libbuild2/cc/module.hxx
+++ b/libbuild2/cc/module.hxx
@@ -86,8 +86,30 @@ namespace build2
// sharing it for the entire weak amalgamation.
//
public:
+ // Keep the hash in the key. This way we can compute it outside of the
+ // lock.
+ //
+ struct header_key
+ {
+ path file;
+ size_t hash;
+
+ friend bool
+ operator== (const header_key& x, const header_key& y)
+ {
+ return x.file == y.file; // Note: hash was already compared.
+ }
+ };
+
+ struct header_key_hasher
+ {
+ size_t operator() (const header_key& k) const {return k.hash;}
+ };
+
mutable shared_mutex header_map_mutex;
- mutable std::unordered_map<path, const file*> header_map;
+ mutable std::unordered_map<header_key,
+ const file*,
+ header_key_hasher> header_map;
private:
// Defined in gcc.cxx.