UIDefaultsLoader: minor optimization (avoid String.substring() and avoid double searching for '.')

This commit is contained in:
Karl Tauber
2020-11-06 23:47:06 +01:00
parent 605c77ecbc
commit 7c08489cb3

View File

@@ -211,14 +211,17 @@ class UIDefaultsLoader
}
// override UI defaults with globals
for( Object okey : defaults.keySet() ) {
if( okey instanceof String && ((String)okey).contains( "." ) ) {
String key = (String) okey;
String globalKey = key.substring( key.lastIndexOf( '.' ) + 1 );
String globalValue = globals.get( globalKey );
if( globalValue != null && !properties.containsKey( key ) )
properties.put( key, globalValue );
}
for( Object key : defaults.keySet() ) {
int dot;
if( !(key instanceof String) ||
properties.containsKey( key ) ||
(dot = ((String)key).lastIndexOf( '.' )) < 0 )
continue;
String globalKey = ((String)key).substring( dot + 1 );
String globalValue = globals.get( globalKey );
if( globalValue != null )
properties.put( key, globalValue );
}
Function<String, String> propertiesGetter = key -> {