r105864 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105863‎ | r105864 | r105865 >
Date:10:47, 12 December 2011
Author:gwicke
Status:deferred (Comments)
Tags:
Comment:
Don't re-build the wiki tokenizer for each test. This speeds up the full
parserTests.js run slightly from 7-8 minutes to about 14 seconds ;)

A few very minor tweaks to the grammar are also thrown into this commit.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt (modified) (history)
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -347,7 +347,9 @@
348348 failOutputTests = 0;
349349
350350 var postProcessor = new DOMPostProcessor();
 351+
351352 function processTest(item) {
 353+ // Create a new tree builder, which also creates a new document.
352354 var treeBuilder = new FauxHTML5.TreeBuilder();
353355 if (!('title' in item)) {
354356 console.log(item);
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js
@@ -15,8 +15,10 @@
1616 this.initSource(function() {
1717 var out, err;
1818 try {
19 - var parser = PEG.buildParser(PegTokenizer.src);
20 - out = parser.parse(text);
 19+ if ( !this.parser ) {
 20+ this.parser = PEG.buildParser(PegTokenizer.src);
 21+ }
 22+ out = this.parser.parse(text);
2123 } catch (e) {
2224 err = e;
2325 console.trace();
Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
@@ -14,6 +14,9 @@
1515
1616 // Flatten a list of lists.
1717 var flatten = function ( e ) {
 18+ // Fast single-level flatten:
 19+ //return [].concat.apply([], e);
 20+
1821 var es = [];
1922 // flatten sub-arrays
2023 for(var i = 0, length = e.length; i < length; i++) {
@@ -1016,15 +1019,16 @@
10171020 }
10181021
10191022 // http://dev.w3.org/html5/spec/Overview.html#attributes-0, and we also
1020 -// disallow newlines and |.
 1023+// disallow newlines, | and {.
10211024 generic_attribute_name
1022 - = n:[^ \t\0/"'>=\n|]+ {
 1025+ = n:[^ \t\0/"'>=\n|{]+ {
10231026 return n.join('');
10241027 }
10251028
10261029 generic_attribute_value
10271030 = "=" space* v:att_value {return v}
10281031
 1032+// XXX: attributes can contain templates and template args!!
10291033 att_value
10301034 = t:[^ \t'"<>='\n]+ { return t.join(''); }
10311035 // XXX: is "\"" also valid html? or just Wikitext?

Comments

#Comment by Hashar (talk | contribs)   10:54, 12 December 2011

Wonderfull! down to less than 10sec on my comp, and 4.3sec with --cache \o/

Status & tagging log