Class StringInterner

java.lang.Object
com.biglybt.core.util.StringInterner

public class StringInterner extends Object
  • Field Details

    • DISABLE_INTERNING

      public static boolean DISABLE_INTERNING
      Can't be final as set true for a few specific apps
    • SCHEDULED_CLEANUP_INTERVAL

      private static final int SCHEDULED_CLEANUP_INTERVAL
      See Also:
    • TRACE_CLEANUP

      private static final boolean TRACE_CLEANUP
      See Also:
    • TRACE_MULTIHITS

      private static final boolean TRACE_MULTIHITS
      See Also:
    • IMMEDIATE_CLEANUP_TRIGGER

      private static final int IMMEDIATE_CLEANUP_TRIGGER
      See Also:
    • IMMEDIATE_CLEANUP_GOAL

      private static final int IMMEDIATE_CLEANUP_GOAL
      See Also:
    • SCHEDULED_CLEANUP_TRIGGER

      private static final int SCHEDULED_CLEANUP_TRIGGER
      See Also:
    • SCHEDULED_CLEANUP_GOAL

      private static final int SCHEDULED_CLEANUP_GOAL
      See Also:
    • SCHEDULED_AGING_THRESHOLD

      private static final int SCHEDULED_AGING_THRESHOLD
      See Also:
    • managedInterningSet

      private static final LightHashSet managedInterningSet
    • unmanagedInterningSet

      private static final LightHashSet unmanagedInterningSet
    • managedSetLock

      static final ReadWriteLock managedSetLock
    • managedRefQueue

      private static final ReferenceQueue managedRefQueue
    • unmanagedRefQueue

      private static final ReferenceQueue unmanagedRefQueue
    • COMMON_KEYS

      private static final String[] COMMON_KEYS
    • byte_map

      private static final ByteArrayHashMap byte_map
    • savingsComp

      private static final Comparator savingsComp
  • Constructor Details

    • StringInterner

      public StringInterner()
  • Method Details

    • intern

      public static String intern(byte[] bytes)
    • internObject

      public static Object internObject(Object toIntern)
      A generic interning facility for heavyweight or frequently duplicated Objects that have a reasonable equals() implementation.

      Important: The objects should have a limited lifespan, the interning set used by this method is unmanaged, i.e. does not clean out old entries! Entries without strong references are still removed.
    • intern

      public static String intern(String toIntern)
    • intern

      public static char[] intern(char[] toIntern)
    • internBytes

      public static byte[] internBytes(byte[] toIntern)
    • internFile

      public static File internFile(File toIntern)
      This is based on File.hashCode() and File.equals(), which can return different values for different representations of the same paths. Thus internFile should be used with canonized Files exclusively
    • internURL

      public static URL internURL(URL toIntern)
    • sanitizeLight

      private static void sanitizeLight()
    • sanitize

      private static void sanitize(boolean scheduled)