Open afd opened 1 month ago
@JamesLee-Jones Thanks for the comment. The C++ single file tests take considerably longer to run compared with the C ones, so I have decided not to add them in this instance, feeling confident this won't change.
@JonathanFoo0523 - the optimisation does work if 0u is replaced by 0 - in next iteration I have added tests to check for this.
It raises room for another optimisation, though, which is that when an int is cast (implicitly or otherwise) to unsigned, we mutate both before and after the cast, which will lead to replacement with 0 and 1 occurring redundantly as they will be used in both places. I'll open an issue for this.
@JonathanFoo0523 Thanks for your comments - good spots. I have revised - and to make it less likely that I'll make a mistake like this again I renamed "operator_kind" to "replacement_operator" in all of the functions that are considering whether a replacement is legitimate (both for unary and binary operator mutations).
It raises room for another optimisation, though, which is that when an int is cast (implicitly or otherwise) to unsigned, we mutate both before and after the cast, which will lead to replacement with 0 and 1 occurring redundantly as they will be used in both places. I'll open an issue for this.
Actually I think I got this wrong - perhaps I looked at the non-optimised code.
@JamesLee-Jones would you be able to take a look again please?
Fixes #240.