diff --git a/lib/assets/htmlMatcher.js b/lib/assets/htmlMatcher.js index 855b369a..6b876f21 100644 --- a/lib/assets/htmlMatcher.js +++ b/lib/assets/htmlMatcher.js @@ -62,10 +62,11 @@ define(function(require, exports, module) { }; /** - * Extend the range with another range. It is O(n) to extend n ranges. + * Extend the range with another range. We have to search the sequence for + * the position of the new range. */ Range.prototype.extend = function(range){ - // LeftPair, the right most range that l.start < range.start + // find the right most range that l.start < range.start var l = this; if (l.start < range.start) { while (l.next && l.next.start < range.start) { @@ -76,7 +77,7 @@ define(function(require, exports, module) { l = l.prev; } } - // RightPair, the left most range that r.end > range.end + // find the left most range that r.end > range.end var r = this; if (r.end > range.end) { while (r.prev && r.prev.end > range.end) { @@ -165,7 +166,7 @@ define(function(require, exports, module) { return range; }; - // Match, a data class represented with position, match token, tag name. + // Find @token in @text. var Match = function(text, startPos, token, name, excludeRange) { this.text = text; this.i = startPos; @@ -350,7 +351,7 @@ define(function(require, exports, module) { TreeResult.finished = new TreeResult(null, null, true); - // Tag tree, built with a MatchGroup. + // Tag tree, built with a MatchGroup. It has a stack to save the match result var Tree = function(matchGroup, direction, root) { this.matchGroup = matchGroup; this.root = root; @@ -600,7 +601,7 @@ define(function(require, exports, module) { } }; - // When an exclude range is added, extending current range is not enough. We have to tell every trees to clean up their tag stack. + // When an excludeRange is added, extending current range is not enough. We have to tell every trees to clean up their tag stack. Search.prototype.cleanTreeStack = function(range) { this.main.stackExclude(range); if (this.explicit) { @@ -628,7 +629,7 @@ define(function(require, exports, module) { } }; - // Try to find a tag on @pos + // Match a tag on @pos. This is used by Match.next, Match.back function matchTag(pos, text) { var match; if (text[pos + 1] == "/") {