diff options
author | Erlend E. Aasland <erlend.aasland@protonmail.com> | 2022-08-13 10:09:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-13 10:09:40 (GMT) |
commit | f07adf82f338ebb7e69475537be050e63c2009fa (patch) | |
tree | 26c4cd000b95fc45befb2ea3c87c03d84d9aed75 /Modules/_blake2 | |
parent | f235178beccf5eb5b47e770240f32d9ba24b26fd (diff) | |
download | cpython-f07adf82f338ebb7e69475537be050e63c2009fa.zip cpython-f07adf82f338ebb7e69475537be050e63c2009fa.tar.gz cpython-f07adf82f338ebb7e69475537be050e63c2009fa.tar.bz2 |
gh-90928: Improve static initialization of keywords tuple in AC (#95907)
Diffstat (limited to 'Modules/_blake2')
-rw-r--r-- | Modules/_blake2/clinic/blake2b_impl.c.h | 26 | ||||
-rw-r--r-- | Modules/_blake2/clinic/blake2s_impl.c.h | 26 |
2 files changed, 16 insertions, 36 deletions
diff --git a/Modules/_blake2/clinic/blake2b_impl.c.h b/Modules/_blake2/clinic/blake2b_impl.c.h index 7e07f60..99b0f09 100644 --- a/Modules/_blake2/clinic/blake2b_impl.c.h +++ b/Modules/_blake2/clinic/blake2b_impl.c.h @@ -28,18 +28,9 @@ static PyObject * py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 12 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 12 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -48,13 +39,12 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(digest_size), &_Py_ID(key), &_Py_ID(salt), &_Py_ID(person), &_Py_ID(fanout), &_Py_ID(depth), &_Py_ID(leaf_size), &_Py_ID(node_offset), &_Py_ID(node_depth), &_Py_ID(inner_size), &_Py_ID(last_node), &_Py_ID(usedforsecurity), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"", "digest_size", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node", "usedforsecurity", NULL}; static _PyArg_Parser _parser = { @@ -286,4 +276,4 @@ _blake2_blake2b_hexdigest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored)) { return _blake2_blake2b_hexdigest_impl(self); } -/*[clinic end generated code: output=6daedbc1dba8c284 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=996b4fe396824797 input=a9049054013a1b77]*/ diff --git a/Modules/_blake2/clinic/blake2s_impl.c.h b/Modules/_blake2/clinic/blake2s_impl.c.h index ee746d4..9b821fb 100644 --- a/Modules/_blake2/clinic/blake2s_impl.c.h +++ b/Modules/_blake2/clinic/blake2s_impl.c.h @@ -28,18 +28,9 @@ static PyObject * py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 12 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 12 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -48,13 +39,12 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(digest_size), &_Py_ID(key), &_Py_ID(salt), &_Py_ID(person), &_Py_ID(fanout), &_Py_ID(depth), &_Py_ID(leaf_size), &_Py_ID(node_offset), &_Py_ID(node_depth), &_Py_ID(inner_size), &_Py_ID(last_node), &_Py_ID(usedforsecurity), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"", "digest_size", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node", "usedforsecurity", NULL}; static _PyArg_Parser _parser = { @@ -286,4 +276,4 @@ _blake2_blake2s_hexdigest(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored)) { return _blake2_blake2s_hexdigest_impl(self); } -/*[clinic end generated code: output=1b0381231f840d4d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bd0fb7639e450618 input=a9049054013a1b77]*/ |