[Python-checkins] replace custom table with pyctype (#3456)

Benjamin Peterson webhook-mailer at python.org
Fri Sep 8 13:35:52 EDT 2017


https://github.com/python/cpython/commit/2b7953d974dbe5adc0937394c93f31c46cf01517
commit: 2b7953d974dbe5adc0937394c93f31c46cf01517
branch: master
author: Benjamin Peterson <benjamin at python.org>
committer: GitHub <noreply at github.com>
date: 2017年09月08日T10:35:49-07:00
summary:
replace custom table with pyctype (#3456)
files:
M Objects/codeobject.c
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index adef625b296..f312f338a9b 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -14,17 +14,6 @@ typedef struct {
 static int
 all_name_chars(PyObject *o)
 {
- /* [a-zA-Z0-9_] */
- static const bool ok_name_char[128] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
- };
 const unsigned char *s, *e;
 
 if (!PyUnicode_IS_ASCII(o))
@@ -33,7 +22,7 @@ all_name_chars(PyObject *o)
 s = PyUnicode_1BYTE_DATA(o);
 e = s + PyUnicode_GET_LENGTH(o);
 for (; s != e; s++) {
- if (!ok_name_char[*s])
+ if (!Py_ISALNUM(*s) && *s != '_')
 return 0;
 }
 return 1;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /