summaryrefslogtreecommitdiff
path: root/src/ir/possible-contents.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-10-28 12:15:53 -0700
committerGitHub <noreply@github.com>2022-10-28 19:15:53 +0000
commit8ab8e40d15a4d9f28ced76d28232f9e791f161d3 (patch)
tree993722fe48256cca1d57bf553fb15e6be62333a0 /src/ir/possible-contents.h
parent7e7dd338b9ae6026f54f3384bebe095fefb9fab5 (diff)
downloadbinaryen-8ab8e40d15a4d9f28ced76d28232f9e791f161d3.tar.gz
binaryen-8ab8e40d15a4d9f28ced76d28232f9e791f161d3.tar.bz2
binaryen-8ab8e40d15a4d9f28ced76d28232f9e791f161d3.zip
[NFC] Rewrite PossibleContents::combine to be static (#5192)
This makes the logic symmetric and easier to read. Measuring speed, this seems identical to before, so that concern seems fine.
Diffstat (limited to 'src/ir/possible-contents.h')
-rw-r--r--src/ir/possible-contents.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ir/possible-contents.h b/src/ir/possible-contents.h
index cf92a578a..b7c9bfafd 100644
--- a/src/ir/possible-contents.h
+++ b/src/ir/possible-contents.h
@@ -103,12 +103,12 @@ class PossibleContents {
// full cone of all subtypes for that type.
static ConeType FullConeType(Type type) { return ConeType{type, FullDepth}; }
+ template<typename T> PossibleContents(T value) : value(value) {}
+
public:
PossibleContents() : value(None()) {}
PossibleContents(const PossibleContents& other) = default;
- template<typename T> explicit PossibleContents(T val) : value(val) {}
-
// Most users will use one of the following static functions to construct a
// new instance:
@@ -163,7 +163,12 @@ public:
// Combine the information in a given PossibleContents to this one. The
// contents here will then include whatever content was possible in |other|.
- void combine(const PossibleContents& other);
+ [[nodiscard]] static PossibleContents combine(const PossibleContents& a,
+ const PossibleContents& b);
+
+ void combine(const PossibleContents& other) {
+ *this = PossibleContents::combine(*this, other);
+ }
// Removes anything not in |other| from this object, so that it ends up with
// only their intersection. Currently this only handles an intersection with a