-
Type: Improvement
-
Resolution: Done
-
Priority: Trivial - P5
-
Affects Version/s: 2.9.2
-
Component/s: Performance
-
Labels:
-
Fully Compatible
I was debugging through the code and noticed this inefficiency. It's probably not the only place.
DBCollection:
private void _checkKeys( DBObject o ) {
for ( String s : o.keySet() ){
validateKey ( s );
Object inner = o.get( s );
if ( inner instanceof DBObject )
else if ( inner instanceof Map )
{ _checkKeys( (Map<String, Object>)inner ); } }
}
There should be an alternative implementation that takes a Map and iterates the entry set, to avoid expensive lookup for every single key in the structure. Method _checkKeys should then start with an instanceof check and delegate to this method, if possible, which it probably will be for the vast majority of cases.