helly Mon Nov 1 07:09:50 2004 EDT
Modified files:
/php-src/ext/standard array.c php_array.h
Log:
- Use new way for global variables
- Cache class lookup
http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.278&r2=1.279&ty=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.278 php-src/ext/standard/array.c:1.279
--- php-src/ext/standard/array.c:1.278 Mon Nov 1 05:45:52 2004
+++ php-src/ext/standard/array.c Mon Nov 1 07:09:46 2004
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.278 2004/11/01 10:45:52 helly Exp $ */
+/* $Id: array.c,v 1.279 2004/11/01 12:09:46 helly Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -95,12 +95,32 @@
#define DOUBLE_DRIFT_FIX 0.000000000000001
-PHP_MINIT_FUNCTION(array)
-{
+ZEND_BEGIN_MODULE_GLOBALS(array)
+ int *multisort_flags[2];
+ int (*compare_func)(zval *result, zval *op1, zval *op2 TSRMLS_DC);
+ zend_class_entry *php_ce_countable;
+ZEND_END_MODULE_GLOBALS(array)
+
+ZEND_DECLARE_MODULE_GLOBALS(array)
+
#ifdef ZTS
- ts_allocate_id(&array_globals_id, sizeof(php_array_globals), NULL, NULL);
+#define ARRAYG(v) TSRMG(array_globals_id, zend_array_globals *, v)
+#else
+#define ARRAYG(v) (array_globals.v)
#endif
+/* {{{ php_extname_init_globals
+ */
+static void php_array_init_globals(zend_array_globals *array_globals)
+{
+ memset(array_globals, 0, sizeof(array_globals));
+}
+/* }}} */
+
+PHP_MINIT_FUNCTION(array)
+{
+ ZEND_INIT_MODULE_GLOBALS(array, php_array_init_globals, NULL);
+
REGISTER_LONG_CONSTANT("EXTR_OVERWRITE", EXTR_OVERWRITE, CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("EXTR_SKIP", EXTR_SKIP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("EXTR_PREFIX_SAME", EXTR_PREFIX_SAME, CONST_CS |
CONST_PERSISTENT);
@@ -304,10 +324,15 @@
break;
case IS_OBJECT: {
#if HAVE_SPL
- zend_class_entry **pce = NULL;
zval *retval;
+ zend_class_entry **pce;
- if (zend_lookup_class("countable", sizeof("countable")-1, &pce
TSRMLS_CC) == SUCCESS) {
+ if (!ARRAYG(php_ce_countable)) {
+ if (zend_lookup_class("countable",
sizeof("countable")-1, &pce TSRMLS_CC) == SUCCESS) {
+ ARRAYG(php_ce_countable) = *pce;
+ }
+ }
+ if (ARRAYG(php_ce_countable) &&
instanceof_function(Z_OBJCE_P(array), ARRAYG(php_ce_countable) TSRMLS_CC)) {
zend_call_method_with_0_params(&array, NULL, NULL,
"count", &retval);
RETVAL_LONG(Z_LVAL_P(retval));
zval_ptr_dtor(&retval);
http://cvs.php.net/diff.php/php-src/ext/standard/php_array.h?r1=1.47&r2=1.48&ty=u
Index: php-src/ext/standard/php_array.h
diff -u php-src/ext/standard/php_array.h:1.47 php-src/ext/standard/php_array.h:1.48
--- php-src/ext/standard/php_array.h:1.47 Wed Jul 21 17:17:56 2004
+++ php-src/ext/standard/php_array.h Mon Nov 1 07:09:46 2004
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_array.h,v 1.47 2004/07/21 21:17:56 andrey Exp $ */
+/* $Id: php_array.h,v 1.48 2004/11/01 12:09:46 helly Exp $ */
#ifndef PHP_ARRAY_H
#define PHP_ARRAY_H
@@ -102,17 +102,4 @@
PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS_DC);
int multisort_compare(const void *a, const void *b TSRMLS_DC);
-typedef struct {
- int *multisort_flags[2];
- int (*compare_func)(zval *result, zval *op1, zval *op2 TSRMLS_DC);
-} php_array_globals;
-
-#ifdef ZTS
-#define ARRAYG(v) TSRMG(array_globals_id, php_array_globals *, v)
-extern int array_globals_id;
-#else
-#define ARRAYG(v) (array_globals.v)
-extern php_array_globals array_globals;
-#endif
-
#endif /* PHP_ARRAY_H */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php