# Saving a 100 tokens worth, is it worth it?

The LaTeX kernel defines a number of tokens that are used throughout the LaTeX source and the standard LaTeX classes. For example:

\def\hb@xt@{\hbox to}


This particular one is commented as:

The next one is another 100 tokens worth.

My understanding is that the tokens are saved by abbreviating the to and that is where the tokens are saved.

Similarly,

\@height saves 5 tokens at the cost in time of one macro expansion by defining the macro \def\@height{height} to replace the TeX height and so on with many more examples.

However, in many cases the conversion, in my opinion, makes the code difficult to read. With to-days's computer power, is this still a good practice? Would you recommend that one should optimize final code in such a manner?

I'd say this is no longer needed as in most LaTeX documents today there are a lot of tokens used by things like pgf which make the modest saving in optimisation pretty meaningless. One of the things we're doing in LaTeX3 is trying to move to more logical constructs at the expense of efficiency in tokens, at least at a higher level. (Right at the core of expl3 there is still a need to watch the number of expansions, etc., and this is an area where we may yet need some more optimisation.)
• The trouble with optimisation is, no matter how pressing the need, you can paint yourself into ugly corners when you have code written for efficiency rather than readability. Writing readable and efficient code - well, that's an art. plain.tex is a better source for that than the Latex2 sources. – Charles Stewart Dec 3 '10 at 12:24
I recall a former colleague, a Lisp hacker, who talked about when he switched from expressing pairs using (first . second) to (first second): the former needs two extra characters on the screen, the latter used an extra cons cell in the data representation. He changed when he realised he cared that little bit more about "screen estate" than data efficiency.