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

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P5
    • 24
    • Affects Version/s: None
    • Component/s: 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.

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

              Created:
              Updated:
              Resolved: