|
-
March 19th, 2007, 06:32 PM
#3
Re: Any way to improve this?
Hi.
 Originally Posted by IllegalCharacter
every time you call push_back with the vector it has to allocate a new array and copy all the elements into it again
Not 'every time'... but, usually (some implementations) when you reach the end of a vector it's resized to twice the original size. That's why iterators to vector can become invalid. Note, however, that a list will actually allocate memory for 'every' push back.
Anyway, if the file is always around this big, a first (and quick) attempt to improve performance is to initialize the vector with 400.000 elements. Try this and let us know.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|