sesser          Sat Jan 15 13:18:09 2005 EDT

  Modified files:              
    /php-src/ext/standard       php_var.h var_unserializer.c 
                                var_unserializer.re 
  Log:
  Restore unserialize() speed
  
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/php_var.h?r1=1.28&r2=1.29&ty=u
Index: php-src/ext/standard/php_var.h
diff -u php-src/ext/standard/php_var.h:1.28 php-src/ext/standard/php_var.h:1.29
--- php-src/ext/standard/php_var.h:1.28 Sun Sep  5 12:29:04 2004
+++ php-src/ext/standard/php_var.h      Sat Jan 15 13:18:08 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_var.h,v 1.28 2004/09/05 16:29:04 helly Exp $ */
+/* $Id: php_var.h,v 1.29 2005/01/15 18:18:08 sesser Exp $ */
 
 #ifndef PHP_VAR_H
 #define PHP_VAR_H
@@ -41,6 +41,7 @@
 
 struct php_unserialize_data {
        void *first;
+       void *first_dtor;
 };
 
 typedef struct php_unserialize_data php_unserialize_data_t;
@@ -54,7 +55,8 @@
    zend_hash_destroy(&(var_hash))
 
 #define PHP_VAR_UNSERIALIZE_INIT(var_hash) \
-       (var_hash).first = 0
+       (var_hash).first = 0; \
+       (var_hash).first_dtor = 0
 #define PHP_VAR_UNSERIALIZE_DESTROY(var_hash) \
        var_destroy(&(var_hash))
 
http://cvs.php.net/diff.php/php-src/ext/standard/var_unserializer.c?r1=1.46&r2=1.47&ty=u
Index: php-src/ext/standard/var_unserializer.c
diff -u php-src/ext/standard/var_unserializer.c:1.46 
php-src/ext/standard/var_unserializer.c:1.47
--- php-src/ext/standard/var_unserializer.c:1.46        Fri Dec  3 11:02:48 2004
+++ php-src/ext/standard/var_unserializer.c     Sat Jan 15 13:18:08 2005
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: var_unserializer.c,v 1.46 2004/12/03 16:02:48 sesser Exp $ */
+/* $Id: var_unserializer.c,v 1.47 2005/01/15 18:18:08 sesser Exp $ */
 
 #include "php.h"
 #include "ext/standard/php_var.h"
@@ -56,6 +56,30 @@
        var_hash->data[var_hash->used_slots++] = *rval;
 }
 
+static inline void var_push_dtor(php_unserialize_data_t *var_hashx, zval 
**rval)
+{
+       var_entries *var_hash = var_hashx->first_dtor, *prev = NULL;
+
+       while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) {
+               prev = var_hash;
+               var_hash = var_hash->next;
+       }
+
+       if (!var_hash) {
+               var_hash = emalloc(sizeof(var_entries));
+               var_hash->used_slots = 0;
+               var_hash->next = 0;
+
+               if (!var_hashx->first_dtor)
+                       var_hashx->first_dtor = var_hash;
+               else
+                       prev->next = var_hash;
+       }
+
+       (*rval)->refcount++;
+       var_hash->data[var_hash->used_slots++] = *rval;
+}
+
 PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval 
**nzval)
 {
        int i;
@@ -93,6 +117,7 @@
 PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
 {
        void *next;
+       int i;
        var_entries *var_hash = var_hashx->first;
        
        while (var_hash) {
@@ -100,6 +125,17 @@
                efree(var_hash);
                var_hash = next;
        }
+       
+       var_hash = var_hashx->first_dtor;
+       
+       while (var_hash) {
+               for (i = 0; i < var_hash->used_slots; i++) {
+                       zval_ptr_dtor(&var_hash->data[i]);
+               }
+               next = var_hash->next;
+               efree(var_hash);
+               var_hash = next;
+       }
 }
 
 /* }}} */
http://cvs.php.net/diff.php/php-src/ext/standard/var_unserializer.re?r1=1.35&r2=1.36&ty=u
Index: php-src/ext/standard/var_unserializer.re
diff -u php-src/ext/standard/var_unserializer.re:1.35 
php-src/ext/standard/var_unserializer.re:1.36
--- php-src/ext/standard/var_unserializer.re:1.35       Fri Dec  3 11:02:48 2004
+++ php-src/ext/standard/var_unserializer.re    Sat Jan 15 13:18:08 2005
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: var_unserializer.re,v 1.35 2004/12/03 16:02:48 sesser Exp $ */
+/* $Id: var_unserializer.re,v 1.36 2005/01/15 18:18:08 sesser Exp $ */
 
 #include "php.h"
 #include "ext/standard/php_var.h"
@@ -54,6 +54,30 @@
        var_hash->data[var_hash->used_slots++] = *rval;
 }
 
+static inline void var_push_dtor(php_unserialize_data_t *var_hashx, zval 
**rval)
+{
+       var_entries *var_hash = var_hashx->first_dtor, *prev = NULL;
+
+       while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) {
+               prev = var_hash;
+               var_hash = var_hash->next;
+       }
+
+       if (!var_hash) {
+               var_hash = emalloc(sizeof(var_entries));
+               var_hash->used_slots = 0;
+               var_hash->next = 0;
+
+               if (!var_hashx->first_dtor)
+                       var_hashx->first_dtor = var_hash;
+               else
+                       prev->next = var_hash;
+       }
+
+       (*rval)->refcount++;
+       var_hash->data[var_hash->used_slots++] = *rval;
+}
+
 PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval 
**nzval)
 {
        int i;
@@ -91,6 +115,7 @@
 PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
 {
        void *next;
+       int i;
        var_entries *var_hash = var_hashx->first;
        
        while (var_hash) {
@@ -98,6 +123,17 @@
                efree(var_hash);
                var_hash = next;
        }
+
+       var_hash = var_hashx->first_dtor;
+       
+       while (var_hash) {
+               for (i = 0; i < var_hash->used_slots; i++) {
+                       zval_ptr_dtor(&var_hash->data[i]);
+               }
+               next = var_hash->next;
+               efree(var_hash);
+               var_hash = next;
+       }
 }
 
 /* }}} */

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

Reply via email to