Skip to content

Commit a7486b4

Browse files
committed
RequirementMachine: Code review feedback from @CodaFi
1 parent 6df75ee commit a7486b4

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

include/swift/AST/RewriteSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class Term final {
216216
Term() {}
217217

218218
explicit Term(llvm::SmallVector<Atom, 3> &&atoms)
219-
: Atoms(atoms) {}
219+
: Atoms(std::move(atoms)) {}
220220

221221
explicit Term(ArrayRef<Atom> atoms)
222222
: Atoms(atoms.begin(), atoms.end()) {}

lib/AST/ASTContext.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,9 +1843,10 @@ RequirementMachine *ASTContext::getOrCreateRequirementMachine(
18431843
// signature.
18441844
auto arena = getArena(sig);
18451845
auto &machines = getImpl().getArena(arena).RequirementMachines;
1846-
auto known = machines.find(sig);
1847-
if (known != machines.end()) {
1848-
auto *machine = known->second.get();
1846+
1847+
auto &machinePtr = machines[sig];
1848+
if (machinePtr) {
1849+
auto *machine = machinePtr.get();
18491850
if (!machine->isComplete()) {
18501851
llvm::errs() << "Re-entrant construction of requirement "
18511852
<< "machine for " << sig << "\n";
@@ -1855,12 +1856,12 @@ RequirementMachine *ASTContext::getOrCreateRequirementMachine(
18551856
return machine;
18561857
}
18571858

1858-
// Create a new requirement machine with the given signature.
1859-
auto machine = new RequirementMachine(*this);
1859+
auto *machine = new RequirementMachine(*this);
18601860

18611861
// Store this requirement machine before adding the signature,
1862-
// to catch re-entrant construction.
1863-
machines[sig] = std::unique_ptr<RequirementMachine>(machine);
1862+
// to catch re-entrant construction via addGenericSignature()
1863+
// below.
1864+
machinePtr = std::unique_ptr<RequirementMachine>(machine);
18641865

18651866
machine->addGenericSignature(sig);
18661867

0 commit comments

Comments
 (0)