From 12fba46d3e738ad6b865500012f85cb0c35cd45d Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 9 Oct 2020 13:01:48 +0100 Subject: [PATCH] Cache codesets structure ourselves attempt to speed up conversion as apparently codesets is being very slow --- frontends/amiga/utf8.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/frontends/amiga/utf8.c b/frontends/amiga/utf8.c index f16cbba6c..af5af126b 100755 --- a/frontends/amiga/utf8.c +++ b/frontends/amiga/utf8.c @@ -36,21 +36,35 @@ static nserror ami_utf8_codesets(const char *string, size_t len, char **result, { char *out; ULONG utf8_tag, local_tag; + static struct codeset *utf8_cs = NULL; + static struct codeset *local_cs = NULL; + + if(local_cs == NULL) CodesetsFind(NULL, +#ifdef __amigaos4__ + CSA_MIBenum, nsoption_int(local_codeset), +#else + NULL, +#endif + TAG_DONE); + + if(utf8_cs == NULL) CodesetsFind(NULL, + CSA_MIBenum, CS_MIBENUM_UTF_8, + TAG_DONE); if(to_local == false) { - local_tag = CSA_SourceMIBenum; - utf8_tag = CSA_DestMIBenum; + local_tag = CSA_SourceCodeset; + utf8_tag = CSA_DestCodeset; } else { - utf8_tag = CSA_SourceMIBenum; - local_tag = CSA_DestMIBenum; + utf8_tag = CSA_SourceCodeset; + local_tag = CSA_DestCodeset; } out = CodesetsConvertStr(CSA_Source, string, CSA_SourceLen, len, #ifdef __amigaos4__ - local_tag, nsoption_int(local_codeset), + local_tag, local_cs, #endif - utf8_tag, CS_MIBENUM_UTF_8, + utf8_tag, utf8_cs, CSA_MapForeignChars, TRUE, TAG_DONE);