Closed drocha87 closed 2 years ago
reversing was actually a choice made keeping in mind the algorithmic complexity of the program, since pop(0) is O(n) but pop() is O(1).
Ohh I didn't know about that. Holy molly good to know that pop(0)
is O(n)
.
I just realized that there's no need to reverse the tokens since you can just
tokens.pop(0)
andtokens = macros[token.value].tokens + tokens
when you need to append the list of tokens totokens
(in case of expanding a macro for example).I don't know if this can bring any performance improvements but I think it simplifies the code a little bit.
If you want I can change the code and send a PR.