New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
removed unnecessary mutables from PixelDigiCollection #3441
removed unnecessary mutables from PixelDigiCollection #3441
Conversation
The previous code was using std::map::operator[] in places where it could use std::map::find to get the same results. Switching to find allowed the removal of the mutables. These mutables were causing warnings from the static analyzer and would have lead to crashes in the threaded framework.
A new Pull Request was created by @Dr15Jones (Chris Jones) for CMSSW_7_1_X. removed unnecessary mutables from PixelDigiCollection It involves the following packages: DataFormats/SiPixelDigi @cmsbuild, @civanch, @Degano, @mdhildreth, @nclopezo can you please review it and eventually sign? Thanks. |
@@ -40,7 +40,11 @@ void PixelDigiCollection::put(Range input, unsigned int detID) { | |||
const PixelDigiCollection::Range PixelDigiCollection::get(unsigned int detID) const { | |||
// get Digis of detID | |||
|
|||
PixelDigiCollection::IndexRange returnIndexRange = map_[detID]; | |||
auto found = map_.find(detID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: Although this is functionally completely identical to the original code, I believe the original code had a bug. If map_
does not contain detID
then you get a defaultly constructed IndexRange
which is a std::pair<unsigned int, unsigned int>
and therefore (0,0). However the return value of this function in that case will be (container_.begin(), container_.begin()+1)
. However I believe the true answer should be (container_.end(),container_.end())
.
If this is a bug, I leave its fix to the owners of the code.
+1 |
…lDigiCollection Multithreading -- Removed unnecessary mutables from PixelDigiCollection
The previous code was using std::map::operator[] in places where
it could use std::map::find to get the same results. Switching
to find allowed the removal of the mutables. These mutables were
causing warnings from the static analyzer and would have lead to
crashes in the threaded framework.