Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-675

Inefficient object handling

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial - P5
    • Resolution: Fixed
    • Affects Version/s: 2.9.2
    • Fix Version/s: 3.0.0
    • Component/s: Performance
    • Labels:
    • Backwards Compatibility:
      Fully Compatible

      Description

      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 )

      { _checkKeys( (DBObject)inner ); }

      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.

        Attachments

          Activity

            People

            Assignee:
            jeff.yemin Jeffrey Yemin
            Reporter:
            nilskp Nils
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: