The specification describes a program used to optimize journal files such
as metafiles used in the Microsoft.RTM. Windows.RTM. programming
environment. The program steps through instructions from the original
journal file and selectively emits the instructions to an optimized
metafile using several optimization techniques. One such technique is to
defer the emission of any state modification instruction until such
emission is actually required by a subsequent instruction that is
dependent on the state modification instruction. For instance, resource
creation and selection instructions are not emitted until the specified
resource is actually used. Another technique is to indefinitely defer the
emission of any state modification instruction that would merely
duplicate the currently existing effect of previously emitted state
modification instructions. A further technique is to indefinitely defer
the emission of resource deletion instructions, and to re-use existing
resources rather than creating a new resource prior to every resource
usage instruction.