Sema: Micro-optimize PotentialBindings

PotentialBindings is part of ConstraintGraphNode and there's no need
to store the ConstraintSystem and TypeVariableType twice.

Also it doesn't need to be optional either, because we no longer need
to reset and recompute bindings.
This commit is contained in:
Slava Pestov
2024-11-19 22:42:09 -05:00
parent 1bdf7f0192
commit 60d34a4162
5 changed files with 63 additions and 45 deletions

View File

@@ -84,7 +84,10 @@ public:
/// as this type variable.
ArrayRef<TypeVariableType *> getEquivalenceClass() const;
inference::PotentialBindings &getCurrentBindings();
inference::PotentialBindings &getCurrentBindings() {
assert(forRepresentativeVar());
return Bindings;
}
private:
/// Determines whether the type variable associated with this node
@@ -180,7 +183,7 @@ private:
TypeVariableType *TypeVar;
/// The set of bindings associated with this type variable.
std::optional<inference::PotentialBindings> Bindings;
inference::PotentialBindings Bindings;
/// The vector of constraints that mention this type variable, in a stable
/// order for iteration.