Since gnulib-tool does not modify modules, it is OK to initialize each
module only once. Moreover, since most of the time is spent upon
executing transitive closures and each transitive closure stores all
modules into different lists, it is also a good idea to calculate the
hash only once for read-only modules. These simple additions make
gnulib-tool much faster than before, since each module is initialized
only once-per-run and has a constant hash value.
For example, an invocation of pygnulib.py inside wget2 takes about 0.5
seconds until it completes gnulib-comp.m4 generation; previously it used
to take up to 8 seconds. Needless to say that performing the same task
is much slower when using the good old gnulib-tool: in my experiments
it takes about a minute to complete gnulib-comp.m4 generation.
Some of the TransitiveClosure methods considered useful enough to be
also present as a part of Database class. The refactoring also revealed
that conditional modules computation was implemented incorrectly; this
code was fixed. Moreover, this part of functionality was moved into the
__init__ section, which also saves several milliseconds since it is not
necessary to check whether conditional modules table exists upon each
conditional() invocation.