Skip to content

Commit 600195f

Browse files
committed
optimize : remove needless array when joining surrogate pairs
1 parent 55e9cb0 commit 600195f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

javascript/diff_match_patch_uncompressed.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2216,9 +2216,8 @@ diff_match_patch.prototype.patch_splitMax = function(patches) {
22162216
};
22172217

22182218
diff_match_patch.prototype.diffs_joinSurrogatePairs = function(diffs) {
2219-
var newDiffs = [];
2220-
22212219
var lastEnd;
2220+
var overwrittenDiffsCounter = 0;
22222221

22232222
for (var x = 0 ; x < diffs.length ; x++) {
22242223
var thisDiff = diffs[x];
@@ -2244,10 +2243,11 @@ diff_match_patch.prototype.diffs_joinSurrogatePairs = function(diffs) {
22442243
continue;
22452244
}
22462245

2247-
newDiffs.push(thisDiff)
2246+
diffs[overwrittenDiffsCounter] = thisDiff;
2247+
overwrittenDiffsCounter ++;
22482248
}
22492249

2250-
return newDiffs
2250+
return diffs.splice(0, overwrittenDiffsCounter)
22512251
}
22522252

22532253
diff_match_patch.prototype.patch_joinSurrogatePairs = function(patch) {

0 commit comments

Comments
 (0)