Constant requests to QMap or a local copy of the object. Where the best performance?

Help to understand the issue. Write code using Qt. There is a named list QMap map.
How better from the performance point of view to do multiple queries to the same list element, but querying different fields of the structure?

There are two options:
Every time to run map.value("key").The field-structures; or make a local copy inside the function struct p = map.key..... continue to contact them p.The field-structure??

It seems to me that map.value() every time searches for the same item that several clearly. Please explain this point, or where to read?
June 7th 19 at 14:52
1 answer
June 7th 19 at 14:54
Solution
Your code is slow? If Yes, then profile and see where. If not profiled, and there is nothing to say about the performance :)

The value method will always return copy of the value. Ie is it somewhere save, if you need some time to refer to different fields. You can avoid the copy using the iterator or constant reference + operator [] with maps.

To read the official Qt documentation. May be a QHash to see it search faster, but the key imposed other restrictions.

Find more questions by tags Qt