[sword-devel] Question for Optimization / speed experts

Christian Renz sword-devel@crosswire.org
Tue, 7 Jan 2003 07:34:55 -0300

Hey David,

>I really don't think an extreme amount of optimization is required; just
>moving to an O(n) algorithm instead of the current O(m*n) should be
>sufficient imho.

You're right -- if that is still too slow, the most efficient
optimization would be to not calculate everything at once, as mentioned.

>Not being able to resist the sirens call to compare programming
>languages using highly contrived examples, I have whipped up an
>equivalent implementation in C++. It is as follows:

My goal wasn't to compare programming languages -- I just don't speak
C++ so well, so it was easier to use perl for me :). Your approach is
the clear winner in this situation -- it optimizes both on speed _and_
programmer's time (_and_ reliability, because STL probably uses a
proven algorithm). It was a nice puzzle for me to figure out the
algorithm, but using a library is almost always smarter :).


crenz@web42.com - http://www.web42.com/crenz/ - http://www.web42.com/

"It still remains true that no justification of virtue will enable a man
to be virtuous."  -- C.S. Lewis, The Abolition of Man