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

The Map plus() method creates new TreeMap but javadoc says HashMap

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5.1
    • 1.5.6, 1.6-rc-2
    • groovy-jdk
    • None

    Description

      The implementation of DefaultGroovyMethods.plus(Map,Map) uses a TreeMap, but the javadoc says HashMap.
      I think a HashMap should be used here. I think that performs better.

      In the odd case that someone wants to add two maps and have a sorted map as the result, it should be implemented explicitly, like

      result = new TreeMap( map1 )
      result.putAll( map2 )
      

      or with the (still missing) leftShift operator

      result = new TreeMap( map1 ) << map2
      

      So, +1 for the leftshift operator (GROOVY-644)

      I think I'll try to write a patch for this.

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              rene.de.bloois René de Bloois
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: