Projects
Mega:24.03
guava20
_service:tar_scm:0001-Avoid-presizing-arrays.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:0001-Avoid-presizing-arrays.patch of Package guava20
From c6497b79ee766206ba27c6b33391e1d5e572e662 Mon Sep 17 00:00:00 2001 From: Michael Simacek <msimacek@redhat.com> Date: Wed, 2 May 2018 15:22:08 +0200 Subject: [PATCH] Avoid presizing arrays Backported version of: https://github.com/google/guava/commit/f89ece5721b2f637fe754937ff1f3c86d80bb196 Ignoring GWT, as we don't ship it. Using ArrayList, because ImmutableLongArray is not available. --- .../common/util/concurrent/AtomicDoubleArray.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java b/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java index e939672..23a2535 100644 --- a/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java +++ b/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java @@ -17,7 +17,10 @@ import static java.lang.Double.doubleToRawLongBits; import static java.lang.Double.longBitsToDouble; import com.google.common.annotations.GwtIncompatible; +import com.google.common.primitives.Longs; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.atomic.AtomicLongArray; /** @@ -261,13 +264,11 @@ public class AtomicDoubleArray implements java.io.Serializable { throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); - // Read in array length and allocate array int length = s.readInt(); - this.longs = new AtomicLongArray(length); - - // Read in all elements in the proper order. + List<Long> builder = new ArrayList<Long>(); for (int i = 0; i < length; i++) { - set(i, s.readDouble()); + builder.add(doubleToRawLongBits(s.readDouble())); } + this.longs = new AtomicLongArray(Longs.toArray(builder)); } } -- 2.17.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2