@@ -20,7 +20,7 @@ function areLinesEqual(actual, expected, checkCommaDisparity) {
20
20
return false ;
21
21
}
22
22
23
- function myersDiff ( actual , expected , checkCommaDisparity = false ) {
23
+ function myersDiff ( actual , expected , checkCommaDisparity = false , useNullPrototypes = true ) {
24
24
const actualLength = actual . length ;
25
25
const expectedLength = expected . length ;
26
26
const max = actualLength + expectedLength ;
@@ -51,13 +51,13 @@ function myersDiff(actual, expected, checkCommaDisparity = false) {
51
51
v [ offset ] = x ;
52
52
53
53
if ( x >= actualLength && y >= expectedLength ) {
54
- return backtrack ( trace , actual , expected , checkCommaDisparity ) ;
54
+ return backtrack ( trace , actual , expected , checkCommaDisparity , useNullPrototypes ) ;
55
55
}
56
56
}
57
57
}
58
58
}
59
59
60
- function backtrack ( trace , actual , expected , checkCommaDisparity ) {
60
+ function backtrack ( trace , actual , expected , checkCommaDisparity , useNullPrototypes ) {
61
61
const actualLength = actual . length ;
62
62
const expectedLength = expected . length ;
63
63
const max = actualLength + expectedLength ;
@@ -87,16 +87,22 @@ function backtrack(trace, actual, expected, checkCommaDisparity) {
87
87
while ( x > prevX && y > prevY ) {
88
88
const actualItem = actual [ x - 1 ] ;
89
89
const value = checkCommaDisparity && ! StringPrototypeEndsWith ( actualItem , ',' ) ? expected [ y - 1 ] : actualItem ;
90
- ArrayPrototypePush ( result , { __proto__ : null , type : 'nop' , value } ) ;
90
+ ArrayPrototypePush ( result , useNullPrototypes ?
91
+ { __proto__ : null , type : 'nop' , value } :
92
+ { type : 'nop' , value } ) ;
91
93
x -- ;
92
94
y -- ;
93
95
}
94
96
95
97
if ( diffLevel > 0 ) {
96
98
if ( x > prevX ) {
97
- ArrayPrototypePush ( result , { __proto__ : null , type : 'insert' , value : actual [ -- x ] } ) ;
99
+ ArrayPrototypePush ( result , useNullPrototypes ?
100
+ { __proto__ : null , type : 'insert' , value : actual [ -- x ] } :
101
+ { type : 'insert' , value : actual [ -- x ] } ) ;
98
102
} else {
99
- ArrayPrototypePush ( result , { __proto__ : null , type : 'delete' , value : expected [ -- y ] } ) ;
103
+ ArrayPrototypePush ( result , useNullPrototypes ?
104
+ { __proto__ : null , type : 'delete' , value : expected [ -- y ] } :
105
+ { type : 'delete' , value : expected [ -- y ] } ) ;
100
106
}
101
107
}
102
108
}
0 commit comments