Netflix / archaius

Library for configuration management API
Apache License 2.0
2.47k stars 486 forks source link

Avoid map resizing in PrivateViewConfig #730

Closed kilink closed 1 month ago

kilink commented 1 month ago

Properly size the LinkedHashMaps in the createState method to avoid rehashing / resizing. Additionally, if instrumentation is not enabled, just use the singleton empty map.

To facilitate this change, add an Iterables utility class with a "size" helper to determine the size of the passed in Iterable; this is necessary because the Config::keys method returns Iterable, but in practice is typically a Collection.

Finally, add a marker annotation, Internal, to indicate classes such as Maps and Iterables that are not meant to be used by users of Archaius and may not have stable APIs.