-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix wrong order if p_bitmap->depth > 16 in UpdatePinmameDisplayBitmap
- Loading branch information
Showing
1 changed file
with
8 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d0528cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@toxieainc, thanks!
quick question, I thought I read somewhere, it's better to create reused vars outside of for loops (ie
r
,g
,b
), so they don't get created each iteration.vs
If that's not true, I'll redo my coding style.
d0528cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends.. :)
My rule of thumb is, that everything should be declared as close to its use-location as possible, unless the creation of a var is very costly and/or the constructor is basically run unnecessarily (e.g. a vector that could be reused multiple times (loop) with roughly the same max size, or a large struct that is re-initialized with the same values again and again).
So for simple data types like ints, floats, etc, its usually always better to have them within a very limited scope. This makes live for the compiler (and most of the time also the human reader) easier.
While one can argue that the compiler is smart enough to track liveness, etc, my professional experience with compilers is, that they work counter-intuitive (compared to human logic) in many cases, so its better to be safe than sorry IMHO.
Its also what static analyzers recommend nowadays for simple data types.