Skip to content

Refactor levenshtein() #5816

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

Closed
wants to merge 2 commits into from
Closed

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jul 6, 2020

The unimplemented overloaded variant about using a callable for the 3rd argument (which only takes a string callable as this code is OLD) is removed and should if implemented be implemented as a separate function (see: https://bugs.php.net/bug.php?id=34835)

This should also fix: https://bugs.php.net/bug.php?id=79050

I'm not sure if the length limitation makes much sense in 2020.

Also I wonder if I should classify as a ValueError negative costs (<= 0)

@Girgias Girgias force-pushed the refactor-levenstein branch from 89451da to f359601 Compare July 6, 2020 17:22
Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Thanks! Very welcome clean-up. :)

default:
WRONG_PARAM_COUNT;
if (ZSTR_LEN(string1) > LEVENSHTEIN_MAX_LENGTH) {
zend_argument_value_error(1, "must be less than %d characters", LEVENSHTEIN_MAX_LENGTH);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
zend_argument_value_error(1, "must be less than %d characters", LEVENSHTEIN_MAX_LENGTH);
zend_argument_value_error(1, "must be less than %d characters", LEVENSHTEIN_MAX_LENGTH + 1);

or

Suggested change
zend_argument_value_error(1, "must be less than %d characters", LEVENSHTEIN_MAX_LENGTH);
zend_argument_value_error(1, "must be less than or equal to %d characters", LEVENSHTEIN_MAX_LENGTH);

(same below)

@Girgias Girgias force-pushed the refactor-levenstein branch from f359601 to c00e0fa Compare July 6, 2020 17:50
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.

4 participants