]> Savannah Git Hosting - gnulib.git/commitdiff
localcharset: short-circuit the search for an alias on a Mac
authorBenno Schulenberg <bensberg@telfort.nl>
Sat, 21 Apr 2018 09:08:08 +0000 (11:08 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 21 Apr 2018 10:36:53 +0000 (12:36 +0200)
* lib/localcharset.c (get_charset_aliases): Add a tautological
UTF-8 entry to speed up the search for this case.

Most machines default to a UTF-8 locale nowadays, so begin the
list of aliases with a dummy UTF-8 entry so it will be found
immediately and a time-consuming search through the rest of
the list is avoided.

ChangeLog
lib/localcharset.c

index f5752a2179938ff093dfaa2907b29704d4683419..1c6f3229465f2b651729849bdf8b262802e8f632 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2018-04-21  Benno Schulenberg  <bensberg@telfort.nl>  (tiny change)
+
+       localcharset: short-circuit the search for an alias on a Mac
+       * lib/localcharset.c (get_charset_aliases): Add a tautological
+       UTF-8 entry to speed up the search for this case.
+       Most machines default to a UTF-8 locale nowadays, so begin the
+       list of aliases with a dummy UTF-8 entry so it will be found
+       immediately and a time-consuming search through the rest of
+       the list is avoided.
+
 2018-04-11  Paul Eggert  <eggert@cs.ucla.edu>
 
        fts: add comment
index a73d6bdd1446cd4b6522ed603bea74df36bf1e05..04eaf071d6f9aed88dc1da40acc59f46275a97dd 100644 (file)
@@ -262,8 +262,10 @@ get_charset_aliases (void)
 # if defined DARWIN7
       /* To avoid the trouble of installing a file that is shared by many
          GNU packages -- many packaging systems have problems with this --,
-         simply inline the aliases here.  */
-      cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
+         simply inline the aliases here.
+         For speed, map the most frequent case first.  */
+      cp = "UTF-8" "\0" "UTF-8" "\0"
+           "ISO8859-1" "\0" "ISO-8859-1" "\0"
            "ISO8859-2" "\0" "ISO-8859-2" "\0"
            "ISO8859-4" "\0" "ISO-8859-4" "\0"
            "ISO8859-5" "\0" "ISO-8859-5" "\0"