summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-10-11 17:04:50 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2022-10-11 17:04:58 +0200
commita5d10657f725e826a7cb3521eb6cba4da5416546 (patch)
tree55c5d86208769e90648ec6475edbe450e014ac05 /container-core
parent274bcee5a55fb61a7c819e6be6acca554fe7a3ae (diff)
Optimize CompoundName.first with 0 elements to return CompoundName.empty.
Optimize CompoundName.first with all elements to return self.
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/processing/request/CompoundName.java2
1 files changed, 2 insertions, 0 deletions
diff --git a/container-core/src/main/java/com/yahoo/processing/request/CompoundName.java b/container-core/src/main/java/com/yahoo/processing/request/CompoundName.java
index 5e52f8d8b37..6af4811fa1b 100644
--- a/container-core/src/main/java/com/yahoo/processing/request/CompoundName.java
+++ b/container-core/src/main/java/com/yahoo/processing/request/CompoundName.java
@@ -175,6 +175,8 @@ public final class CompoundName {
if (compounds.size() < n)
throw new IllegalArgumentException("Asked for the first " + n + " components but '" +
this + "' only have " + compounds.size() + " components.");
+ if (compounds.size() == n) return this;
+ if (compounds.size() == 0) return empty;
return new CompoundName(compounds.subList(0, n));
}