Bugzilla – Bug 1870
AsInt function is useless (and slow)
Last modified: 2014-03-14 17:51:45 UTC
Created attachment 1791 [details] Patch to remove AsInt static uint8_t AsInt (std::string v) { NS_LOG_FUNCTION (v); std::istringstream iss; iss.str (v); uint32_t retval; iss >> std::hex >> retval >> std::dec; return retval; } is functionally equivalent to: strtoul (tmp.c_str(), 0, 16) The difference is the speed. AsInt is 20x time *slower*. See: http://tinodidriksen.com/2010/02/16/cpp-convert-string-to-int-speed/ We're lucky that the stream extraction operator (where AsInt is called) isn't used often...
Pushed in changeset: 10647:0fd17d2704cd
*** Bug 1881 has been marked as a duplicate of this bug. ***