output: cache the mapped file names

Don't repeatedly call malloc/free for each call to map_file_name.

* bootstrap.conf: We need hash-map.
* src/files.h, src/files.c (map_file_name): The caller must not free
the result.
Adjust callers.
(mapped_dir_prefix, spec_mapped_header_file): Remove.
* src/files.c
(map_file_name): Rename as...
(map_file_name_alloc): this.
(mapped_files, map_file_name, string_equals, string_hash, string_free):
New.
This commit is contained in:
Akim Demaille
2021-02-25 08:31:50 +01:00
parent b96528b48c
commit f6eb1ac87b
7 changed files with 94 additions and 48 deletions

View File

@@ -269,7 +269,5 @@ fail_for_invalid_at (char const *at)
static void
output_mapped_file (char const *name)
{
char *f = map_file_name (name);
fputs (quotearg_style (c_quoting_style, f), yyout);
free (f);
fputs (quotearg_style (c_quoting_style, map_file_name (name)), yyout);
}