stas Tue Dec 5 02:51:25 2006 UTC
Modified files:
/ZendEngine2 zend_operators.c zend_operators.h
Log:
Merge from 5.2:
Improve tolower()-related functions on Windows and VC2005 by caching locale
and using
tolower_l function.
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.c?r1=1.259&r2=1.260&diff_format=u
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.259 ZendEngine2/zend_operators.c:1.260
--- ZendEngine2/zend_operators.c:1.259 Wed Nov 15 17:28:56 2006
+++ ZendEngine2/zend_operators.c Tue Dec 5 02:51:25 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.c,v 1.259 2006/11/15 17:28:56 tony2001 Exp $ */
+/* $Id: zend_operators.c,v 1.260 2006/12/05 02:51:25 stas Exp $ */
#include <ctype.h>
@@ -35,6 +35,15 @@
#define LONG_SIGN_MASK (1L << (8*sizeof(long)-1))
+#if ZEND_USE_TOLOWER_L
+#include <locale.h>
+static _locale_t current_locale = NULL;
+/* this is true global! may lead to strange effects on ZTS, but so may
setlocale() */
+#define zend_tolower(c) _tolower_l(c, current_locale)
+#else
+#define zend_tolower(c) tolower(c)
+#endif
+
ZEND_API int zend_atoi(const char *str, int str_len)
{
int retval;
@@ -2331,6 +2340,13 @@
return (Z_LVAL_P(op) ? 1 : 0);
}
+#ifdef ZEND_USE_TOLOWER_L
+ZEND_API void zend_update_current_locale()
+{
+ current_locale = _get_current_locale();
+}
+#endif
+
ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned
int length)
{
register unsigned char *str = (unsigned char*)source;
@@ -2338,7 +2354,7 @@
register unsigned char *end = str + length;
while (str < end) {
- *result++ = tolower((int)*str++);
+ *result++ = zend_tolower((int)*str++);
}
*result = '\0';
@@ -2390,7 +2406,7 @@
register unsigned char *end = p + length;
while (p < end) {
- *p = tolower((int)*p);
+ *p = zend_tolower((int)*p);
p++;
}
}
@@ -2503,8 +2519,8 @@
len = MIN(len1, len2);
while (len--) {
- c1 = tolower((int)*(unsigned char *)s1++);
- c2 = tolower((int)*(unsigned char *)s2++);
+ c1 = zend_tolower((int)*(unsigned char *)s1++);
+ c2 = zend_tolower((int)*(unsigned char *)s2++);
if (c1 != c2) {
return c1 - c2;
}
@@ -2530,8 +2546,8 @@
len = MIN(length, MIN(len1, len2));
while (len--) {
- c1 = tolower((int)*(unsigned char *)s1++);
- c2 = tolower((int)*(unsigned char *)s2++);
+ c1 = zend_tolower((int)*(unsigned char *)s1++);
+ c2 = zend_tolower((int)*(unsigned char *)s2++);
if (c1 != c2) {
return c1 - c2;
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.h?r1=1.113&r2=1.114&diff_format=u
Index: ZendEngine2/zend_operators.h
diff -u ZendEngine2/zend_operators.h:1.113 ZendEngine2/zend_operators.h:1.114
--- ZendEngine2/zend_operators.h:1.113 Fri Sep 8 17:19:42 2006
+++ ZendEngine2/zend_operators.h Tue Dec 5 02:51:25 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.h,v 1.113 2006/09/08 17:19:42 andrei Exp $ */
+/* $Id: zend_operators.h,v 1.114 2006/12/05 02:51:25 stas Exp $ */
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H
@@ -451,6 +451,19 @@
#define Z_TYPE_P(zval_p) Z_TYPE(*zval_p)
#define Z_TYPE_PP(zval_pp) Z_TYPE(**zval_pp)
+#if HAVE_SETLOCALE && defined(ZEND_WIN32) && !defined(ZTS) &&
defined(_MSC_VER) && (_MSC_VER >= 1400)
+/* This is performance improvement of tolower() on Windows and VC2005
+ * Gives 10-18% on bench.php
+ */
+#define ZEND_USE_TOLOWER_L 1
+#endif
+
+#ifdef ZEND_USE_TOLOWER_L
+ZEND_API void zend_update_current_locale();
+#else
+#define zend_update_current_locale()
+#endif
+
#endif
/*
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|