Hi Tagir, another minor issue. The testFlags() methods in IntPrimitiveOpsTests / LongPrimitiveOpsTests each have a duplicated assert:
IntPrimitiveOpsTests: assertFalse(IntStreams.of(1, 10).boxed().spliterator() .hasCharacteristics(Spliterator.SORTED)); LongPrimitiveOpsTests: assertFalse(LongStreams.of(1, 10).boxed().spliterator() .hasCharacteristics(Spliterator.SORTED)); The asserts for IntStreams.range(1, 10).asDoubleStream() would have to be changed to account for DISTINCTness, of course. Regards, Stefan 2016-04-01 18:25 GMT+02:00 Tagir F. Valeev <amae...@gmail.com>: > Hello! > > Please review and sponsor the following patch: > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/r1/ > > The patch preserves more characteristics on primitive stream > operations: > IntStream/LongStream/DoubleStream.boxed() preserves SORTED and DISTINCT > IntStream.asLongStream() preserves SORTED and DISTINCT > IntStream.asDoubleStream() and LongStream.asDoubleStream() preserves SORTED > (different longs can be converted into the same double, so DISTINCT is > not preserved here; not sure whether this is possible for ints) > > Fixing the boxed() case is especially important as distinct() for > primitive streams is implemented like boxed().distinct().unbox, so the > actual distinct() operation cannot take the advantage of DISTINCT flag > (skip the operation at all) or SORTED flag (switch to more efficient > implementation). > > Here's the small JMH benchmark which measures the performance boost of > quite common operation: sort the input numbers and leave only distinct > ones: > http://cr.openjdk.java.net/~tvaleev/webrev/8153293/jmh/ > > new Random(1).ints(size).sorted().distinct().toArray() > > I've got the following results. > > 9ea+111: > > Benchmark (size) Mode Cnt Score Error > Units > SortDistinctTest.sortedDistinct 10 avgt 30 0,612 ± 0,004 > us/op > SortDistinctTest.sortedDistinct 1000 avgt 30 92,848 ± 1,039 > us/op > SortDistinctTest.sortedDistinct 100000 avgt 30 32147,205 ± 3487,422 > us/op > > 9ea+111 patched: > > Benchmark (size) Mode Cnt Score Error Units > SortDistinctTest.sortedDistinct 10 avgt 30 0,435 ± 0,001 us/op > SortDistinctTest.sortedDistinct 1000 avgt 30 40,555 ± 0,772 us/op > SortDistinctTest.sortedDistinct 100000 avgt 30 9031,651 ± 73,956 us/op > > With best regards, > Tagir Valeev. >