Skip to content

Commit 256c2dc

Browse files
avargitster
authored andcommitted
perl: use mock i18n functions under NO_GETTEXT=Y
Change the logic of the i18n functions I added in 5e9637c (i18n: add infrastructure for translating Git with gettext, 2011-11-18) to use pass-through functions when NO_GETTEXT is defined. This speeds up the compilation time of commands that use this library when NO_GETTEXT=Y is in effect. Loading it and POSIX.pm is around 20ms on my machine, whereas it takes 2ms to just instantiate perl itself. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 368a50d commit 256c2dc

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,7 @@ ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
19861986
ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES))
19871987

19881988
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1989+
NO_GETTEXT_SQ = $(subst ','\'',$(NO_GETTEXT))
19891990
bindir_SQ = $(subst ','\'',$(bindir))
19901991
bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
19911992
mandir_SQ = $(subst ','\'',$(mandir))
@@ -2276,6 +2277,7 @@ PERL_DEFINES += $(PERLLIB_EXTRA_SQ)
22762277
PERL_DEFINES += $(perllibdir_SQ)
22772278
PERL_DEFINES += $(RUNTIME_PREFIX)
22782279
PERL_DEFINES += $(NO_PERL_CPAN_FALLBACKS)
2280+
PERL_DEFINES += $(NO_GETTEXT)
22792281

22802282
# Support Perl runtime prefix. In this mode, a different header is installed
22812283
# into Perl scripts.
@@ -2680,6 +2682,7 @@ endif
26802682
perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES
26812683
$(QUIET_GEN)mkdir -p $(dir $@) && \
26822684
sed -e 's|@@LOCALEDIR@@|$(perl_localedir_SQ)|g' \
2685+
-e 's|@@NO_GETTEXT@@|$(NO_GETTEXT_SQ)|g' \
26832686
-e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
26842687
< $< > $@
26852688

perl/Git/I18N.pm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,19 @@ BEGIN {
1616
our @EXPORT = qw(__ __n N__);
1717
our @EXPORT_OK = @EXPORT;
1818

19+
# See Git::LoadCPAN's NO_PERL_CPAN_FALLBACKS_STR for a description of
20+
# this "'@@' [...] '@@'" pattern.
21+
use constant NO_GETTEXT_STR => '@@' . 'NO_GETTEXT' . '@@';
22+
use constant NO_GETTEXT => (
23+
q[@@NO_GETTEXT@@] ne ''
24+
and
25+
q[@@NO_GETTEXT@@] ne NO_GETTEXT_STR
26+
);
27+
1928
sub __bootstrap_locale_messages {
2029
our $TEXTDOMAIN = 'git';
2130
our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@';
31+
die "NO_GETTEXT=" . NO_GETTEXT_STR if NO_GETTEXT;
2232

2333
require POSIX;
2434
POSIX->import(qw(setlocale));

0 commit comments

Comments
 (0)