File tree Expand file tree Collapse file tree 1 file changed +14
-16
lines changed Expand file tree Collapse file tree 1 file changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -2063,27 +2063,25 @@ _PyPegen_get_invalid_target(expr_ty e)
20632063 if (e == NULL ) {
20642064 return NULL ;
20652065 }
2066+
2067+ #define VISIT_CONTAINER (CONTAINER , TYPE ) do { \
2068+ Py_ssize_t len = asdl_seq_LEN(CONTAINER->v.TYPE.elts);\
2069+ for (Py_ssize_t i = 0; i < len; i++) {\
2070+ expr_ty other = asdl_seq_GET(CONTAINER->v.TYPE.elts, i);\
2071+ expr_ty child = _PyPegen_get_invalid_target(other);\
2072+ if (child != NULL) {\
2073+ return child;\
2074+ }\
2075+ }\
2076+ } while (0)
2077+
20662078 switch (e -> kind ) {
20672079 case List_kind : {
2068- Py_ssize_t len = asdl_seq_LEN (e -> v .List .elts );
2069- for (Py_ssize_t i = 0 ; i < len ; i ++ ) {
2070- expr_ty other = asdl_seq_GET (e -> v .List .elts , i );
2071- expr_ty child = _PyPegen_get_invalid_target (other );
2072- if (child != NULL ) {
2073- return child ;
2074- }
2075- }
2080+ VISIT_CONTAINER (e , List );
20762081 return NULL ;
20772082 }
20782083 case Tuple_kind : {
2079- Py_ssize_t len = asdl_seq_LEN (e -> v .Tuple .elts );
2080- for (Py_ssize_t i = 0 ; i < len ; i ++ ) {
2081- expr_ty other = asdl_seq_GET (e -> v .Tuple .elts , i );
2082- expr_ty child = _PyPegen_get_invalid_target (other );
2083- if (child != NULL ) {
2084- return child ;
2085- }
2086- }
2084+ VISIT_CONTAINER (e , Tuple );
20872085 return NULL ;
20882086 }
20892087 case Starred_kind :
You can’t perform that action at this time.
0 commit comments