diff options
author | Dmitry Stogov <dmitry@php.net> | 2008-04-29 08:15:20 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2008-04-29 08:15:20 +0000 |
commit | 2ecf4bb0a7c66bc882ff82d66d86ac6be5bffdf7 (patch) | |
tree | 128afacc2d1cf3234b0f59dccb3bf63633f0c7e7 /Zend/zend_execute_API.c | |
parent | c75658c477cead4cb7c4a9ae6a72c6d8a1d98cee (diff) | |
download | php-git-2ecf4bb0a7c66bc882ff82d66d86ac6be5bffdf7.tar.gz |
Lazy EG(active_symbol_table) initialization
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 74ffc1c56c..c11673f27a 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1777,12 +1777,49 @@ ZEND_API int zend_delete_global_variable(char *name, int name_len TSRMLS_DC) /* } } } - return zend_hash_del(&EG(symbol_table), name, name_len + 1); + return zend_hash_quick_del(&EG(symbol_table), name, name_len + 1, hash_value); } return FAILURE; } /* }}} */ +ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */ +{ + zend_uint i; + + if (!EG(active_symbol_table)) { + if (EG(symtable_cache_ptr)>=EG(symtable_cache)) { + /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/ + EG(active_symbol_table) = *(EG(symtable_cache_ptr)--); + } else { + ALLOC_HASHTABLE(EG(active_symbol_table)); + zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); + /*printf("Cache miss! Initialized %x\n", EG(active_symbol_table));*/ + } + if (EG(current_execute_data) && EG(current_execute_data)->op_array) { + EG(current_execute_data)->symbol_table = EG(active_symbol_table); + if (EG(current_execute_data)->op_array->uses_this && EG(This)) { + Z_ADDREF_P(EG(This)); /* For $this pointer */ + if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), NULL)==FAILURE) { + Z_DELREF_P(EG(This)); + } + } + for (i = 0; i < EG(current_execute_data)->op_array->last_var; i++) { + if (EG(current_execute_data)->CVs[i]) { + zend_hash_quick_update(EG(active_symbol_table), + EG(current_execute_data)->op_array->vars[i].name, + EG(current_execute_data)->op_array->vars[i].name_len + 1, + EG(current_execute_data)->op_array->vars[i].hash_value, + (void**)EG(current_execute_data)->CVs[i], + sizeof(zval*), + (void**)&EG(current_execute_data)->CVs[i]); + } + } + } + } +} +/* }}} */ + /* * Local variables: * tab-width: 4 |