Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow early termination to limit execution time with degenerate cases #365

Merged
merged 2 commits into from
May 6, 2022

Conversation

xeger
Copy link
Contributor

@xeger xeger commented Apr 28, 2022

Fixes #364 by giving callers an option.

src/diff/base.js Outdated
@@ -29,7 +29,7 @@ Diff.prototype = {

let newLen = newString.length, oldLen = oldString.length;
let editLength = 1;
let maxEditLength = newLen + oldLen;
let maxEditLength = options.maxEditLength || newLen + oldLen;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we cap this parameter at newLen+oldLen?

@kpdecker
Copy link
Owner

kpdecker commented May 6, 2022

LGTM outside of that one change.

@xeger
Copy link
Contributor Author

xeger commented May 6, 2022

Done!

@kpdecker kpdecker merged commit f4cc58c into kpdecker:master May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Endless loop + hang with 100% CPU usage in execEditLength() when calling structuredPatch()
2 participants