minor clarifications
This commit is contained in:
11
.github/cpp.instructions.md
vendored
11
.github/cpp.instructions.md
vendored
@@ -147,12 +147,13 @@ This pattern enables optimizations and makes intent clear to reviewers.
|
||||
|
||||
### `const` locals
|
||||
|
||||
Adding `const` to a local variable that is only assigned once is not necessary — but it **is** required when the variable is passed to a function that takes a `const` parameter (pointer or reference). In hot-path code, `const` on cached locals helps the compiler keep values in registers:
|
||||
* Adding `const` to a local variable that is only assigned once is optional, but *not* strictly necessary.
|
||||
* In hot-path code, `const` on cached locals may help the compiler keep values in registers:
|
||||
```cpp
|
||||
const uint_fast16_t cols = vWidth();
|
||||
const uint_fast16_t rows = vHeight();
|
||||
```
|
||||
|
||||
```cpp
|
||||
const uint_fast16_t cols = virtualWidth();
|
||||
const uint_fast16_t rows = virtualHeight();
|
||||
```
|
||||
<!-- HUMAN_ONLY_END -->
|
||||
### `const` references to avoid copies
|
||||
|
||||
|
||||
Reference in New Issue
Block a user