From 214bf852d8dab02bf62900e61facef2c9f48f2f4 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 21 Apr 2018 11:08:08 +0200 Subject: [PATCH] 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. --- ChangeLog | 10 ++++++++++ lib/localcharset.c | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f5752a2179..1c6f322946 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2018-04-21 Benno Schulenberg (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 fts: add comment diff --git a/lib/localcharset.c b/lib/localcharset.c index a73d6bdd14..04eaf071d6 100644 --- a/lib/localcharset.c +++ b/lib/localcharset.c @@ -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" -- 2.39.5