From 7c502e3e4eda7619be7fc071496912a1fb1aadfb Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 10 May 2013 05:39:44 -0700 Subject: [PATCH] Fix performance issue with large changesets in Differential Summary: Fixes T3151. Javelin treats a behavior without parameters as a global behavior and invokes it only once no matter how many times it is initialized (this is necessarily correct for any reasonable behavior, as the inputs do not vary). A recent patch changed `differential-dropdown-menus` from a zero-argument global behavior to an implicitly nonzero-argument behavior by adding `pht`. Currently, we initialize the behavior next to dropdown menu creation, so this resulted in `O(N^2)` initializations of the menus. For large diffs, this locks browsers. Instead, initialize outside of the dropdown loop so we ginitialize each menu just once. Test Plan: Viewed a 2,000 file diff without browser lock. Reviewers: wez, vrana, btrahan Reviewed By: wez CC: aran Maniphest Tasks: T3151 Differential Revision: https://secure.phabricator.com/D5885 --- .../differential/view/DifferentialChangesetListView.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/applications/differential/view/DifferentialChangesetListView.php b/src/applications/differential/view/DifferentialChangesetListView.php index f72733b769..dcd080dfe8 100644 --- a/src/applications/differential/view/DifferentialChangesetListView.php +++ b/src/applications/differential/view/DifferentialChangesetListView.php @@ -108,6 +108,9 @@ final class DifferentialChangesetListView extends AphrontView { $changesets = $this->changesets; Javelin::initBehavior('differential-toggle-files', array()); + Javelin::initBehavior( + 'differential-dropdown-menus', + array()); $output = array(); $mapping = array(); @@ -304,10 +307,6 @@ final class DifferentialChangesetListView extends AphrontView { $meta['containerID'] = $detail->getID(); - Javelin::initBehavior( - 'differential-dropdown-menus', - array()); - return javelin_tag( 'a', array(