[Libguestfs] [PATCH] Add a cache for iconv_t handles to hive_t
Richard W.M. Jones
rjones at redhat.com
Fri Feb 9 16:50:42 UTC 2018
On Fri, Feb 09, 2018 at 03:52:20PM +0100, Hilko Bengen wrote:
> diff --git a/bootstrap b/bootstrap
> index bd82477..373fad8 100755
> --- a/bootstrap
> +++ b/bootstrap
> @@ -75,6 +75,7 @@ vc-list-files
> warnings
> xstrtol
> xstrtoll
> +threadlib
> '
Probably better to keep these sorted.
> +typedef enum {
> + utf8_to_latin1 = 0,
> + latin1_to_utf8,
> + utf8_to_utf16le,
> + utf16le_to_utf8,
> +} recode_type;
> +
> struct hive_h {
> char *filename;
> int fd;
> @@ -79,6 +88,11 @@ struct hive_h {
> /* Internal data for mmap replacement */
> void *p_winmap;
> #endif
> +
> + struct {
> + gl_lock_t mutex;
> + iconv_t *handle;
> + } iconv_cache[4];
I wonder if there's a way we can avoid hard-coding ‘4’ here, which
AIUI is the size of the enum type. Maybe adding an extra enum case
‘nr_recode_types’?
The rest looks good.
ACK, if you sort the list of GNUlib modules in bootstrap.
And maybe try to fix the hard-coded number if there's an easy way
before pushing.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
More information about the Libguestfs
mailing list