Package jenkins.util

Class MemoryReductionUtil


  • public class MemoryReductionUtil
    extends Object
    Utilities to reduce memory footprint
    Author:
    Sam Van Oort
    • Field Detail

      • EMPTY_STRING_ARRAY

        public static final String[] EMPTY_STRING_ARRAY
        Empty string array, exactly what it says on the tin. Avoids repeatedly created empty array when calling "toArray."
    • Constructor Detail

      • MemoryReductionUtil

        public MemoryReductionUtil()
    • Method Detail

      • preallocatedHashmapCapacity

        public static int preallocatedHashmapCapacity​(int elementsToHold)
        Returns the capacity we need to allocate for a HashMap so it will hold all elements without needing to resize.
      • getPresizedMutableMap

        public static Map getPresizedMutableMap​(int elementCount)
        Returns a mutable HashMap presized to hold the given number of elements without needing to resize.
      • internInPlace

        public static String[] internInPlace​(String[] input)
        Returns the input strings, but with all values interned.