Skip to content

Commit 2d7f53b

Browse files
authored
Thread Safety Analysis: Use replaceLock instead of removeLock+addLock (llvm#141500)
In ScopedLockableFactEntry::unlock(), we can avoid a second search, pop_back(), and push_back() if we use the already obtained iterator into the FactSet to replace the old FactEntry and take its position in the vector.
1 parent 9fba20b commit 2d7f53b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clang/lib/Analysis/ThreadSafety.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,9 @@ class ScopedLockableFactEntry : public FactEntry {
10661066
return;
10671067
}
10681068

1069-
FSet.removeLock(FactMan, Cp);
1070-
FSet.addLock(FactMan,
1071-
std::make_unique<LockableFactEntry>(!Cp, LK_Exclusive, loc));
1069+
FSet.replaceLock(
1070+
FactMan, It,
1071+
std::make_unique<LockableFactEntry>(!Cp, LK_Exclusive, loc));
10721072
} else if (Handler) {
10731073
SourceLocation PrevLoc;
10741074
if (const FactEntry *Neg = FSet.findLock(FactMan, !Cp))

0 commit comments

Comments
 (0)