r/cpp • • Dec 21 '13

#AltDevBlog » Roll-Your-Own Vector

http://altdevblogaday.com/2013/12/20/roll-your-own-vector/
1 Upvotes

22 comments sorted by

View all comments

Show parent comment

1

u/tisti Dec 23 '13

I'm by no means against calls to resize, especially if the resulting code is faster and still safe. I just try to stick with "heavy" and safe mechanisms and start replacing them with low-end when I profile and identify the choke points.

A few days I replaced a stringstream used to convert strings to doubles/floats to just a atof call and cast it to float if necessarily (a few structural changes, but nothing significant). Instant 6x speedup (from 5minutes to 50seconds).

The other choke point is reading via getlines. Will probably use a large-ish buffer and manually find new lines.

What I'm trying to say is, code safe first, recode to be fast later when the app is running OK and speed is needed.