ソースを参照

ZF-10487: AMF3 serialization performance

- Applied patch Amf.perform.ref-writeString-1.10.5.patch
- Also applied spl_object_hash() improvements as suggested in comments

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23682 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 15 年 前
コミット
9a5105120c
1 ファイル変更10 行追加5 行削除
  1. 10 5
      library/Zend/Amf/Parse/Amf3/Serializer.php

+ 10 - 5
library/Zend/Amf/Parse/Amf3/Serializer.php

@@ -236,9 +236,11 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
             return $this;
             return $this;
         }
         }
 
 
-        $ref = array_search($string, $this->_referenceStrings, true);
-        if($ref === false){
-            $this->_referenceStrings[] = $string;
+        $ref = array_key_exists($string, $this->_referenceStrings) 
+             ? $this->_referenceStrings[$string] 
+             : false;
+        if ($ref === false){
+            $this->_referenceStrings[$string] = count($this->_referenceStrings);
             $this->writeBinaryString($string);
             $this->writeBinaryString($string);
         } else {
         } else {
             $ref <<= 1;
             $ref <<= 1;
@@ -386,7 +388,10 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
             $object = &$objectByVal;
             $object = &$objectByVal;
         }
         }
 
 
-        $ref = array_search($object, $this->_referenceObjects,true);
+        $hash = spl_object_hash($object);
+        $ref = array_key_exists($hash, $this->_referenceObjects) 
+             ? $this->_referenceObjects[$hash] 
+             : false;
 
 
         // quickly handle object references
         // quickly handle object references
         if ($ref !== false){
         if ($ref !== false){
@@ -394,7 +399,7 @@ class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer
             $this->writeInteger($ref);
             $this->writeInteger($ref);
             return true;
             return true;
         }
         }
-        $this->_referenceObjects[] = $object;
+        $this->_referenceObjects[$hash] = count($this->_referenceObjects);
         return false;
         return false;
     }
     }