Giving the std-map a hint (normally) improves insert performance.
There seems to be no reason not to provide this hint.
Change-Id: I4344607ebf54574a3ae9666d87a41a3c14762361
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
const_iterator it = end();
while (it != begin()) {
--it;
- map.insert(std::pair<Key, T>(it.key(), it.value()));
+ map.insert(map.begin(), std::pair<Key, T>(it.key(), it.value()));
}
return map;
}
void lookup_string_int();
void iteration();
+ void toStdMap();
};
}
}
+void tst_QMap::toStdMap()
+{
+ QMap<int, int> map;
+ for (int i = 0; i < 100000; ++i)
+ map.insert(i, i);
+
+ QBENCHMARK {
+ std::map<int, int> n = map.toStdMap();
+ n.begin();
+ }
+}
QTEST_MAIN(tst_QMap)