
14 Feb
2008
14 Feb
'08
1:43 a.m.
I just discovered that the string algorithm predicate is_any_of has an inefficient implementation. Internally it uses a std::set. There are two problems with this. First, since the order of the characters does not matter, std::unordered_set is probably faster. Second, the contained set has to be copied each time the object is used in, for instance, a split() statement. Since split can reuse a predicate literally thousands of times when splitting a large string, this is a lot of unnecessary copying. Joe Gottman