HashMap::iterator::operator* returns new pair

Bug #1069588 reported by Paul J. Lucas
6
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<KeyHolder,ValueHolder>

then operator* could simply return a reference to a reinterpret_cast to that:

 return *reinterpret_cast<std::pair<T,V>*>( &entry );

assuming you move theIsFree to be after the pair in the HashEntry struct layout.

Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

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.

Changed in zorba:
importance: High → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.