Skip to content

Improve time complexity of tokenization regex used in diffSentences #580

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better fix
  • Loading branch information
ExplodingCabbage committed Feb 12, 2025
commit 60fa6c7566e484449b04555bcd8e010e1dff79e0
2 changes: 1 addition & 1 deletion src/diff/sentence.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Diff from './base';

export const sentenceDiff = new Diff();
sentenceDiff.tokenize = function(value) {
return value.split(/(?<=^|\s+)(\S.+?[.!?])(?=\s+|$)/);
return value.split(/(?<=[.!?])(\s+|$)/);
};

export function diffSentences(oldStr, newStr, callback) { return sentenceDiff.diff(oldStr, newStr, callback); }