[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Yes, they are special, but...



At some point in my version of TeX I replaced the dispatch in the
inner loop with an array of functions similar to your suggestion.  I
don't know if that is what is done now.  (I don't use TeX much and
since I have a Sun on my desk now, if I do use it, I run it on the
Sun).  As I recall, the speed up was not as dramatic as one might
expect.  There are several reasons for this.  I think that the
overhead of doing a funcall is greater than 3 or 4 tests.  In TeX the
first several branches of the dispatch account for a large percentage
of the cases.  The array referencing and funcalling approach will
increase performance much more when the probability of taking any
branch of the case/cond is about the same.  I suppose this says
something about the design of programs.  Another reason that the
funcall are not faster is that the functions in the array reference
variables specially that are referenced as locals in the case/cond
approach.

If my memory serves I believe that I removed the array of functions
and just used the case statement.  I don't think it speed things up
much and I had to replace some of the Lisp code output by my compiler
with a piece of code to construct the array.  Since I would
(potentially) have to change this code any time the Pascal changed I
believe I decided to just use the CASE statement.

Perhaps Mabry can tell us how it is done in the version of TeX he
uses.

Art