Skip to content

Commit a7336e8

Browse files
authored
Merge pull request #77266 from xedin/fix-name-of-expr-time-threshold-param
[ConstraintSystem] NFC: Rename threshold in `ExpressionTimer` to clar…
2 parents b4b99e9 + 6109463 commit a7336e8

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ class ExpressionTimer {
240240
ASTContext &Context;
241241
llvm::TimeRecord StartTime;
242242

243-
/// The number of milliseconds from creation until
243+
/// The number of seconds from creation until
244244
/// this timer is considered expired.
245-
unsigned ThresholdInMillis;
245+
unsigned ThresholdInSecs;
246246

247247
bool PrintDebugTiming;
248248
bool PrintWarning;
@@ -251,7 +251,8 @@ class ExpressionTimer {
251251
/// This constructor sets a default threshold defined for all expressions
252252
/// via compiler flag `solver-expression-time-threshold`.
253253
ExpressionTimer(AnchorType Anchor, ConstraintSystem &CS);
254-
ExpressionTimer(AnchorType Anchor, ConstraintSystem &CS, unsigned thresholdInMillis);
254+
ExpressionTimer(AnchorType Anchor, ConstraintSystem &CS,
255+
unsigned thresholdInSecs);
255256

256257
~ExpressionTimer();
257258

@@ -272,20 +273,18 @@ class ExpressionTimer {
272273
return endTime.getProcessTime() - StartTime.getProcessTime();
273274
}
274275

275-
/// Return the remaining process time in milliseconds until the
276+
/// Return the remaining process time in seconds until the
276277
/// threshold specified during construction is reached.
277-
unsigned getRemainingProcessTimeInMillis() const {
278+
unsigned getRemainingProcessTimeInSeconds() const {
278279
auto elapsed = unsigned(getElapsedProcessTimeInFractionalSeconds());
279-
return elapsed >= ThresholdInMillis ? 0 : ThresholdInMillis - elapsed;
280+
return elapsed >= ThresholdInSecs ? 0 : ThresholdInSecs - elapsed;
280281
}
281282

282283
// Disable emission of warnings about expressions that take longer
283284
// than the warning threshold.
284285
void disableWarning() { PrintWarning = false; }
285286

286-
bool isExpired() const {
287-
return getRemainingProcessTimeInMillis() == 0;
288-
}
287+
bool isExpired() const { return getRemainingProcessTimeInSeconds() == 0; }
289288
};
290289

291290
} // end namespace constraints

lib/Sema/CSStep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
938938
Snapshot.emplace(cs, conjunction);
939939

940940
if (cs.Timer) {
941-
auto remainingTime = cs.Timer->getRemainingProcessTimeInMillis();
941+
auto remainingTime = cs.Timer->getRemainingProcessTimeInSeconds();
942942
OuterTimeRemaining.emplace(cs.Timer->getAnchor(), remainingTime);
943943
}
944944
}

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ ExpressionTimer::ExpressionTimer(AnchorType Anchor, ConstraintSystem &CS)
5858
CS.getASTContext().TypeCheckerOpts.ExpressionTimeoutThreshold) {}
5959

6060
ExpressionTimer::ExpressionTimer(AnchorType Anchor, ConstraintSystem &CS,
61-
unsigned thresholdInMillis)
61+
unsigned thresholdInSecs)
6262
: Anchor(Anchor), Context(CS.getASTContext()),
6363
StartTime(llvm::TimeRecord::getCurrentTime()),
64-
ThresholdInMillis(thresholdInMillis),
64+
ThresholdInSecs(thresholdInSecs),
6565
PrintDebugTiming(CS.getASTContext().TypeCheckerOpts.DebugTimeExpressions),
6666
PrintWarning(true) {}
6767

0 commit comments

Comments
 (0)