How can I increase the performance in a map lookup with key type std::string?

后端 未结 14 1301
天涯浪人
天涯浪人 2021-02-05 23:25

I\'m using a std::map (VC++ implementation) and it\'s a little slow for lookups via the map\'s find method.

The key type is std::string.

14条回答
  •  没有蜡笔的小新
    2021-02-05 23:41

    Why don't you use a hashtable instead? boost::unordered_map could do. Or you can roll out your own solution, and store the crc of a string instead of the string itself. Or better yet, put #defines for the strings, and use those for lookup, e.g.,

    #define "STRING_1" STRING_1
    

提交回复
热议问题