You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently searching for a fast algorithm to diff large arrays. Just one level, values can be compared with ===, nothing special. So I tried microdiff like this:
importdifffrom"microdiff";// Build source array with values 0..9999consta: number[]=[];for(leti=0;i<10000;i++){a.push(i);}// Clone source array into target array and just add one number at the beginningconstb=a.slice();b.unshift(-1);console.log(diff(a,b));
I expected a diff with a CREATE change for index 0 but instead I get a diff with 10000 changes. When I add the number at the end then I get a single CREATE change as expected but when inserting or removing a single value somewhere then all subsequent entries are reported as CHANGED. Is this intended? Am I doing something wrong? I don't expect the shortest possible diff (which I know is expensive to generate) but this result seems pretty much useless.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm currently searching for a fast algorithm to diff large arrays. Just one level, values can be compared with
===
, nothing special. So I tried microdiff like this:I expected a diff with a CREATE change for index 0 but instead I get a diff with 10000 changes. When I add the number at the end then I get a single CREATE change as expected but when inserting or removing a single value somewhere then all subsequent entries are reported as CHANGED. Is this intended? Am I doing something wrong? I don't expect the shortest possible diff (which I know is expensive to generate) but this result seems pretty much useless.
Beta Was this translation helpful? Give feedback.
All reactions