aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-01-29 15:24:33 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-02-08 13:41:00 +0100
commit953dac0d23007567472414c35ed97861f207e779 (patch)
treec7de80695467eec175e8a8e77d5d0ea103629b53 /server/sonar-server
parent682c8c55b3594652b2c4ec1180ede35139885958 (diff)
downloadsonarqube-953dac0d23007567472414c35ed97861f207e779.tar.gz
sonarqube-953dac0d23007567472414c35ed97861f207e779.zip
SONAR-10313 Small code optimization
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java12
1 files changed, 5 insertions, 7 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
index 9237803edc1..0ec420128dd 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
@@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.SearchHit;
@@ -392,19 +393,16 @@ public class SearchAction implements IssuesWsAction {
LinkedHashMap<String, Long> rulesFacet = facets.get(PARAM_RULES);
try (DbSession dbSession = dbClient.openSession(false)) {
- Set<String> ruleKeysToLoad = new HashSet<>();
- ruleKeysToLoad.addAll(rulesFacet.keySet());
+ Set<String> ruleKeysToLoad = new HashSet<>(rulesFacet.keySet());
ruleKeysToLoad.removeAll(
alreadyLoadedRules
.stream()
.map(r -> r.getKey().toString())
.collect(Collectors.toList()));
- Set<RuleDefinitionDto> requiredRules = new HashSet<>();
- requiredRules.addAll(alreadyLoadedRules);
- requiredRules.addAll(dbClient.ruleDao().selectDefinitionByIds(dbSession, Collections2.transform(ruleKeysToLoad, Integer::parseInt)));
-
- Map<Integer, RuleKey> idToRuleKey = requiredRules.stream()
+ Map<Integer, RuleKey> idToRuleKey = Stream.concat(
+ alreadyLoadedRules.stream(),
+ dbClient.ruleDao().selectDefinitionByIds(dbSession, Collections2.transform(ruleKeysToLoad, Integer::parseInt)).stream())
.collect(Collectors.toMap(RuleDefinitionDto::getId, RuleDefinitionDto::getKey));
LinkedHashMap<String, Long> newRulesFacet = new LinkedHashMap<>();