Well, I'm sure there's some call to it.. somewhere...
Whatever. This isn't my code, and I'm not about to start making arbitrary changes for no good reason to code I don't own. Moving it, or just plain deleting it, would make sense if it were my own, but so far I haven't touched win32_compat.cpp at all.
Mostly my aim was to babble about general good practices, it helps me think.
Hmm.. it was originally written by BHelyer, wasn't it? Why don't you take it up with him instead?
I think the particular function in question was copied from a code repository. I don't want to get started babbling about that.
..why would you even be reading code to look for optimizations? Run a profiler, and it'll tell you exactly where optimizing will do you any good. Callgrind will do nicely.
I read that because it was in the diff for .04, it is one of my
bad habits to pay more attention to things that have changed than to things that are still the same.
Wow, profilers must be getting really good if they can tell you
exactly where your code needs to be fixed. Next they will be writing the code too.
Anyhow more testing with the U,M subsequent ESC sequence. I got it to display the Military screen when doing hold U + press and hold M (released both after the Military displayed). It happens much less often then the rapid series of presses, implying that the frequency of erases and inserts in add_input is a factor.
The only way I can see all the observed behaviors occuring is if get_input returned a set with both those keypresses. Then the gameview's feed processes both creating the Units screen then creating the Military, both with push_at_back. In order for that to happen the serial member for both presses must be the same; and the only way for a serial number to be reused is if clear_input is called.
Quick fix answer remove the reset of the serial counter from clear_input.
Long term, you are hunting for a threading issue. Good luck.