Issue 30785: ast.c duplicates STR(CHILD) (original) (raw)

The function alias_for_import_name() duplicates logic starting at Python/ast.c:3237

char *sch = STR(CHILD(n, i));
strcpy(s, STR(CHILD(n, i)));
s += strlen(sch);
*s++ = '.';

I assume the strcpy() is supposed to use the sch value from the line above. There shouldn't be any consequence to the code as it currently is; I just noticed it while reading through the source.

Thanks Christopher, you are absolutely correct. There are a few ways in which this code could be optimized (and many other small optimizations probably exist elsewhere in the code).

If you are interested in submitting a PR for this, you are more than welcome to and I can re-open the issue. Otherwise, I'm going to close it out as this is not a critical optimization.