On Monday 06 June 2005 00:53, Dave Robillard wrote:
Good
answer. I've often wondered why anyone would use vectors.
Because they dynamically resize, easily, and are generally much simpler
to work with, perhaps? :)
Not to mention being more-or-less fully debugged and stable.
I think it's important to preserve some balance here. While absolute speed is
important, there are times when it can be a perfectly valid design decision
to subordinate speed to other goal (such as design flexibility,
maintainability or even [gasp!] speed of development). Will it really make
that much difference if a constructor that runs once at application startup
takes 0.75 instead of 0.20 sec to complete?
Of course, there are also situations where it's absolutely right and necessary
to optimize for every ounce of speed possible. The point is that it really
depends upon the specific situation and design -- to say that 'so-and-so
technique is *always* better' is naive. This is why profiling your code is
important -- it highlights spots where the 'spit-n-shine' routine will do the
most good.
Cheers!
|-------------------------------------------------------------------------|
| Frederick F. Gleason, Jr. | Director of Broadcast Software Development |
| | Salem Radio Labs |
|-------------------------------------------------------------------------|
| Optimization is fifteen percent science and eighty-five percent |
| black magic. |
| -- Linux Torvalds |
|-------------------------------------------------------------------------|