mirror of
https://github.com/git/git.git
synced 2026-01-22 00:16:01 +00:00
gettext: avoid initialization if the locale dir is not present
The runtime of a simple `git.exe version` call on Windows is currently dominated by the gettext setup, adding a whopping ~150ms to the ~210ms total. Given that this cost is added to each and every git.exe invocation goes through common-main's invocation of git_setup_gettext(), and given that scripts have to call git.exe dozens, if not hundreds, of times, this is a substantial performance penalty. This is particularly pointless when considering that Git for Windows ships without localization (to keep the installer's size to a bearable ~34MB): all that time setting up gettext is for naught. So let's be smart about it and skip setting up gettext if the locale directory is not even present. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
12
gettext.c
12
gettext.c
@@ -167,11 +167,13 @@ void git_setup_gettext(void)
|
||||
if (!is_absolute_path(podir))
|
||||
podir = p = system_path(podir);
|
||||
|
||||
bindtextdomain("git", podir);
|
||||
setlocale(LC_MESSAGES, "");
|
||||
setlocale(LC_TIME, "");
|
||||
init_gettext_charset("git");
|
||||
textdomain("git");
|
||||
if (is_directory(podir)) {
|
||||
bindtextdomain("git", podir);
|
||||
setlocale(LC_MESSAGES, "");
|
||||
setlocale(LC_TIME, "");
|
||||
init_gettext_charset("git");
|
||||
textdomain("git");
|
||||
}
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user