Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8333265

De-duplicate method references in java.util.stream.FindOps

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 24
    • None
    • core-libs

      When initializing j.u.stream.FindOps$FindRef we spin up some duplicate lambda proxy classes:

                  static final TerminalOp<?, ?> OP_FIND_FIRST = new FindOp<>(true,
                          StreamShape.REFERENCE, Optional.empty(),
                          Optional::isPresent, FindSink.OfRef::new);

                  static final TerminalOp<?, ?> OP_FIND_ANY = new FindOp<>(false,
                          StreamShape.REFERENCE, Optional.empty(),
                          Optional::isPresent, FindSink.OfRef::new);

      Extracting Optional::isPresent and FindSink.OfRef::new to static constants means we can reuse the lambdas for the different streams. A simple, minor startup win.

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: