Permalink
Browse files

performance improvement of JsonResponse saving 2 assignments and 1 va…

…riable
  • Loading branch information...
1 parent 54ce7c7 commit c3483d0eb987250eb891334190c0862259eaf2b4 @Tobion Tobion committed Mar 22, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/Symfony/Component/HttpFoundation/JsonResponse.php
@@ -91,15 +91,15 @@ public function setData($data = array())
*/
protected function update()
{
- $content = $this->data;
- $this->headers->set('Content-Type', 'application/json', false);
-
if ($this->callback) {
- $content = sprintf('%s(%s);', $this->callback, $content);
// Not using application/javascript for compatibility reasons with older browsers.
$this->headers->set('Content-Type', 'text/javascript', true);
+
+ return $this->setContent(sprintf('%s(%s);', $this->callback, $this->data));
}
- return $this->setContent($content);
+ $this->headers->set('Content-Type', 'application/json', false);
+
+ return $this->setContent($this->data);
}
}

0 comments on commit c3483d0

Please sign in to comment.