From c946c2174c56c7c0463292c5a94e1d542950e028 Mon Sep 17 00:00:00 2001 From: Janos Gyerik Date: Thu, 2 Mar 2017 18:05:15 +0100 Subject: Store repeated call result in local variable --- .../sonar/scanner/scan/filesystem/InputComponentStore.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sonar-scanner-engine') diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java index 52c0167d100..ff92762a405 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java @@ -186,13 +186,14 @@ public class InputComponentStore { } public void put(DefaultInputModule inputModule) { - Preconditions.checkState(!inputComponents.containsKey(inputModule.key()), "Module '%s' already indexed", inputModule.key()); - Preconditions.checkState(!inputModuleCache.containsKey(inputModule.key()), "Module '%s' already indexed", inputModule.key()); - inputComponents.put(inputModule.key(), inputModule); - inputModuleCache.put(inputModule.key(), inputModule); + String key = inputModule.key(); + Preconditions.checkState(!inputComponents.containsKey(key), "Module '%s' already indexed", key); + Preconditions.checkState(!inputModuleCache.containsKey(key), "Module '%s' already indexed", key); + inputComponents.put(key, inputModule); + inputModuleCache.put(key, inputModule); if (inputModule.definition().getParent() == null) { if (root != null) { - throw new IllegalStateException("Root module already indexed: '" + root.key() + "', '" + inputModule.key() + "'"); + throw new IllegalStateException("Root module already indexed: '" + root.key() + "', '" + key + "'"); } root = inputModule; } -- cgit v1.2.3