aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorMarco Elver <elver@google.com>2025-06-05 16:05:59 +0200
committerGitHub <noreply@github.com>2025-06-05 16:05:59 +0200
commit2d7f53bc27c345b844013b0a64040119bd362e51 (patch)
tree0ab155036e25fc9e05b3a9492bcd9ed9f600872e /clang/lib
parent9fba20bfacc878bc89b89c1ff44805c5f8a142df (diff)
downloadllvm-2d7f53bc27c345b844013b0a64040119bd362e51.zip
llvm-2d7f53bc27c345b844013b0a64040119bd362e51.tar.gz
llvm-2d7f53bc27c345b844013b0a64040119bd362e51.tar.bz2
Thread Safety Analysis: Use replaceLock instead of removeLock+addLock (#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.
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/ThreadSafety.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index d4d06b6..80e7c8e 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1066,9 +1066,9 @@ private:
return;
}
- FSet.removeLock(FactMan, Cp);
- FSet.addLock(FactMan,
- std::make_unique<LockableFactEntry>(!Cp, LK_Exclusive, loc));
+ FSet.replaceLock(
+ FactMan, It,
+ std::make_unique<LockableFactEntry>(!Cp, LK_Exclusive, loc));
} else if (Handler) {
SourceLocation PrevLoc;
if (const FactEntry *Neg = FSet.findLock(FactMan, !Cp))