PDA

View Full Version : case/switch versus if (key =='z') etc.



technologist
12-27-2017, 02:49 PM
In processing keyboard events is it faster to use case/switch programming or if(key=="z"){etc.}. I've noticed a significant difference. Maybe user error or not.

Alfonse Reinheart
12-27-2017, 03:15 PM
There is no way your keyboard event testing code is a performance bottleneck. If your benchmarking says that it is, then either your benchmarks are broken or you're really doing it wrong.

technologist
12-27-2017, 05:02 PM
I agree, I think it was my IDE. Key selections and their sequelae were showing up quickly when processed, but when I went to the case/switch methodology, it was noticeably slower. Sometimes wouldn't show until the program stopped. I restarted everything and farmed it out to a new project, and the behavior went away (but not too soon to delete the post : ))