aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-10-02 10:28:58 +0200
committerGitHub <noreply@github.com>2017-10-02 10:28:58 +0200
commit8115d8b7e41c38120650bac7432291c722b9a7c3 (patch)
treefa1799aab7cd353475b32d622b4a0408de84cac0 /sonar-plugin-api/src
parent583e42c16797bf57162ebd502e12241d8765a8fc (diff)
downloadsonarqube-8115d8b7e41c38120650bac7432291c722b9a7c3.tar.gz
sonarqube-8115d8b7e41c38120650bac7432291c722b9a7c3.zip
SONAR-6959 Performance improvements
* Avoid creation of intermediary array * SONAR-6959 Speed-up copy of custom measures in Compute Engine * Use light object to get key/uuid map of components * Avoid always formatting string * Minor refactoring * Avoid cost of hash * Ajust perf tests
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/RangeDistributionBuilder.java14
1 files changed, 6 insertions, 8 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/RangeDistributionBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/RangeDistributionBuilder.java
index 3a16537d376..2a069017f1b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/RangeDistributionBuilder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/measure/RangeDistributionBuilder.java
@@ -93,8 +93,8 @@ public class RangeDistributionBuilder {
*/
public RangeDistributionBuilder add(String data) {
Map<Double, Double> map = KeyValueFormat.parse(data, KeyValueFormat.newDoubleConverter(), KeyValueFormat.newDoubleConverter());
- Number[] limits = map.keySet().toArray(new Number[map.size()]);
if (bottomLimits == null) {
+ Number[] limits = map.keySet().toArray(new Number[map.size()]);
init(limits);
} else if (!areSameLimits(bottomLimits, map.keySet())) {
@@ -118,16 +118,14 @@ public class RangeDistributionBuilder {
}
private void changeDoublesToInts() {
- boolean onlyInts = true;
for (Number bottomLimit : bottomLimits) {
if (NumberComparator.INSTANCE.compare(bottomLimit.intValue(), bottomLimit.doubleValue()) != 0) {
- onlyInts = false;
+ // it's not only ints
+ return;
}
}
- if (onlyInts) {
- for (int i = 0; i < bottomLimits.length; i++) {
- bottomLimits[i] = bottomLimits[i].intValue();
- }
+ for (int i = 0; i < bottomLimits.length; i++) {
+ bottomLimits[i] = bottomLimits[i].intValue();
}
}
@@ -204,7 +202,7 @@ public class RangeDistributionBuilder {
@Override
public int compare(Number n1, Number n2) {
- return ((Double) n1.doubleValue()).compareTo(n2.doubleValue());
+ return Double.compare(n1.doubleValue(), n2.doubleValue());
}
}