Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4695

Pre-Size Java Collections in Union

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.12.0
    • 0.13.0
    • Java - Library
    • None
    • Patch Available

    Description

      One of these methods is not like the other (collections are pre-sized).

      TUnion.java
        private static Map deepCopyMap(Map<Object, Object> map) {
          Map copy = new HashMap();
          for (Map.Entry<Object, Object> entry : map.entrySet()) {
            copy.put(deepCopyObject(entry.getKey()), deepCopyObject(entry.getValue()));
          }
          return copy;
        }
      
        private static Set deepCopySet(Set set) {
          Set copy = new HashSet();
          for (Object o : set) {
            copy.add(deepCopyObject(o));
          }
          return copy;
        }
      
        private static List deepCopyList(List list) {
          List copy = new ArrayList(list.size());
          for (Object o : list) {
            copy.add(deepCopyObject(o));
          }
          return copy;
        }
      

      Attachments

        1. THRIFT-4695.1.patch
          0.9 kB
          David Mollitor

        Issue Links

          Activity

            People

              jking3 James E. King III
              belugabehr David Mollitor
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m