Advertisement
PVS-StudioWarnings

PVS-Studio warning V803 for Geant4

Nov 27th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. class G4PhysicsTable : public std::vector<G4PhysicsVector*> {
  2.   ....
  3. };
  4.  
  5. typedef G4PhysicsTable::iterator G4PhysicsTableIterator;
  6.  
  7. inline void G4PhysicsTable::insertAt(
  8.   size_t idx, G4PhysicsVector* pvec)
  9. {
  10.   G4PhysicsTableIterator itr=begin();
  11.   for (size_t i=0; i<idx; ++i) { itr++; }
  12.   ....
  13. }
  14.  
  15. This suspicious code was found in Geant4 project by PVS-Studio static code analyzer.
  16. Warning message is:
  17. V803 Decreased performance. In case 'itr' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. g4physicstable.icc 83
  18.  
  19. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement