# # patch "ChangeLog" # from [a2585504ca40a54dd0c901d55bf69f2853b33738] # to [16a82ae86e06b90b5d4062f935e5168dc88df446] # # patch "interner.hh" # from [57c97faa357c9664fa8c3e457f12a97db9852ed7] # to [31d3f27219df930763472894aa9bc653f533c077] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,7 @@ +2005-07-11 Timothy Brownawell + + * interner.hh: make slightly faster + 2005-07-10 Nathaniel Smith * ChangeLog, configure.ac: Re-remove mysteriously revived --- interner.hh +++ interner.hh @@ -52,18 +52,15 @@ } T intern(std::string const & s, bool & is_new) { - is_new = false; - typename hmap::const_iterator i = fwd.find(s); - if (i == fwd.end()) - { - is_new = true; - T t = rev.size(); - fwd.insert(make_pair(s, t)); - rev.push_back(s); - return t; - } - else - return i->second; + std::pair res; + T t = rev.size(); + // if fwd already contains an entry with key s, this just finds + // that and returns it + res = fwd.insert(make_pair(s, t)); + is_new = res.second; + if (is_new) + rev.push_back(s); + return res.first->second; } };