Browse files

Merge pull request #7 from NV/optimize

Simplify LineDiff.tokenize
  • Loading branch information...
2 parents 60c7297 + 122f586 commit 70f37f8c86a2f138dd669147a6adae91f857ee6a @kpdecker kpdecker committed Nov 1, 2011
Showing with 3 additions and 11 deletions.
  1. +3 −11 diff.js
View
14 diff.js
@@ -154,25 +154,17 @@ var JsDiff = (function() {
var WordDiff = new fbDiff(true);
WordDiff.tokenize = function(value) {
- return removeEmpty(value.split(/(\s+|\b)/g));
+ return removeEmpty(value.split(/(\s+|\b)/));
};
var CssDiff = new fbDiff(true);
CssDiff.tokenize = function(value) {
- return removeEmpty(value.split(/([{}:;,]|\s+)/g));
+ return removeEmpty(value.split(/([{}:;,]|\s+)/));
};
var LineDiff = new fbDiff();
LineDiff.tokenize = function(value) {
- var values = value.split(/\n/g),
- ret = [];
- for (var i = 0; i < values.length-1; i++) {
- ret.push(values[i] + "\n");
- }
- if (values.length) {
- ret.push(values[values.length-1]);
- }
- return ret;
+ return value.split(/^/m);
};
return {

0 comments on commit 70f37f8

Please sign in to comment.