Merge "Update README from [[mw:README]]"
[lhc/web/wiklou.git] / includes / profiler / SectionProfiler.php
index 275e986..2c36b68 100644 (file)
@@ -46,6 +46,8 @@ class SectionProfiler {
        protected $collateOnly = true;
        /** @var array Cache of a standard broken collation entry */
        protected $errorEntry;
+       /** @var callable Cache of a profile out callback */
+       protected $profileOutCallback;
 
        /**
         * @param array $params
@@ -53,6 +55,9 @@ class SectionProfiler {
        public function __construct( array $params = array() ) {
                $this->errorEntry = $this->getErrorEntry();
                $this->collateOnly = empty( $params['trace'] );
+               $this->profileOutCallback = function ( $profiler, $section ) {
+                       $profiler->profileOutInternal( $section );
+               };
        }
 
        /**
@@ -63,9 +68,7 @@ class SectionProfiler {
                $this->profileInInternal( $section );
 
                $that = $this;
-               return new ScopedCallback( function () use ( $that, $section ) {
-                       $that->profileOutInternal( $section );
-               } );
+               return new ScopedCallback( $this->profileOutCallback, array( $that, $section ) );
        }
 
        /**