performance improvement of JsonResponse saving 2 assignments and 1 variable

This commit is contained in:
Tobias Schultze 2012-03-22 22:53:40 +01:00
parent 54ce7c75e8
commit c3483d0eb9

View File

@ -91,15 +91,15 @@ class JsonResponse extends Response
*/ */
protected function update() protected function update()
{ {
$content = $this->data;
$this->headers->set('Content-Type', 'application/json', false);
if ($this->callback) { if ($this->callback) {
$content = sprintf('%s(%s);', $this->callback, $content);
// Not using application/javascript for compatibility reasons with older browsers. // Not using application/javascript for compatibility reasons with older browsers.
$this->headers->set('Content-Type', 'text/javascript', true); $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);
} }
} }