From bc353f4f742f396e58851c16f4f5c2c7dd2c6f04 Mon Sep 17 00:00:00 2001 From: Peter Gafert Date: Sat, 23 May 2020 20:51:52 +0200 Subject: [PATCH] avoid calling `getClass().getSimpleName()` repeatedly Surprisingly when I tested this locally, the JVM did not optimize it and lost some performance just for this statement. The value of using `getSimpleName()` here is not that great, so I simply hard-coded the value (I thought about making it a constant, but then went for simplicity, since the probability that this class will change and we overlook this renaming and it will actually cause a real problem / confusion is IMHO not that great). Signed-off-by: Peter Gafert --- .../java/com/tngtech/archunit/core/importer/Location.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/archunit/src/main/java/com/tngtech/archunit/core/importer/Location.java b/archunit/src/main/java/com/tngtech/archunit/core/importer/Location.java index 5b2e637d55..36e0f76d46 100644 --- a/archunit/src/main/java/com/tngtech/archunit/core/importer/Location.java +++ b/archunit/src/main/java/com/tngtech/archunit/core/importer/Location.java @@ -140,9 +140,9 @@ private String encodeIllegalCharacters(String relativeURI) { } void checkScheme(String scheme, NormalizedUri uri) { - checkArgument(scheme.equals(uri.getScheme()), - "URI %s of %s must have scheme %s, but has %s", - uri, getClass().getSimpleName(), scheme, uri.getScheme()); + String actualScheme = uri.getScheme(); + checkArgument(scheme.equals(actualScheme), + "URI %s of Location must have scheme %s, but has %s", uri, scheme, actualScheme); } /**