-
-
Notifications
You must be signed in to change notification settings - Fork 46.5k
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
Add bitap_string_match algo #11060
Add bitap_string_match algo #11060
Conversation
pyproject.toml
Outdated
@@ -135,5 +135,5 @@ omit = [ | |||
sort = "Cover" | |||
|
|||
[tool.codespell] | |||
ignore-words-list = "3rt,ans,crate,damon,fo,followings,hist,iff,kwanza,manuel,mater,secant,som,sur,tim,toi,zar" | |||
ignore-words-list = "3rt,ans,crate,damon,fo,followings,hist,iff,kwanza,manuel,mater,secant,som,sur,tim,toi,zar,bitap" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list is in alphabetical order to make it easy to spot missing values and almost impossible to add duplicates.
strings/bitap_string_match.py
Outdated
m: int = len(pattern) | ||
if m == 0: | ||
return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All falsey values for pattern
are equally dangerous as ""
.
Python and mypy are both smart enough to figure out without the type hint that if len(pattern)
is assigned to m
then m
is an int.
m: int = len(pattern) | |
if m == 0: | |
return 0 | |
if not pattern: | |
return 0 | |
m = len(pattern) |
strings/bitap_string_match.py
Outdated
return -1 | ||
|
||
# Initial state of bit string 1110 | ||
state: int = ~1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state: int = ~1 | |
state = ~1 |
Thank you this review! |
🚀 Please give this repo a ⭐ if you have not already done so. |
* Add bitap_string_match algo * Fix types * Fix spelling and add ignore word * Add suggested changes and change return type * Resolve suggestions
Describe your change:
Checklist: