From 7cc983360603749c3f098db5c35e81e514dd5845 Mon Sep 17 00:00:00 2001 From: Ke Li Date: Fri, 2 Dec 2016 23:11:41 +0800 Subject: [PATCH] Avoid some redundant unboxing and object creation (#21909) --- .../action/admin/cluster/allocation/NodeExplanation.java | 2 +- .../java/org/elasticsearch/bootstrap/JNACLibrary.java | 2 +- .../org/elasticsearch/bootstrap/JNAKernel32Library.java | 8 +++----- .../java/org/elasticsearch/bootstrap/JavaVersion.java | 4 +--- .../main/java/org/elasticsearch/bootstrap/Seccomp.java | 2 +- .../org/elasticsearch/bootstrap/StartupException.java | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/NodeExplanation.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/NodeExplanation.java index e564711d418..bcd9a1887fb 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/NodeExplanation.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/NodeExplanation.java @@ -106,7 +106,7 @@ public class NodeExplanation implements Writeable, ToXContent { } builder.endObject(); // end store builder.field("final_decision", finalDecision.toString()); - builder.field("final_explanation", finalExplanation.toString()); + builder.field("final_explanation", finalExplanation); builder.field("weight", nodeWeight); nodeDecision.toXContent(builder, params); } diff --git a/core/src/main/java/org/elasticsearch/bootstrap/JNACLibrary.java b/core/src/main/java/org/elasticsearch/bootstrap/JNACLibrary.java index fe0f400698f..4ee11af5267 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/JNACLibrary.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/JNACLibrary.java @@ -61,7 +61,7 @@ final class JNACLibrary { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "rlim_cur", "rlim_max" }); + return Arrays.asList("rlim_cur", "rlim_max"); } } diff --git a/core/src/main/java/org/elasticsearch/bootstrap/JNAKernel32Library.java b/core/src/main/java/org/elasticsearch/bootstrap/JNAKernel32Library.java index 747ba2e458f..27d4ff69e54 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/JNAKernel32Library.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/JNAKernel32Library.java @@ -149,7 +149,7 @@ final class JNAKernel32Library { @Override protected List getFieldOrder() { - return Arrays.asList(new String[]{"BaseAddress", "AllocationBase", "AllocationProtect", "RegionSize", "State", "Protect", "Type"}); + return Arrays.asList("BaseAddress", "AllocationBase", "AllocationProtect", "RegionSize", "State", "Protect", "Type"); } } @@ -261,10 +261,8 @@ final class JNAKernel32Library { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { - "PerProcessUserTimeLimit", "PerJobUserTimeLimit", "LimitFlags", "MinimumWorkingSetSize", - "MaximumWorkingSetSize", "ActiveProcessLimit", "Affinity", "PriorityClass", "SchedulingClass" - }); + return Arrays.asList("PerProcessUserTimeLimit", "PerJobUserTimeLimit", "LimitFlags", "MinimumWorkingSetSize", + "MaximumWorkingSetSize", "ActiveProcessLimit", "Affinity", "PriorityClass", "SchedulingClass"); } } diff --git a/core/src/main/java/org/elasticsearch/bootstrap/JavaVersion.java b/core/src/main/java/org/elasticsearch/bootstrap/JavaVersion.java index 63de83d88d0..03722e03060 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/JavaVersion.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/JavaVersion.java @@ -33,9 +33,7 @@ public class JavaVersion implements Comparable { } private JavaVersion(List version) { - if (version.size() >= 2 - && version.get(0).intValue() == 1 - && version.get(1).intValue() == 8) { + if (version.size() >= 2 && version.get(0) == 1 && version.get(1) == 8) { // for Java 8 there is ambiguity since both 1.8 and 8 are supported, // so we rewrite the former to the latter version = new ArrayList<>(version.subList(1, version.size())); diff --git a/core/src/main/java/org/elasticsearch/bootstrap/Seccomp.java b/core/src/main/java/org/elasticsearch/bootstrap/Seccomp.java index 88c618d445c..a510e964b7e 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/Seccomp.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/Seccomp.java @@ -172,7 +172,7 @@ final class Seccomp { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "len", "filter" }); + return Arrays.asList("len", "filter"); } } diff --git a/core/src/main/java/org/elasticsearch/bootstrap/StartupException.java b/core/src/main/java/org/elasticsearch/bootstrap/StartupException.java index a78f82ef3e7..59629eb5b3b 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/StartupException.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/StartupException.java @@ -104,7 +104,7 @@ final class StartupException extends RuntimeException { continue; } - consumer.accept("\tat " + line.toString()); + consumer.accept("\tat " + line); linesWritten++; } }