Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualJuliean

Posted 15 June 2013 - 10:08 AM

Thanks, noted it, in case I might come across a case where I can optimize this.

 

 

 


However, the OP code might benefit from not repeating this expensive operation (or operator[]) 3 times in a row, and instead caching the result once, depending on how much faith you have in the compiler to spot and clean up the redundancy wink.png

 

I already tried that, it didn't show any significant difference neigther in FPS nor when profiling, in release mode. Even though in my tests, the operation was likely executed about 300.000+ times, it seems most of the time spend here comes from the if()-condition itself. Though even more offtopic, do you have any suggestion on how to improve that, maybe some complete different branch-less approach for checking if a state was already applied before?


#1Juliean

Posted 15 June 2013 - 10:08 AM

Thanks, noted it, in case I might come across a case where I can optimize this.

 


However, the OP code might benefit from not repeating this expensive operation (or operator[]) 3 times in a row, and instead caching the result once, depending on how much faith you have in the compiler to spot and clean up the redundancy wink.png

 

I already tried that, it didn't show any significant difference neigther in FPS nor when profiling, in release mode. Even though in my profiling, the operation was likely executed about 3.000.000+ times, it seems most of the time spend here comes from the if()-condition itself. Though even more offtopic, do you have any suggestion on how to improve that, maybe some complete different branch-less approach for checking if a state was already applied before?


PARTNERS