From 6341ee8fa626b75372a70ff0203399a29d219e5f Mon Sep 17 00:00:00 2001 From: Reedy Date: Sun, 14 Apr 2019 16:02:53 +0100 Subject: [PATCH] Move SectionProfileCallback to its own file Change-Id: Iccb2048eed6631caa4f20639f55866e76f9fabf0 --- .phpcs.xml | 1 - autoload.php | 2 +- includes/profiler/SectionProfileCallback.php | 48 ++++++++++++++++++++ includes/profiler/SectionProfiler.php | 26 ----------- 4 files changed, 49 insertions(+), 28 deletions(-) create mode 100644 includes/profiler/SectionProfileCallback.php diff --git a/.phpcs.xml b/.phpcs.xml index 86d37ad52f..f08ed80a69 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -214,7 +214,6 @@ */includes/parser/Preprocessor_DOM\.php */includes/parser/Preprocessor_Hash\.php */includes/parser/Preprocessor\.php - */includes/profiler/SectionProfiler\.php */includes/utils/AutoloadGenerator\.php */maintenance/dumpIterator\.php */maintenance/Maintenance\.php diff --git a/autoload.php b/autoload.php index 139f8d57d4..f70dd5cadc 100644 --- a/autoload.php +++ b/autoload.php @@ -1316,7 +1316,7 @@ $wgAutoloadLocalClasses = [ 'SearchSuggestion' => __DIR__ . '/includes/search/SearchSuggestion.php', 'SearchSuggestionSet' => __DIR__ . '/includes/search/SearchSuggestionSet.php', 'SearchUpdate' => __DIR__ . '/includes/deferred/SearchUpdate.php', - 'SectionProfileCallback' => __DIR__ . '/includes/profiler/SectionProfiler.php', + 'SectionProfileCallback' => __DIR__ . '/includes/profiler/SectionProfileCallback.php', 'SectionProfiler' => __DIR__ . '/includes/profiler/SectionProfiler.php', 'SevenZipStream' => __DIR__ . '/maintenance/7zip.inc', 'ShiConverter' => __DIR__ . '/languages/classes/LanguageShi.php', diff --git a/includes/profiler/SectionProfileCallback.php b/includes/profiler/SectionProfileCallback.php new file mode 100644 index 0000000000..4c25c507f1 --- /dev/null +++ b/includes/profiler/SectionProfileCallback.php @@ -0,0 +1,48 @@ +profiler = $profiler; + $this->section = $section; + } + + function __destruct() { + $this->profiler->profileOutInternal( $this->section ); + } +} diff --git a/includes/profiler/SectionProfiler.php b/includes/profiler/SectionProfiler.php index b00401d9bf..c27ab4f3f4 100644 --- a/includes/profiler/SectionProfiler.php +++ b/includes/profiler/SectionProfiler.php @@ -496,29 +496,3 @@ class SectionProfiler { } } } - -/** - * Subclass ScopedCallback to avoid call_user_func_array(), which is slow - * - * This class should not be used outside of SectionProfiler - */ -class SectionProfileCallback extends ScopedCallback { - /** @var SectionProfiler */ - protected $profiler; - /** @var string */ - protected $section; - - /** - * @param SectionProfiler $profiler - * @param string $section - */ - public function __construct( SectionProfiler $profiler, $section ) { - parent::__construct( null ); - $this->profiler = $profiler; - $this->section = $section; - } - - function __destruct() { - $this->profiler->profileOutInternal( $this->section ); - } -} -- 2.20.1