8000 gh-117431: Improve performance of startswith and endswith by eendebakpt · Pull Request #117782 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-117431: Improve performance of startswith and endswith #117782

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
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
code style
  • Loading branch information
eendebakpt committed Apr 11, 2024
commit 4f4b084eadd50e65f165ad011777e5a7991ff240
9 changes: 5 additions & 4 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -9272,12 +9272,13 @@ tailmatch(PyObject *self,
else
offset = start;

int last_character_matches = PyUnicode_READ(kind_self, data_self, offset + end_sub) ==
PyUnicode_READ(kind_sub, data_sub, end_sub);
int match_last = PyUnicode_READ(kind_self, data_self, offset + end_sub) ==
PyUnicode_READ(kind_sub, data_sub, end_sub);

if (last_character_matches) {< 6616 /span>
if (end_sub==0)
if (match_last) {
if (end_sub==0) {
return 1;
}
/* If both are of the same kind, memcmp is sufficient */
if (kind_self == kind_sub) {
return ! memcmp((char *)data_self + (offset * kind_sub),
Expand Down
0