Avoid wasting cpu/garbage formatting preconditions string

RELNOTES: None
PiperOrigin-RevId: 168691489
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 2ac152c..7e69eb1 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 @@
     }
     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);
     }