diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-21 07:19:03 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-21 07:19:03 +0200 |
commit | 1397444e5de3281431d2174564dfd76fe7b7b32f (patch) | |
tree | a58a822b31ae403f83868bdc8157d4caa82c32f8 /build2/target | |
parent | 855ee25d977c3e658162210de3c418922e1fe949 (diff) |
Use hash map/set for targets/prerequisites to resolve key change issue
Diffstat (limited to 'build2/target')
-rw-r--r-- | build2/target | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/build2/target b/build2/target index 9061e2d..ac67ff8 100644 --- a/build2/target +++ b/build2/target @@ -5,9 +5,9 @@ #ifndef BUILD2_TARGET #define BUILD2_TARGET -#include <map> #include <iterator> // tags, etc. #include <type_traits> +#include <unordered_map> #include <butl/multi-index> // map_iterator_adapter @@ -779,13 +779,18 @@ namespace build2 a, reverse_iterate (group_prerequisites (t)), members); } - // + // A target with an unspecified extension is considered equal to the one + // with the specified one. And when we find a target with an unspecified + // extension via a key with the specified one, we update the extension, + // essentially modifying the map's key. To make this work we use a hash + // map. The key's hash ignores the extension, so the hash will stay stable + // across extension updates. // struct target_set { - // @@ When we update ext in key, don't we change it? I think we do. + // @@ Why do we dynalloc target? // - typedef std::map<target_key, unique_ptr<target>> map; + typedef std::unordered_map<target_key, unique_ptr<target>> map; typedef butl::map_iterator_adapter<map::const_iterator> iterator; iterator |