Skip to content

Commit 6c28c81

Browse files
committed
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 <[email protected]>
1 parent 8d86b47 commit 6c28c81

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

gettext.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ void git_setup_gettext(void)
165165
if (!podir)
166166
podir = system_path(GIT_LOCALE_PATH);
167167

168+
if (!is_directory(podir))
169+
return;
170+
168171
bindtextdomain("git", podir);
169172
setlocale(LC_MESSAGES, "");
170173
setlocale(LC_TIME, "");

0 commit comments

Comments
 (0)