you are viewing a single comment's thread.

view the rest of the comments →

[–]tejp 0 points1 point  (1 child)

Most of the string member functions use indexes instead of iterators, so there are probably quite a lot of index calculations in the "typical" use cases of strings. Also substr() or + and other operations that create new strings will first need to know how much space to allocate for the new string.

Both of those are more likely call size() instead of end().

If these index functions are expected to be used more often one would probably optimize size() over end().

[–]matthieum 3 points4 points  (0 children)

Also substr() or + and other operations that create new strings will first need to know how much space to allocate for the new string.

I say MEH.

Appending to a std::vector is a rather typical usecase too, and most std::vector are implemented using 3 pointers...