Util.pm: add pure perl config file reader
commitef5d305d1975c1808521f46d0016b4ed5e730330
authorKyle J. McKay <mackyle@gmail.com>
Fri, 11 Nov 2016 16:52:09 +0000 (11 08:52 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Fri, 11 Nov 2016 16:52:09 +0000 (11 08:52 -0800)
treec0b8205acee5e862c3b2b46d0b971eefef90dc48
parentf83c58d902c91c5e89f5cc1fa39b1d37f969f922
Util.pm: add pure perl config file reader

Add two new functions that can read a Git config-format file
directly without needing to spawn any subprocesses:

  * read_config_file: preserves ordering and duplicates
  * read_config_file_hash: convenience when duplicates aren't needed

Previously the only option was to spawn a subprocess using
`git config --list` possibly with the `--null` option and parse
the output.

While the speed difference might not be noticed when only reading
a single config file for a single project, the difference when
reading multiple projects' config files is enormous.

Multiple config files can easily be read in less than a tenth the
time needed when spawning subprocesses.  Typically only about 5%
of the time is needed compared to spawning a subprocess.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Girocco/Util.pm