From: Father Chrysostomos Date: Thu, 6 Dec 2012 02:27:18 +0000 (-0800) Subject: Fewer strEQ calls in toke.c:S_new_constant X-Git-Tag: upstream/5.20.0~4575 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f374c70f2f466935df480e5b2a9b1853fd86aa9d;p=platform%2Fupstream%2Fperl.git Fewer strEQ calls in toke.c:S_new_constant There is a small fixed number of keys that can be passed to this static function: charnames binary float integer q qr In a few places, we check whether the key is "charnames". It would be quicker just to check the first character, since, if it is 'c', the key must be "charnames". (Under debugging builds, assert that that assumption is true.) --- diff --git a/toke.c b/toke.c index 86bb994..bb81b4a 100644 --- a/toke.c +++ b/toke.c @@ -9030,9 +9030,11 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, STRLEN keylen, const char *why1 = "", *why2 = "", *why3 = ""; PERL_ARGS_ASSERT_NEW_CONSTANT; + /* We assume that this is true: */ + if (*key == 'c') { assert (strEQ(key, "charnames")); } /* charnames doesn't work well if there have been errors found */ - if (PL_error_count > 0 && strEQ(key,"charnames")) + if (PL_error_count > 0 && *key == 'c') { SvREFCNT_dec_NN(sv); return &PL_sv_undef; @@ -9047,7 +9049,7 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, STRLEN keylen, /* Here haven't found what we're looking for. If it is charnames, * perhaps it needs to be loaded. Try doing that before giving up */ - if (strEQ(key,"charnames")) { + if (*key == 'c') { Perl_load_module(aTHX_ 0, newSVpvs("_charnames"), @@ -9077,7 +9079,7 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, STRLEN keylen, why2 = key; why3 = "} is not defined"; report: - if (strEQ(key,"charnames")) { + if (*key == 'c') { yyerror_pv(Perl_form(aTHX_ /* The +3 is for '\N{'; -4 for that, plus '}' */ "Unknown charname '%.*s'", (int)typelen - 4, type + 3