From 9a83a5f11213f1ed7f8bf2e698f64a120af9eb07 Mon Sep 17 00:00:00 2001 From: Brian Burton Date: Sun, 25 Feb 2024 21:43:36 -0500 Subject: [PATCH] Uses ArrayHelper.prefix() in constructor. --- .../java/org/javimmutable/collections/common/ArrayHelper.java | 2 +- .../java/org/javimmutable/collections/list/MultiValueNode.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/javimmutable/collections/common/ArrayHelper.java b/src/main/java/org/javimmutable/collections/common/ArrayHelper.java index e902ba34..7909e831 100644 --- a/src/main/java/org/javimmutable/collections/common/ArrayHelper.java +++ b/src/main/java/org/javimmutable/collections/common/ArrayHelper.java @@ -271,7 +271,7 @@ public static T[] assignDelete(@Nonnull Allocator allocator, } /** - * Returns a copy of orig containing of length limit containing all values from [0,limit). + * Returns a copy of orig of length limit containing all values from [0,limit). */ @Nonnull public static T[] prefix(@Nonnull Allocator allocator, diff --git a/src/main/java/org/javimmutable/collections/list/MultiValueNode.java b/src/main/java/org/javimmutable/collections/list/MultiValueNode.java index 61cb4426..3b6c1eb4 100644 --- a/src/main/java/org/javimmutable/collections/list/MultiValueNode.java +++ b/src/main/java/org/javimmutable/collections/list/MultiValueNode.java @@ -91,8 +91,7 @@ private MultiValueNode(T[] values) { assert count > 1; assert count <= MAX_SIZE; - this.values = allocate(count); - System.arraycopy(values, 0, this.values, 0, count); + this.values = ArrayHelper.prefix(this, values, count); } /**