Create new Document constructor taking initial capacity of LinkedHashMap

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Fix
    • Priority: Minor - P4
    • None
    • Affects Version/s: 3.2.2
    • Component/s: API, BSON
    • None
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, when Document class is initialized, it doesn't allow setting `initialCapacity` of internal LinkedHashMap so, that value gets set to 16 everytime. This doesn't work well if I already know number of entries going to be inserted / appended. If number of entries are are less than 16 then, it's kind of creating internal linked list table with bigger size or if entries are greater than 16, it's guaranteed to do `resize()`.

      So, it would be nice if Document class exposes new constructor with initial capacity of internal LinkedHashMap.

      /**
       * Creates an empty Document instance with custom intial capacity
       */
      public Document(int initialCapacity) {
          documentAsMap = new LinkedHashMap<String, Object>(initialCapacity);
      }
      

            Assignee:
            Ross Lawley
            Reporter:
            PRAJWAL TULADHAR
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: