I was a new hire at a game development company. My first task was to optimize a function that was consuming more cycles than all the other ones. The function was responsible for dispatching Objective-C++ method calls.
After a quick debug session, the problem was clear: the methods to call was being searched using a linear search. I changed the search to use a hashtable and the function disappeared from the list of most CPU consuming functions.
After running both implementations for a couple of weeks to make sure my implementation was right, I made a PR, which wasn't approved. The manager said my change was too risky to go to production, even though the implementation was simple and I spent two weeks making sure it was ok. They're probably still using the linear search.
I was a junior programmer helping out with a Java applet game that ran in the browser.
It had performance issues, which I narrowed down to a “ticker tape” text animation. The position of the text in pixels was being updated by a background thread, and that thread would leak each time when the user switched screens. If you clicked around enough there would be hundreds of threads all updating the same shared variable.
I replaced a thousand lines of that nonsense with a single line of code:
return getTicks() * velocity % tickerWidth;
It looked identical except that now there weren’t any threads used and the animation was silky smooth.
I got in trouble for “making a mess”. The developer responsible for the previous code had been busy (for weeks!) “fixing” this code and couldn’t merge his change. So it got reverted and they spent another month tuning the threaded code for better performance.
I waited until they got distracted and gave up, then re-merged my one-liner. They were convinced they had “fixed it” and never looked at that code again.
The responsible coder got a pat on the back for his hard work and I got a disciplinary meeting to discuss my “behaviour”.
This was at a startup that burned through ten million dollars and then was shuttered because the software was basically garbage and couldn’t be sold to anyone.
I hope you ran away from that company. Your change was too disruptive, because it made other people look stupid, like they didn't grok basic data structures. I think everyone overlooks obvious solutions to everyday problems every now and then, but the way they reacted speaks volumes...
Even insecure people will take better code in most circumstances. Maybe after adding their own touches to it so it doesn’t seem like you got it right or came up with a good solution on your own.
It’s the ones that don’t understand the change and don’t want to admit it that are the real problem. “Too disruptive = I don’t understand this and don’t know how to support it”, if, in fact, it was a simple search->hash map change which any developer should be able to grok.
Objective C is a system for that; Objective C++ is at least three systems for dispatching calls in ways that don't involve linear search. Not sure why they'd try to make another one.
After a quick debug session, the problem was clear: the methods to call was being searched using a linear search. I changed the search to use a hashtable and the function disappeared from the list of most CPU consuming functions.
After running both implementations for a couple of weeks to make sure my implementation was right, I made a PR, which wasn't approved. The manager said my change was too risky to go to production, even though the implementation was simple and I spent two weeks making sure it was ok. They're probably still using the linear search.