Replace java.util.Hashtable with java.util.HashMap
ProprietaryHashtable synchronizes every operation, which only costs time when a single thread uses it. This recipe replaces a Hashtable that a method creates and keeps in a local variable with a HashMap when program analysis shows that no other thread can reach it or a view of it such as its keySet(): neither is returned, stored in a field, passed to another method or constructor, or captured by a lambda that may run later or on another thread, by any path through the method, loops and catch blocks included. A table whose Hashtable-only methods (contains, elements, keys) are called, fields, and Kotlin and other non-Java source are left as they are. HashMap accepts null keys and values, so it accepts every input Hashtable did, and both leave the order of their keys unspecified.
io. moderne. staticanalysis. ReplaceHashtableWithHashMapmod run . --recipe= io. moderne. staticanalysis. ReplaceHashtableWithHashMapInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.