Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is it really suitable for array diffing?#44

Unanswered
kayahr asked this question inQ&A
Discussion options

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.

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@kayahr

[8]ページ先頭

©2009-2025 Movatter.jp