Project

General

Profile

Cleanup #432

use STL find() and iterators instead of count()

Added by Sage Weil over 13 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Target version:
-
% Done:

0%

Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:

Description

There are 100 million instances of code like

if (container.count(foo))
  return container[foo];

or similar. We should be using iterators so that the hashes/maps don't need to be traversed twice.

Associated revisions

Revision 01b2e1fd (diff)
Added by Nathan Cutler almost 9 years ago

osd_types.cc: replace count with iterator in add_next_event function

Performance optimization: count() and then operator[] duplicates the rbtree
lookup.

http://tracker.ceph.com/issues/432 Refs: #432

Signed-off-by: Nathan Cutler <>

History

#1 Updated by Noah Watkins over 11 years ago

The semantic patch tool Coccinelle has an open issue for supporting C++. Something to keep an eye out for, and would probably be perfect for this task.

#2 Updated by Rishabh Kumar over 7 years ago

Hi. I wish to do this major cleanup. I will break it down into a series of commits depending on the subdirectories.

#3 Updated by Greg Farnum about 7 years ago

+1 :)

#4 Updated by Jos Collin over 6 years ago

  • Assignee set to Amit Kumar

#5 Updated by Patrick Donnelly about 5 years ago

  • Status changed from New to Closed

Closing this, there's a never-ending stream of these.

Also available in: Atom PDF