On 18/01/2023 6:21 pm, Anthony PERARD wrote: > On Tue, Jan 17, 2023 at 05:21:32PM +0000, Andrew Cooper wrote: >> On 16/01/2023 6:10 pm, Anthony PERARD wrote: >>> +def get_typedefs(tokens): >>> + level = 1 >>> + state = 0 >>> + typedefs = [] >> I'm pretty sure typedefs actually wants to be a dict rather than a list >> (will have better "id in typedefs" performance lower down), but that >> wants matching with code changes elsewhere, and probably wants doing >> separately. > I'm not sure that going to make a difference to have "id in ()" instead > of "id in []".
It will in the middle of a tight loop. Less pointer chasing in memory. But it is very marginal. > I just found out that `typedefs` is always empty... > > I don't know what get_typedefs() is supposed to do, or at least if it > works as expected, because it always returns "" or an empty list. (even > the shell version) > > So, it would actually be a bit faster to not call get_typedefs(), but I > don't know if that's safe. If it is dead logic even at the shell level, drop it. Perhaps a prereq patch, because removing the complexity first will make this patch simpler to follow. The conversion is atypical python, and perf will improve (which is the point of this patch anyway). ~Andrew