Hello! Please review the following enhancement: https://bugs.openjdk.java.net/browse/JDK-8153332 http://cr.openjdk.java.net/~tvaleev/webrev/8153332/r1/
It was earlier discussed here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-March/039308.html The motivation and algorithm are briefly described in the JIRA issue description. Visible behavior should not change after this patch, so all the existing tests pass. I added some more tests to focus on sorted().limit() chain. Again here's some performance tests which were presented in earlier discussion: http://cr.openjdk.java.net/~tvaleev/patches/sortedLimit/jmh/ http://cr.openjdk.java.net/~tvaleev/patches/sortedLimit/jmh/summary.txt With best regards, Tagir Valeev.