Skip to content

Commit 1c78b04

Browse files
committed
RequirementMachine: Clean up the RequirementMachine::initWith*() methods a bit
1 parent f0899e3 commit 1c78b04

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

lib/AST/RequirementMachine/RequirementMachine.cpp

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ RequirementMachine::RequirementMachine(RewriteContext &ctx)
139139
RequirementMachineStepLimit = langOpts.RequirementMachineStepLimit;
140140
RequirementMachineDepthLimit = langOpts.RequirementMachineDepthLimit;
141141
Stats = ctx.getASTContext().Stats;
142+
143+
if (Stats)
144+
++Stats->getFrontendCounters().NumRequirementMachines;
142145
}
143146

144147
RequirementMachine::~RequirementMachine() {}
@@ -147,19 +150,15 @@ RequirementMachine::~RequirementMachine() {}
147150
///
148151
/// This must only be called exactly once, before any other operations are
149152
/// performed on this requirement machine.
153+
///
154+
/// Used by ASTContext::getOrCreateRequirementMachine().
150155
void RequirementMachine::initWithGenericSignature(CanGenericSignature sig) {
151156
Sig = sig;
152157
Params.append(sig.getGenericParams().begin(),
153158
sig.getGenericParams().end());
154159

155160
PrettyStackTraceGenericSignature debugStack("building rewrite system for", sig);
156161

157-
auto &ctx = Context.getASTContext();
158-
auto *Stats = ctx.Stats;
159-
160-
if (Stats)
161-
++Stats->getFrontendCounters().NumRequirementMachines;
162-
163162
FrontendStatsTracer tracer(Stats, "build-rewrite-system");
164163

165164
if (Dump) {
@@ -189,15 +188,11 @@ void RequirementMachine::initWithGenericSignature(CanGenericSignature sig) {
189188
///
190189
/// This must only be called exactly once, before any other operations are
191190
/// performed on this requirement machine.
191+
///
192+
/// Used by RequirementSignatureRequest.
192193
void RequirementMachine::initWithProtocols(ArrayRef<const ProtocolDecl *> protos) {
193194
Protos = protos;
194195

195-
auto &ctx = Context.getASTContext();
196-
auto *Stats = ctx.Stats;
197-
198-
if (Stats)
199-
++Stats->getFrontendCounters().NumRequirementMachines;
200-
201196
FrontendStatsTracer tracer(Stats, "build-rewrite-system");
202197

203198
if (Dump) {
@@ -225,18 +220,17 @@ void RequirementMachine::initWithProtocols(ArrayRef<const ProtocolDecl *> protos
225220
}
226221

227222
/// Build a requirement machine from a set of generic parameters and
228-
/// (possibly non-canonical or non-minimal) structural requirements.
223+
/// (possibly non-canonical or non-minimal) abstract requirements.
224+
///
225+
/// This must only be called exactly once, before any other operations are
226+
/// performed on this requirement machine.
227+
///
228+
/// Used by AbstractGenericSignatureRequest.
229229
void RequirementMachine::initWithAbstractRequirements(
230230
ArrayRef<GenericTypeParamType *> genericParams,
231231
ArrayRef<Requirement> requirements) {
232232
Params.append(genericParams.begin(), genericParams.end());
233233

234-
auto &ctx = Context.getASTContext();
235-
auto *Stats = ctx.Stats;
236-
237-
if (Stats)
238-
++Stats->getFrontendCounters().NumRequirementMachines;
239-
240234
FrontendStatsTracer tracer(Stats, "build-rewrite-system");
241235

242236
if (Dump) {

0 commit comments

Comments
 (0)