mirror of
https://github.com/git/git.git
synced 2026-01-21 08:00:54 +00:00
Merge branch 'skip-gettext-when-possible'
This topic branch allows us to skip the gettext initialization when the locale directory does not even exist. This saves 150ms out of 210ms for a simply `git version` call on Windows, and it most likely will help scripts that call out to `git.exe` hundreds of times. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
4
Makefile
4
Makefile
@@ -492,6 +492,7 @@ lib = lib
|
||||
# DESTDIR =
|
||||
pathsep = :
|
||||
|
||||
localedir_relative = $(patsubst $(prefix)/%,%,$(localedir))
|
||||
mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))
|
||||
infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))
|
||||
htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
|
||||
@@ -1740,6 +1741,7 @@ mandir_relative_SQ = $(subst ','\'',$(mandir_relative))
|
||||
infodir_relative_SQ = $(subst ','\'',$(infodir_relative))
|
||||
perllibdir_SQ = $(subst ','\'',$(perllibdir))
|
||||
localedir_SQ = $(subst ','\'',$(localedir))
|
||||
localedir_relative_SQ = $(subst ','\'',$(localedir_relative))
|
||||
gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
|
||||
template_dir_SQ = $(subst ','\'',$(template_dir))
|
||||
htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
|
||||
@@ -2163,7 +2165,7 @@ attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
|
||||
|
||||
gettext.sp gettext.s gettext.o: GIT-PREFIX
|
||||
gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
|
||||
-DGIT_LOCALE_PATH='"$(localedir_SQ)"'
|
||||
-DGIT_LOCALE_PATH='"$(localedir_relative_SQ)"'
|
||||
|
||||
http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp: SPARSE_FLAGS += \
|
||||
-DCURL_DISABLE_TYPECHECK
|
||||
|
||||
@@ -32,12 +32,12 @@ int main(int argc, const char **argv)
|
||||
*/
|
||||
sanitize_stdfds();
|
||||
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
git_setup_gettext();
|
||||
|
||||
attr_start();
|
||||
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
restore_sigpipe_to_default();
|
||||
|
||||
return cmd_main(argc, argv);
|
||||
|
||||
20
gettext.c
20
gettext.c
@@ -6,6 +6,8 @@
|
||||
#include "gettext.h"
|
||||
#include "strbuf.h"
|
||||
#include "utf8.h"
|
||||
#include "cache.h"
|
||||
#include "exec_cmd.h"
|
||||
|
||||
#ifndef NO_GETTEXT
|
||||
# include <locale.h>
|
||||
@@ -160,14 +162,22 @@ static void init_gettext_charset(const char *domain)
|
||||
void git_setup_gettext(void)
|
||||
{
|
||||
const char *podir = getenv("GIT_TEXTDOMAINDIR");
|
||||
char *p = NULL;
|
||||
|
||||
if (!podir)
|
||||
podir = GIT_LOCALE_PATH;
|
||||
bindtextdomain("git", podir);
|
||||
setlocale(LC_MESSAGES, "");
|
||||
setlocale(LC_TIME, "");
|
||||
init_gettext_charset("git");
|
||||
textdomain("git");
|
||||
if (!is_absolute_path(podir))
|
||||
podir = p = system_path(podir);
|
||||
|
||||
if (is_directory(podir)) {
|
||||
bindtextdomain("git", podir);
|
||||
setlocale(LC_MESSAGES, "");
|
||||
setlocale(LC_TIME, "");
|
||||
init_gettext_charset("git");
|
||||
textdomain("git");
|
||||
}
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
/* return the number of columns of string 's' in current locale */
|
||||
|
||||
Reference in New Issue
Block a user