Lucene - Core
  1. Lucene - Core
  2. LUCENE-2990

Improve ArrayUtil/CollectionUtil.*Sort() methods to early-reaturn on empty or one-element lists/arrays

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.2, 4.0-ALPHA
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      It might be a good idea to make CollectionUtil or ArrayUtil return early if the passed-in list or array's length <= 1 because sorting is unneeded then. This improves maybe automaton or other places, as for empty or one-element lists no SorterTermplate is created.

      1. LUCENE-2990.patch
        6 kB
        Uwe Schindler
      2. LUCENE-2990.patch
        4 kB
        Uwe Schindler
      3. LUCENE-2990.patch
        6 kB
        Uwe Schindler

        Issue Links

          Activity

          Robert Muir made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Hide
          Robert Muir added a comment -

          Bulk closing for 3.2

          Show
          Robert Muir added a comment - Bulk closing for 3.2
          Uwe Schindler made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Lucene Fields [New] [New, Patch Available]
          Resolution Fixed [ 1 ]
          Hide
          Uwe Schindler added a comment -

          Renamed local variable from "l" to "size".

          Committed trunk revision: 1085689
          Committed 3.x revision: 1085691

          Show
          Uwe Schindler added a comment - Renamed local variable from "l" to "size". Committed trunk revision: 1085689 Committed 3.x revision: 1085691
          uschindler committed 1085689 (4 files)
          Hide
          Uwe Schindler added a comment -

          Will do. Courier New is an ugly font

          Show
          Uwe Schindler added a comment - Will do. Courier New is an ugly font
          Hide
          Simon Willnauer added a comment -

          Uwe patch looks good.

          I wonder if we could change the variable name from l to length or maybe size.
          I had to look twice here

           if (l <= 1) return;
          

          to realize that you don't compare one <= one

          Show
          Simon Willnauer added a comment - Uwe patch looks good. I wonder if we could change the variable name from l to length or maybe size. I had to look twice here if (l <= 1) return ; to realize that you don't compare one <= one
          Uwe Schindler made changes -
          Attachment LUCENE-2990.patch [ 12474526 ]
          Hide
          Uwe Schindler added a comment -

          Add corresponding tests

          Show
          Uwe Schindler added a comment - Add corresponding tests
          Uwe Schindler made changes -
          Attachment LUCENE-2990.patch [ 12474522 ]
          Hide
          Uwe Schindler added a comment -

          Simplier patch (no duplicate checks, missed to see delegation).

          Show
          Uwe Schindler added a comment - Simplier patch (no duplicate checks, missed to see delegation).
          Uwe Schindler made changes -
          Attachment LUCENE-2990.patch [ 12474521 ]
          Uwe Schindler made changes -
          Priority Major [ 3 ] Trivial [ 5 ]
          Uwe Schindler made changes -
          Field Original Value New Value
          Link This issue relates to LUCENE-2989 [ LUCENE-2989 ]
          Uwe Schindler created issue -

            People

            • Assignee:
              Uwe Schindler
              Reporter:
              Uwe Schindler
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development