diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-03-31 13:34:36 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-03-31 13:34:36 +0200 |
commit | 0a9dd0c7d31cbba2170fdfda4b747a1fe5ce665a (patch) | |
tree | 08aaf5b0c9fa06ca2352f1775f2c470841653a93 /libbuild2/target-type.hxx | |
parent | eed93abebc20e59f861c7e8b6322f7ef3681c59e (diff) |
Use own type information instead of dynamic_cast in target::is_a()
Diffstat (limited to 'libbuild2/target-type.hxx')
-rw-r--r-- | libbuild2/target-type.hxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libbuild2/target-type.hxx b/libbuild2/target-type.hxx index 0e24e3a..ef3a3ed 100644 --- a/libbuild2/target-type.hxx +++ b/libbuild2/target-type.hxx @@ -102,14 +102,15 @@ namespace build2 bool is_a (const target_type& tt) const { - return this == &tt || (base != nullptr && is_a_base (tt)); + for (const target_type* b (this); b != nullptr; b = b->base) + if (b == &tt) + return true; + + return false; } bool is_a (const char*) const; // Defined in target.cxx - - bool - is_a_base (const target_type&) const; // Defined in target.cxx }; inline bool |