Tim Starling has uploaded a new change for review.
https://gerrit.wikimedia.org/r/297951
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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/51/297951/1
diff --git a/includes/tidy/Balancer.php b/includes/tidy/Balancer.php
index 7f1f911..b78c030 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: newchange
Gerrit-Change-Id: Ie8ff66a836cd137234828effcce9547e2cb3cd58
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits