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

Change subject: T118367: Kill dead code + fix bad perf in pathological 
scenarios.
......................................................................


T118367: Kill dead code + fix bad perf in pathological scenarios.

This code was added in fd0aefc3 (Aug 3, 2012) in the very
first draft of the template encapsulation code when nothing
but the very outlines of this technique had been dreamt up.

This code was seemlingly added to deal with fostered content from
tables (suprise!). But, given how our template wrapping works,
about tags are only assigned to the start/end meta tags and
nothing else in between. So, there was no way that a table
could exist with an about-id found on transclusion meta tags.

You can verify this by examining code in tt/TemplateHandler.js
and/or by running this:
echo "{{echo|a\n\nb\n\ncr\n\nd}}" | node parse --dump dom:pre-encap
and noticing that none of the p-tags there have an about id.

So, this code has always (or at least since almost the very
beginning) been dead, and only served to make parsing slow in
pathological cases as in the bug report.

With this dead code removed, that page parses in 17s.

Change-Id: I056169adab7f958f35c2ecb84135c61a4736e9b1
---
M lib/wt2html/pp/wrapTemplates.js
1 file changed, 1 insertion(+), 25 deletions(-)

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



diff --git a/lib/wt2html/pp/wrapTemplates.js b/lib/wt2html/pp/wrapTemplates.js
index c1357ef..7b82b41 100644
--- a/lib/wt2html/pp/wrapTemplates.js
+++ b/lib/wt2html/pp/wrapTemplates.js
@@ -782,16 +782,6 @@
        }
 }
 
-function findTableSibling(elem, about) {
-       elem = elem.nextSibling;
-       while (elem &&
-                       (!DU.hasNodeName(elem, 'table') ||
-                               elem.getAttribute('about') !== about)) {
-               elem = elem.nextSibling;
-       }
-       return elem;
-}
-
 /**
  * Recursive worker
  */
@@ -845,21 +835,7 @@
                                        }
                                } else {
                                        // elem is the end-meta tag
-                                       // check if it is followed by a table 
node
-                                       var tableNode = findTableSibling(elem, 
about);
-                                       if (tableNode) {
-                                               // found following table 
content, the end marker
-                                               // was foster-parented. Extend 
the DOM range to
-                                               // include the table.
-                                               // TODO: implement
-                                               env.log("warning/template", 
'foster-parented content following!');
-                                               if (aboutRef && aboutRef.start) 
{
-                                                       
tplRanges.push(getDOMRange(env, doc, aboutRef.start, elem, tableNode));
-                                               } else {
-                                                       
env.log("warning/template", 'found foster-parented end marker followed',
-                                                                       'by 
table, but no start marker!');
-                                               }
-                                       } else if (aboutRef) {
+                                       if (aboutRef) {
                                                /* 
------------------------------------------------------------
                                                 * Special case: In some cases, 
the entire template content can
                                                 * get fostered out of a table, 
not just the start/end marker.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I056169adab7f958f35c2ecb84135c61a4736e9b1
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: Cscott <canan...@wikimedia.org>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to