c++ - Avoid malloc() when doing unordered_map -


try use has map in c++. problem when add constant entry mymap["u.s."] = "washington";, used malloc() (i verified when using gdb breakpoint on malloc()). unnecessary calls malloc reduce performance, hence trying avoid as possible. ideas?

#include <iostream> #include <unordered_map>  int main () {   std::unordered_map<std::string,std::string> mymap;   mymap["u.s."] = "washington";   std::cout << mymap["u.s."] << std::endl;    return 0; } 

i know malloc necessary when scope of key short, since 1 may need use mymap[key] after key destroyed. in case, keys (a huge number of them) persisitent in memory .


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -