diff options
author | 2017-09-14 17:26:42 +0200 | |
---|---|---|
committer | 2017-09-14 18:48:49 +0200 | |
commit | fdc1e2f9fdd3de395ce8655acb26a91b8ab6824e (patch) | |
tree | 37e0a053e7e59e28734e50667f484421d7ba6ccd /src/main/java/com/google/devtools | |
parent | 84cdaa377d8d52d447ee4510c6636327751beb03 (diff) |
Avoid wasting cpu/garbage formatting preconditions string
RELNOTES: None
PiperOrigin-RevId: 168691489
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/Mutability.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Mutability.java b/src/main/java/com/google/devtools/build/lib/syntax/Mutability.java index 2ac152c024..7e69eb1310 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/Mutability.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/Mutability.java @@ -190,10 +190,13 @@ public final class Mutability implements AutoCloseable, Serializable { } Preconditions.checkArgument(lockedItems.containsKey(object), "trying to unlock an object that is not locked"); + List<Location> locList = lockedItems.get(object); - boolean changed = locList.remove(loc); - Preconditions.checkArgument(changed, Printer.format( - "trying to unlock an object for a location at which it was not locked (%r)", loc)); + if (!locList.remove(loc)) { + throw new IllegalArgumentException( + Printer.format( + "trying to unlock an object for a location at which it was not locked (%r)", loc)); + } if (locList.isEmpty()) { lockedItems.remove(object); } |