Skip to content

Commit b77f2a1

Browse files
committed
Thread Safety Analysis: Use replaceLock instead of removeLock+addLock
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 c7ccfc6 commit b77f2a1

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
@@ -1071,9 +1071,9 @@ class ScopedLockableFactEntry : public FactEntry {
10711071
return;
10721072
}
10731073

1074-
FSet.removeLock(FactMan, Cp);
1075-
FSet.addLock(FactMan,
1076-
std::make_unique<LockableFactEntry>(!Cp, LK_Exclusive, loc));
1074+
FSet.replaceLock(
1075+
FactMan, It,
1076+
std::make_unique<LockableFactEntry>(!Cp, LK_Exclusive, loc));
10771077
} else if (Handler) {
10781078
SourceLocation PrevLoc;
10791079
if (const FactEntry *Neg = FSet.findLock(FactMan, !Cp))

0 commit comments

Comments
 (0)