Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7629

ObjectRange methods duplicate functionality and should not rely on size()

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.5.0-alpha-1
    • groovy-jdk
    • None

    Description

      The methods iterator(), step(), get(), size() and subList() all step through the range, all having their own stepping implementation, which makes the class more complex than it needs to be.

      Also, get(), subList() and iterator() rely on method size(), which in non-numeric cases does a brute-force iteration over all elements. This causes an unnecessary performance overhead in several cases (even if the value of size() is cached after first computation). The overhead may be arbitrarily large, and in cases the size() exceed MAX_INTEGER, the reliance leads to errors.

      (Also see GROOVY-2972, GROOVY-5426).

      I suggest unifying the stepping semantics and not relying on size(). PR will follow.

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              tkruse Thibault Kruse
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: