[Advanced-java] Coding String.indexOf() with ignore quoted
Steven J. Owens
puffmail at darksleep.com
Sat Apr 12 07:07:17 2003
On Thu, Apr 03, 2003 at 10:10:37AM -0500, Nikolaos Giannopoulos wrote:
> > Anyway, not sure what your entire program is doing (or if you have
> > already done this) but if I were you I would not spend time
> > speculating over the performance of this one function but rather
> > look at the entire execution of your program using a profiling
> > tool. This should give you a better idea of were your program
> > needs optimization. OptimizeIt is one such tool I have used in the
> > past and it seemed to do the job OK.
> <rant>
>
> Why is it that someone can't look at different approaches to an algorithm
> without having this comment thrown at them? Sure, CPU's are getting faster
> and mediocre code can run quite optimally but that doesn't mean that this is
> a *good* thing (MS???).
It's because, to quote Knuth, "Early optimization is the root of
all evil." (Actually, I believe that's a mis-quote; I remember
reading that the original quote was "of much evil", but I can't find a
good source for that).
Given that, and the prevalence of developers with misdirected
optimizing behavior, it's not surprising that this meme keeps getting
brought up when you don't explain what you're doing and why it makes
sense to devote any degree of time energy to spot-optimizing this bit
of code.
Framework code is one of the classic exceptions usually mentioned
in screeds about when not to optimize and when to optimize. If you'd
mentioned that this was framework code earlier in the conversation (or
did I miss that? I might have) I suspect you wouldn't have had the
opportunity to rant.
Another exception is if you're just looking for faster ways to do
it for fun and education, of course.
Steven J. Owens
puff@darksleep.com
"I'm going to make broad, sweeping generalizations and strong,
declarative statements, because otherwise I'll be here all night and
this document will be four times longer and much less fun to read.
Take it all with a grain of salt." - Me at http://darksleep.com