Single-handedly one of the most expensive features in 4chan X?

LETS ADD RECURSION!
This commit is contained in:
Zixaphir 2013-08-11 23:31:33 -07:00
parent 708f56c759
commit 045ba42296
3 changed files with 20 additions and 11 deletions

View File

@ -4450,7 +4450,7 @@
} }
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
if (match) { if (match) {
links.push(Linkify.seek(snapshot, node, match, i)); links.push(Linkify.seek(snapshot, post, node, match, i));
} }
_ref = links.reverse(); _ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -4458,8 +4458,8 @@
Linkify.makeLink(range, post); Linkify.makeLink(range, post);
} }
}, },
seek: function(snapshot, node, match, i) { seek: function(snapshot, post, node, match, i) {
var data, link, next, range, result; var data, index, link, next, range, result;
link = match[0]; link = match[0];
range = document.createRange(); range = document.createRange();
@ -4468,7 +4468,10 @@
node = next; node = next;
data = node.data; data = node.data;
if (result = /[\s'"]/.exec(data)) { if (result = /[\s'"]/.exec(data)) {
range.setEnd(node, result.index); index = result.index;
range.setEnd(node, index);
Linkify.regString.lastIndex = index;
Linkify.gatherLinks(snapshot, post, node, i);
} }
} }
if (range.collapsed) { if (range.collapsed) {

View File

@ -4455,7 +4455,7 @@
} }
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
if (match) { if (match) {
links.push(Linkify.seek(snapshot, node, match, i)); links.push(Linkify.seek(snapshot, post, node, match, i));
} }
_ref = links.reverse(); _ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -4463,8 +4463,8 @@
Linkify.makeLink(range, post); Linkify.makeLink(range, post);
} }
}, },
seek: function(snapshot, node, match, i) { seek: function(snapshot, post, node, match, i) {
var data, link, next, range, result; var data, index, link, next, range, result;
link = match[0]; link = match[0];
range = document.createRange(); range = document.createRange();
@ -4473,7 +4473,10 @@
node = next; node = next;
data = node.data; data = node.data;
if (result = /[\s'"]/.exec(data)) { if (result = /[\s'"]/.exec(data)) {
range.setEnd(node, result.index); index = result.index;
range.setEnd(node, index);
Linkify.regString.lastIndex = index;
Linkify.gatherLinks(snapshot, post, node, i);
} }
} }
if (range.collapsed) { if (range.collapsed) {

View File

@ -84,14 +84,14 @@ Linkify =
Linkify.regString.lastIndex = 0 Linkify.regString.lastIndex = 0
if match if match
links.push Linkify.seek snapshot, node, match, i links.push Linkify.seek snapshot, post, node, match, i
for range in links.reverse() for range in links.reverse()
Linkify.makeLink range, post Linkify.makeLink range, post
return return
seek: (snapshot, node, match, i) -> seek: (snapshot, post, node, match, i) ->
link = match[0] link = match[0]
range = document.createRange() range = document.createRange()
range.setStart node, match.index range.setStart node, match.index
@ -100,7 +100,10 @@ Linkify =
node = next node = next
data = node.data data = node.data
if result = /[\s'"]/.exec data if result = /[\s'"]/.exec data
range.setEnd node, result.index {index} = result
range.setEnd node, index
Linkify.regString.lastIndex = index
Linkify.gatherLinks snapshot, post, node, i
if range.collapsed if range.collapsed
range.setEndAfter node range.setEndAfter node