jenkins-bot has submitted this change and it was merged.

Change subject: Balancer: Inline BalancerStack::length()
......................................................................


Balancer: Inline BalancerStack::length()

Provides 1% reduction in benchmark time

Change-Id: Ie8ff66a836cd137234828effcce9547e2cb3cd58
---
M includes/tidy/Balancer.php
1 file changed, 6 insertions(+), 5 deletions(-)

Approvals:
  Cscott: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/tidy/Balancer.php b/includes/tidy/Balancer.php
index 6f7afff..9e96b14 100644
--- a/includes/tidy/Balancer.php
+++ b/includes/tidy/Balancer.php
@@ -813,7 +813,7 @@
                $endTagSet = $thorough ?
                        BalanceSets::$thoroughImpliedEndTagsSet :
                        BalanceSets::$impliedEndTagsSet;
-               while ( $this->length() > 0 ) {
+               while ( $this->currentNode ) {
                        if ( $butnot !== null && 
$this->currentNode->isHtmlNamed( $butnot ) ) {
                                break;
                        }
@@ -828,7 +828,7 @@
         * Return the adjusted current node.
         */
        public function adjustedCurrentNode( $fragmentContext ) {
-               return ( $fragmentContext && $this->length() === 1 ) ?
+               return ( $fragmentContext && count( $this->elements ) === 1 ) ?
                        $fragmentContext : $this->currentNode;
        }
 
@@ -916,7 +916,8 @@
         * @param int $idx
         */
        public function popTo( $idx ) {
-               while ( $this->length() > $idx ) {
+               $length = count( $this->elements );
+               for ( $length = count( $this->elements ); $length > $idx; 
$length-- ) {
                        $this->pop();
                }
        }
@@ -928,7 +929,7 @@
         * @param BalanceElement|array|string $tag
         */
        public function popTag( $tag ) {
-               while ( $this->length() > 0 ) {
+               while ( $this->currentNode ) {
                        if ( $this->currentNode->isA( $tag ) ) {
                                $this->pop();
                                break;
@@ -944,7 +945,7 @@
         */
        public function clearToContext( $set ) {
                // Note that we don't loop to 0. Never pop the <html> elt off.
-               while ( $this->length() > 1 ) {
+               for ( $length = count( $this->elements ); $length > 1; 
$length-- ) {
                        if ( $this->currentNode->isA( $set ) ) {
                                break;
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/297951
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie8ff66a836cd137234828effcce9547e2cb3cd58
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to