Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: case/switch versus if (key =='z') etc.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Regular Contributor
    Join Date
    May 2017
    Posts
    101

    case/switch versus if (key =='z') etc.

    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.

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    6,047
    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.

  3. #3
    Junior Member Regular Contributor
    Join Date
    May 2017
    Posts
    101
    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 : ))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •