Nicely done and well-timed, too.
It's a nice shortcut that you know for a fact can save you a lot of unnecessary work since you profiled first.
How long did it take to close the events editor after you added the shortcut, btw?
A few thoughts:
(1) Is the growth really exponential? Whatever it is, it's obviously fast, and although I'm not (yet) familiar with the SEXP handling code, I'd think that the amount of checking would be
O(<number of SEXP nodes> x <number of events>).
(2) About the patch itself, you may want to adjust the patch as follows:
(a) Put the three lines you added above the
int i;
line, to make it clear that that declaration fits with the rest of the code and not your new shortcut.
(b) Add a comment above your added lines, maybe
// If the name hasn't changed, there's nothing to update
(c) Move the assert to the top of the function, so that it checks the assert before evaluating your shortcut.
(d) Maybe even move the index variable
i into the
for loop, something
couldn't do in C but that can done in C++, making the line read
for (int i = 0; i < Num_sexp_nodes; i++)
(I'm not backseat coding, I swear.
)
EDIT: Slight corrections.