edit icon indicating copy to clipboard operation
edit copied to clipboard

Added error handling and safe indexing to score_fuzzy algorithm

Open GiorgosTsak opened this issue 6 months ago • 2 comments

Improved the score_fuzzy algorithm by introducing essential error handling and input validation while preserving the original logic and comments. Specifically, early returns have been added for empty strings or impossible match scenarios to prevent unnecessary computation. Matrix size calculations now use .checked_mul() to avoid potential overflow errors. Access to previous characters in the target string uses .get() with safe bounds checking to prevent panics, and contiguous match checks employ .map_or(false, ...) to handle edge cases safely.

GiorgosTsak avatar Jun 23 '25 17:06 GiorgosTsak

Are you sure you tested this PR locally? If you don't mind me saying, the lack of running rustfmt, and the commit titles that are rather typical for the online GitHub code editor, indicate you didn't.

lhecker avatar Jun 23 '25 20:06 lhecker

I'll close this PR for now.

lhecker avatar Aug 04 '25 21:08 lhecker