From 9d0d1ac42f8a49c4e561d19e5c4111a9a7f8780b Mon Sep 17 00:00:00 2001 From: Jacob Hurwitz Date: Fri, 9 May 2014 18:06:29 -0700 Subject: [PATCH] Speed up DiffusionBrowseFileController by removing call to array_merge Summary: Some profiling using XHProf in the Dark Console showed me that Diffusion was wasting a ton of time on array_merge. This change sped up the loading of a large file in Diffusion from 16.8 seconds to 2.4 seconds. Test Plan: Load files in Diffusion. They all look good. Also, use a PHP shell to try to manually verify that I still kinda remember some PHP and, yes, this is functionally equivalent to what was there before. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9032 --- .../diffusion/controller/DiffusionBrowseFileController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/DiffusionBrowseFileController.php index 91c2577e16..a9f7439c84 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseFileController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseFileController.php @@ -800,10 +800,13 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController { ), $blame); - $rows = array_merge($rows, $this->renderInlines( + $cur_inlines = $this->renderInlines( idx($inlines, $line['line'], array()), ($show_blame), - $engine)); + $engine); + foreach ($cur_inlines as $cur_inline) { + $rows[] = $cur_inline; + } } return $rows;