I am working on a dictionary, and I would like to reduce the time it takes to build it. The entries that I work with are stored in some form, and are then 'translated' to a TeX file, which is included with \input. This file looks like this:
\wordentry{book}{a handwritten or printed work of fiction or nonfiction, usually on sheets of paper fastened or bound together within covers}
\wordentry{cat}{an animal that…}
\wordentry{dog}{an animal that…}
It's just a series of calls to \wordentry, which is defined in the preamble and successfully dumped into the format file. FWIW, this macro calls \hypertarget, \label and \bookmark.
The bulk of the build time is spent processing this file, and I thought that perhaps it would be possible to 'take' it inside the format file I am using. The idea is that, if the following macro
\newcommand{\hello}{hello}
can be put in the preamble and dumped, then perhaps
\newcommand{\thewholefile}{ THE CONTENTS OF THE FILE }
could be dumped as well. The same file is processed three times because of cross-references, so any speedup should add up.
Well, I first tried
\newcommand{\thewholefile}{\input{thefile}}
but the file wasn't being read at all. I messed with \expandafter to no avail, so, finally, I just pasted the contents of the file. It worked, although it didn't reduce the build time (it produced a 17MB format file, though). I wonder if I have done it wrong or if dumps simply can't improve the situation. I'm guessing that iniTeX just dumped the definition of \thewholefile, without actually 'digesting' it.
Could you please give some hints about the matter? Have I done it wrong, or are format files unsuitable for this task? Is there something I can try to reduce the build time?
I haven't provided a MWE because I saw no way of stripping the monster while keeping its complexity. I guess this question is more 'theoretical' than 'practical'. FWIW, I am using LuajitTeX from TeX Live 2015 (beta-0.80.0).
\input, packagecatchfileis of help. See this question. – djsp Jul 13 '15 at 12:06