Skip to content

Commit

Permalink
Use fast zpp for frequently used gettext(_)
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed May 6, 2015
1 parent 76fb021 commit 31f516b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ext/gettext/gettext.c
Expand Up @@ -186,15 +186,21 @@ PHP_NAMED_FUNCTION(zif_textdomain)
Return the translation of msgid for the current domain, or msgid unaltered if a translation does not exist */
PHP_NAMED_FUNCTION(zif_gettext)
{
char *msgid, *msgstr;
size_t msgid_len;
char *msgstr;
zend_string *msgid;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &msgid, &msgid_len) == FAILURE) {
#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &msgid) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STR(msgid)
ZEND_PARSE_PARAMETERS_END();
#endif

PHP_GETTEXT_LENGTH_CHECK("msgid", msgid_len)
msgstr = gettext(msgid);
PHP_GETTEXT_LENGTH_CHECK("msgid", msgid->len)
msgstr = gettext(msgid->val);

RETURN_STRING(msgstr);
}
Expand Down

0 comments on commit 31f516b

Please sign in to comment.