jenkins-bot has submitted this change and it was merged.
Change subject: Fix arguments to PegTokenizer constructor.
......................................................................
Fix arguments to PegTokenizer constructor.
The 'canCache' argument to the PegTokenizer constructor was added in
commit bf84638bc0f59c8dc703374b37626a7d63fe4c1f to avoid tokenizing the
same template multiple times when we used our native template pipeline
for everything. It rotted almost immediately; commit
8368e17d6a49d8ba028515a78ecc189632bff39b changed the second argument of
the constructor so it was an options hash, and commit
814511f523cd26a43509dbdbb2a798394cb2f60c removed the only place which
passed a boolean as the second constructor argument.
Since we don't use the caching stuff any more, this patch effectively
sets canCache = false for all PegTokenizer instances.
Change-Id: I13e0225537e7cb302305977d8ad52dc4eac84ff7
---
M js/lib/mediawiki.tokenizer.peg.js
1 file changed, 10 insertions(+), 9 deletions(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/js/lib/mediawiki.tokenizer.peg.js
b/js/lib/mediawiki.tokenizer.peg.js
index 6757544..5010642 100644
--- a/js/lib/mediawiki.tokenizer.peg.js
+++ b/js/lib/mediawiki.tokenizer.peg.js
@@ -14,10 +14,11 @@
fs = require('fs'),
events = require('events');
-function PegTokenizer( env, canCache ) {
+function PegTokenizer( env, options ) {
this.env = env;
- this.canCache = canCache;
- this.options = {};
+ this.options = options || {};
+ this.offsets = {};
+ this.canCache = this.options.canCache;
if ( this.canCache ) {
this.cacheAccum = { chunks: [] };
}
@@ -43,8 +44,8 @@
* Set start and end offsets of the source that generated this DOM
*/
PegTokenizer.prototype.setSourceOffsets = function(start, end) {
- this.options.startOffset = start;
- this.options.endOffset = end;
+ this.offsets.startOffset = start;
+ this.offsets.endOffset = end;
};
/*
@@ -140,7 +141,7 @@
}
// Kick it off!
- var srcOffset = this.options.startOffset || 0;
+ var srcOffset = this.offsets.startOffset || 0;
var args = { cb: chunkCB, pegTokenizer: this, srcOffset: srcOffset,
env: this.env };
if (fullParse) {
if ( ! this.env.conf.parsoid.debug ) {
@@ -205,8 +206,8 @@
}
// Reset source offsets
- this.options.startOffset = undefined;
- this.options.endOffset = undefined;
+ this.offsets.startOffset = undefined;
+ this.offsets.endOffset = undefined;
this.emit('end');
};
@@ -223,7 +224,7 @@
retToks = this.tokenizer.tokenize(text, production, {
cb: function(r) { toks = toks.concat(r); },
pegTokenizer: this,
- srcOffset: this.options.startOffset || 0,
+ srcOffset: this.offsets.startOffset || 0,
env: this.env
});
--
To view, visit https://gerrit.wikimedia.org/r/76646
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I13e0225537e7cb302305977d8ad52dc4eac84ff7
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits