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

Inefficient object handling

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Trivial - P5 Trivial - P5
    • 3.0.0
    • 2.9.2
    • Performance
    • 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

            jeff.yemin@mongodb.com Jeffrey Yemin
            nilskp Nils
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: