Преглед на файлове

[Serializer] minor optimization

Jordi Boggiano преди 14 години
родител
ревизия
457dc105bc
променени са 1 файла, в които са добавени 4 реда и са изтрити 4 реда
  1. 4 4
      src/Symfony/Component/Serializer/Serializer.php

+ 4 - 4
src/Symfony/Component/Serializer/Serializer.php

@@ -41,10 +41,10 @@ class Serializer implements SerializerInterface
      */
     public function serialize($data, $format)
     {
-        if (!$this->hasEncoder($format)) {
+        if (!isset($this->encoders[$format])) {
             throw new \UnexpectedValueException('No encoder registered for the '.$format.' format');
         }
-        if (!$this->getEncoder($format) instanceof NormalizationAwareInterface) {
+        if (!$this->encoders[$format] instanceof NormalizationAwareInterface) {
             $data = $this->normalize($data);
         }
         return $this->encode($data, $format);
@@ -138,7 +138,7 @@ class Serializer implements SerializerInterface
      */
     public function encode($data, $format)
     {
-        if (!$this->hasEncoder($format)) {
+        if (!isset($this->encoders[$format])) {
             throw new \UnexpectedValueException('No encoder registered for the '.$format.' format');
         }
         return $this->encoders[$format]->encode($data, $format);
@@ -149,7 +149,7 @@ class Serializer implements SerializerInterface
      */
     public function decode($data, $format)
     {
-        if (!$this->hasDecoder($format)) {
+        if (!isset($this->decoders[$format])) {
             throw new \UnexpectedValueException('No decoder registered for the '.$format.' format');
         }
         return $this->decoders[$format]->decode($data, $format);