Skip to content

Commit

Permalink
Update first.md
Browse files Browse the repository at this point in the history
Fixed typo (gratly -> greatly)
  • Loading branch information
rileynet authored Aug 27, 2024
1 parent debf6e0 commit ce0d0ef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/first.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ Those are points where other GBA tutorials often err. It's not an exclusive list
- **Use a better algorithm**. Okay, so this one may not always be simple, but it's still very true.
- **Use ints**. The `int` is loosely defined as the native datatype. Processors tend to perform better when they deal with their native datatype.
- **Use temporary variables for common expressions**. If you use a long expression more than a few times, consider dumping it in a temp. This means less writing for you, and less reading for everyone. It can also make your code faster because you don't need to evaluate the entire expression all the time. This is especially true for global variables, which have to be reloaded after each function-call because the values may have changed.
- **Use pointers**. Pointers have the reputation of being dangerous, but they're a *very* powerful tool if used correctly. Pointer arithmetic is usually faster than indexing because it's closer to hardware, and by assigning temp pointers to deeply nested structure expressions (see above), you can gratly reduce the length of the expressions, which makes things easier on the compiler and the reader alike.
- **Use pointers**. Pointers have the reputation of being dangerous, but they're a *very* powerful tool if used correctly. Pointer arithmetic is usually faster than indexing because it's closer to hardware, and by assigning temp pointers to deeply nested structure expressions (see above), you can greatly reduce the length of the expressions, which makes things easier on the compiler and the reader alike.
- **Precalculate.** This is related to the previous two points. If you have a loop in which things don't depend on the loop-variable, precalculate that part before the loop. Also, to avoid (complex) calculations, you could dump the data in a [Look-up Table](fixed.html#sec-lut) and simply grab a value from there.
- **Avoid branches**. Things that redirect program flow (ifs, loops, switches) generally cost more than other operations such as arithmetic. Sometimes it's possible to effectively do the branch with arithmetic (for example, `(int)x>>1` gives −1 or 0, depending on the sign of *x*)

Expand Down

0 comments on commit ce0d0ef

Please sign in to comment.