I don't know Bo, I think that latex_code() is a reasonably efficient way of having a signature of the math inset (to check if it has changed). I would be surprised if this had a real performance impact (typically O(1) operations per user interaction, we do much worse elsewhere in the code)
OK. Do you have any doubt in replacing notifyCursorLeaves with the standalone version? If not, I will submit Alfredo's patch. It looks safe enough to me. Cheers, Bo