Skip to content

Conversation

sir-sigurd
Copy link
Contributor

No description provided.

Modules/_sre.c Outdated
@@ -293,7 +288,7 @@ _sre_ascii_iscased_impl(PyObject *module, int character)
/*[clinic end generated code: output=4f454b630fbd19a2 input=9f0bd952812c7ed3]*/
{
unsigned int ch = (unsigned int)character;
return ch != sre_lower_ascii(ch) || ch != sre_upper_ascii(ch);
return ch <= 'z' && Py_ISALPHA(ch);
Copy link
Member

Choose a reason for hiding this comment

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

I would use 127 instead of 'z'.

Copy link
Contributor

@benjaminp benjaminp left a comment

Choose a reason for hiding this comment

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

Agreed that < 128 would be better.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@sir-sigurd
Copy link
Contributor Author

@serhiy-storchaka @benjaminp
I used <= 'z' to allow fast path for values between 'z' and 128, i'm not sure why < 128 would be better.

@serhiy-storchaka
Copy link
Member

Performance is not critical here, but readability matters. It took a while for me to figure out why this code is written in such way and to ensure that it is correct. It can be looking more cryptic for other readers. The meaning of < 128 is more clear: it is for ASCII only.

@sir-sigurd
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@zhangyangyu, @benjaminp: please review the changes made to this pull request.

@serhiy-storchaka serhiy-storchaka merged commit 7f0d59f into python:master Sep 12, 2018
@sir-sigurd sir-sigurd deleted the sre-ascii-iscased branch September 12, 2018 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants