]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7480 remove useless map copy
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 25 Mar 2016 15:36:11 +0000 (16:36 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 31 Mar 2016 13:22:07 +0000 (15:22 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java

index 64230d8b40b2b2ffa761320cd8a8258efdd8e178..ff63491c89198278f91bca5dc0838d777c578e2f 100644 (file)
@@ -21,11 +21,9 @@ package org.sonar.server.qualityprofile;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Multimap;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import javax.annotation.CheckForNull;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
@@ -101,12 +99,7 @@ public class QProfileLoader {
   }
 
   public Map<String, Long> countAllActiveRules() {
-    Set<Map.Entry<String, Long>> entries = activeRuleIndex.countAllByQualityProfileKey().entrySet();
-    Map<String, Long> counts = new HashMap<>(entries.size());
-    for (Map.Entry<String, Long> entry : entries) {
-      counts.put(entry.getKey(), entry.getValue());
-    }
-    return counts;
+    return activeRuleIndex.countAllByQualityProfileKey();
   }
 
   public Map<String, Multimap<String, FacetValue>> getAllProfileStats() {
index 71348447368b31cc8ded92c9a5b310dcdaf3b827..cb5c848cdcae1473a3ebddf1cd61ac1db40927aa 100644 (file)
@@ -181,13 +181,13 @@ public class SearchDataLoader {
     return Sets.newHashSet(Sets.difference(languageKeys, set2));
   }
 
-  private void addAllFromDto(Map<String, QProfile> qualityProfiles, Collection<QualityProfileDto> list) {
+  private static void addAllFromDto(Map<String, QProfile> qualityProfiles, Collection<QualityProfileDto> list) {
     for (QualityProfileDto qualityProfileDto : list) {
       qualityProfiles.put(qualityProfileDto.getLanguage(), QualityProfileDtoToQProfile.INSTANCE.apply(qualityProfileDto));
     }
   }
 
-  private void addAll(Map<String, QProfile> qualityProfiles, Collection<QProfile> list) {
+  private static void addAll(Map<String, QProfile> qualityProfiles, Collection<QProfile> list) {
     for (QProfile qProfile : list) {
       qualityProfiles.put(qProfile.language(), qProfile);
     }
@@ -197,12 +197,6 @@ public class SearchDataLoader {
     return from(Arrays.asList(languages.all())).transform(LanguageToKey.INSTANCE).toSet();
   }
 
-  private List<QProfile> findDefaultProfiles(Set<String> languageKeys) {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      return findDefaultProfiles(dbSession, languageKeys);
-    }
-  }
-
   private List<QProfile> findDefaultProfiles(final DbSession dbSession, Set<String> languageKeys) {
     return from(profileFactory.getDefaults(dbSession, languageKeys))
       .transform(QualityProfileDtoToQProfile.INSTANCE)