mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8333774: Avoid eagerly loading various EmptySpliterator classes
Reviewed-by: liach, pminborg
This commit is contained in:
parent
d130d2f4f4
commit
d744059b5b
1 changed files with 21 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -57,12 +57,9 @@ public final class Spliterators {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Spliterator<T> emptySpliterator() {
|
public static <T> Spliterator<T> emptySpliterator() {
|
||||||
return (Spliterator<T>) EMPTY_SPLITERATOR;
|
return (Spliterator<T>) EmptySpliterator.OfRef.EMPTY_SPLITERATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Spliterator<Object> EMPTY_SPLITERATOR =
|
|
||||||
new EmptySpliterator.OfRef<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@code Spliterator.OfInt}
|
* Creates an empty {@code Spliterator.OfInt}
|
||||||
*
|
*
|
||||||
|
@ -73,12 +70,9 @@ public final class Spliterators {
|
||||||
* @return An empty spliterator
|
* @return An empty spliterator
|
||||||
*/
|
*/
|
||||||
public static Spliterator.OfInt emptyIntSpliterator() {
|
public static Spliterator.OfInt emptyIntSpliterator() {
|
||||||
return EMPTY_INT_SPLITERATOR;
|
return EmptySpliterator.OfInt.EMPTY_INT_SPLITERATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Spliterator.OfInt EMPTY_INT_SPLITERATOR =
|
|
||||||
new EmptySpliterator.OfInt();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@code Spliterator.OfLong}
|
* Creates an empty {@code Spliterator.OfLong}
|
||||||
*
|
*
|
||||||
|
@ -89,12 +83,9 @@ public final class Spliterators {
|
||||||
* @return An empty spliterator
|
* @return An empty spliterator
|
||||||
*/
|
*/
|
||||||
public static Spliterator.OfLong emptyLongSpliterator() {
|
public static Spliterator.OfLong emptyLongSpliterator() {
|
||||||
return EMPTY_LONG_SPLITERATOR;
|
return EmptySpliterator.OfLong.EMPTY_LONG_SPLITERATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Spliterator.OfLong EMPTY_LONG_SPLITERATOR =
|
|
||||||
new EmptySpliterator.OfLong();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@code Spliterator.OfDouble}
|
* Creates an empty {@code Spliterator.OfDouble}
|
||||||
*
|
*
|
||||||
|
@ -105,12 +96,9 @@ public final class Spliterators {
|
||||||
* @return An empty spliterator
|
* @return An empty spliterator
|
||||||
*/
|
*/
|
||||||
public static Spliterator.OfDouble emptyDoubleSpliterator() {
|
public static Spliterator.OfDouble emptyDoubleSpliterator() {
|
||||||
return EMPTY_DOUBLE_SPLITERATOR;
|
return EmptySpliterator.OfDouble.EMPTY_DOUBLE_SPLITERATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Spliterator.OfDouble EMPTY_DOUBLE_SPLITERATOR =
|
|
||||||
new EmptySpliterator.OfDouble();
|
|
||||||
|
|
||||||
// Array-based spliterators
|
// Array-based spliterators
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -905,28 +893,40 @@ public final class Spliterators {
|
||||||
private static final class OfRef<T>
|
private static final class OfRef<T>
|
||||||
extends EmptySpliterator<T, Spliterator<T>, Consumer<? super T>>
|
extends EmptySpliterator<T, Spliterator<T>, Consumer<? super T>>
|
||||||
implements Spliterator<T> {
|
implements Spliterator<T> {
|
||||||
OfRef() { }
|
static final Spliterator<Object> EMPTY_SPLITERATOR =
|
||||||
|
new EmptySpliterator.OfRef<>();
|
||||||
|
|
||||||
|
private OfRef() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("overloads")
|
@SuppressWarnings("overloads")
|
||||||
private static final class OfInt
|
private static final class OfInt
|
||||||
extends EmptySpliterator<Integer, Spliterator.OfInt, IntConsumer>
|
extends EmptySpliterator<Integer, Spliterator.OfInt, IntConsumer>
|
||||||
implements Spliterator.OfInt {
|
implements Spliterator.OfInt {
|
||||||
OfInt() { }
|
static final Spliterator.OfInt EMPTY_INT_SPLITERATOR =
|
||||||
|
new EmptySpliterator.OfInt();
|
||||||
|
|
||||||
|
private OfInt() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("overloads")
|
@SuppressWarnings("overloads")
|
||||||
private static final class OfLong
|
private static final class OfLong
|
||||||
extends EmptySpliterator<Long, Spliterator.OfLong, LongConsumer>
|
extends EmptySpliterator<Long, Spliterator.OfLong, LongConsumer>
|
||||||
implements Spliterator.OfLong {
|
implements Spliterator.OfLong {
|
||||||
OfLong() { }
|
static final Spliterator.OfLong EMPTY_LONG_SPLITERATOR =
|
||||||
|
new EmptySpliterator.OfLong();
|
||||||
|
|
||||||
|
private OfLong() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("overloads")
|
@SuppressWarnings("overloads")
|
||||||
private static final class OfDouble
|
private static final class OfDouble
|
||||||
extends EmptySpliterator<Double, Spliterator.OfDouble, DoubleConsumer>
|
extends EmptySpliterator<Double, Spliterator.OfDouble, DoubleConsumer>
|
||||||
implements Spliterator.OfDouble {
|
implements Spliterator.OfDouble {
|
||||||
OfDouble() { }
|
static final Spliterator.OfDouble EMPTY_DOUBLE_SPLITERATOR =
|
||||||
|
new EmptySpliterator.OfDouble();
|
||||||
|
|
||||||
|
private OfDouble() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue