dmitry                                   Thu, 05 Aug 2010 13:10:15 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=301876

Log:
Use interned strings for class names

Changed paths:
    U   php/php-src/trunk/Zend/zend_API.h
    U   php/php-src/trunk/Zend/zend_compile.c
    U   php/php-src/trunk/Zend/zend_iterators.c
    U   php/php-src/trunk/Zend/zend_opcode.c

Modified: php/php-src/trunk/Zend/zend_API.h
===================================================================
--- php/php-src/trunk/Zend/zend_API.h   2010-08-05 12:29:40 UTC (rev 301875)
+++ php/php-src/trunk/Zend/zend_API.h   2010-08-05 13:10:15 UTC (rev 301876)
@@ -167,7 +167,10 @@
 #define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, 
class_name_len, functions, handle_fcall, handle_propget, handle_propset, 
handle_propunset, handle_propisset) \
        {                                                                       
                                                \
                int _len = class_name_len;                                      
                        \
-               class_container.name = zend_strndup(class_name, _len);  \
+               class_container.name = zend_new_interned_string(class_name, 
_len+1, 0); \
+               if (class_container.name == class_name) {                       
        \
+                       class_container.name = zend_strndup(class_name, _len);  
\
+               }                                                               
                                                \
                class_container.name_length = _len;                             
                \
                class_container.builtin_functions = functions;                  
\
                class_container.constructor = NULL;                             
                \

Modified: php/php-src/trunk/Zend/zend_compile.c
===================================================================
--- php/php-src/trunk/Zend/zend_compile.c       2010-08-05 12:29:40 UTC (rev 
301875)
+++ php/php-src/trunk/Zend/zend_compile.c       2010-08-05 13:10:15 UTC (rev 
301876)
@@ -4486,8 +4486,8 @@

        new_class_entry = emalloc(sizeof(zend_class_entry));
        new_class_entry->type = ZEND_USER_CLASS;
-       new_class_entry->name = class_name->u.constant.value.str.val;
-       new_class_entry->name_length = class_name->u.constant.value.str.len;
+       new_class_entry->name = 
zend_new_interned_string(Z_STRVAL(class_name->u.constant), 
Z_STRLEN(class_name->u.constant) + 1, 1 TSRMLS_CC);
+       new_class_entry->name_length = Z_STRLEN(class_name->u.constant);

        zend_initialize_class_data(new_class_entry, 1 TSRMLS_CC);
        new_class_entry->filename = zend_get_compiled_filename(TSRMLS_C);

Modified: php/php-src/trunk/Zend/zend_iterators.c
===================================================================
--- php/php-src/trunk/Zend/zend_iterators.c     2010-08-05 12:29:40 UTC (rev 
301875)
+++ php/php-src/trunk/Zend/zend_iterators.c     2010-08-05 13:10:15 UTC (rev 
301876)
@@ -51,8 +51,6 @@
 ZEND_API void zend_register_iterator_wrapper(TSRMLS_D)
 {
        INIT_CLASS_ENTRY(zend_iterator_class_entry, "__iterator_wrapper", NULL);
-       free(zend_iterator_class_entry.name);
-       zend_iterator_class_entry.name = "__iterator_wrapper";
 }

 static void iter_wrapper_dtor(void *object, zend_object_handle handle 
TSRMLS_DC)

Modified: php/php-src/trunk/Zend/zend_opcode.c
===================================================================
--- php/php-src/trunk/Zend/zend_opcode.c        2010-08-05 12:29:40 UTC (rev 
301875)
+++ php/php-src/trunk/Zend/zend_opcode.c        2010-08-05 13:10:15 UTC (rev 
301876)
@@ -301,7 +301,9 @@
                                efree(ce->default_static_members_table);
                        }
                        zend_hash_destroy(&ce->properties_info);
-                       efree(ce->name);
+                       if (!IS_INTERNED(ce->name)) {
+                               efree(ce->name);
+                       }
                        zend_hash_destroy(&ce->function_table);
                        zend_hash_destroy(&ce->constants_table);
                        if (ce->num_interfaces > 0 && ce->interfaces) {
@@ -335,7 +337,9 @@
                                free(ce->default_static_members_table);
                        }
                        zend_hash_destroy(&ce->properties_info);
-                       free(ce->name);
+                       if (!IS_INTERNED(ce->name)) {
+                               free(ce->name);
+                       }
                        zend_hash_destroy(&ce->function_table);
                        zend_hash_destroy(&ce->constants_table);
                        if (ce->num_interfaces > 0) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to