Commit ec014a10 authored by Sergey Fedoseev's avatar Sergey Fedoseev Committed by Miss Islington (bot)

bpo-34636: Use fast path for more chars in SRE category macros. (GH-9170)

When handling \s, \d, or \w (and their inverse) escapes in bytes regexes this a small but measurable performance improvement.

<!-- issue-number: [bpo-34636](https://www.bugs.python.org/issue34636) -->
https://bugs.python.org/issue34636
<!-- /issue-number -->
parent d13e59c1
Speed up re scanning of many non-matching characters for \s \w and \d within
bytes objects. (microoptimization)
......@@ -87,13 +87,13 @@ static const char copyright[] =
/* search engine state */
#define SRE_IS_DIGIT(ch)\
((ch) < 128 && Py_ISDIGIT(ch))
((ch) <= '9' && Py_ISDIGIT(ch))
#define SRE_IS_SPACE(ch)\
((ch) < 128 && Py_ISSPACE(ch))
((ch) <= ' ' && Py_ISSPACE(ch))
#define SRE_IS_LINEBREAK(ch)\
((ch) == '\n')
#define SRE_IS_WORD(ch)\
((ch) < 128 && (Py_ISALNUM(ch) || (ch) == '_'))
((ch) <= 'z' && (Py_ISALNUM(ch) || (ch) == '_'))
static unsigned int sre_lower_ascii(unsigned int ch)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment