HashMap::iterator::operator* returns new pair
Bug #1069588 reported by
Paul J. Lucas
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zorba |
New
|
Medium
|
Markos Zaharioudakis |
Bug Description
This function returns a brand new std::pair as its return value. It has to copy-construct both T and V every time you call operator*.
If HashEntry had the key/value declared like this:
std::pair<
then operator* could simply return a reference to a reinterpret_cast to that:
return *reinterpret_
assuming you move theIsFree to be after the pair in the HashEntry struct layout.
To post a comment you must log in.
This is a good suggestion, but notice that the iterator also provides getKey() and getValue() methods, which do not copy. So, if you have a situation where performance may suffer due to the copying done by oprator*, you can use getKey() and getValue() in the mean time.