3 deleted 5 characters in body
source | link

Use function pointers or delegates.

The variable holding the function pointer need not be explicitly examined until a change needs to be made. And when you no longer need said logic to run, replace with a ref to an empty / no-op function. Compare with doing conditionals checks every frame for the entire life of your program - even if that flag was only needed in the first few frames after startup! - Unclean and inefficient. Instead when you no longer need said logic to run, replace with a ref to an empty / no-op function(Boreal's point about prediction is however acknowledged in this regard.)

Nested conditionals, which these often constitute, are even more costly than having to check one single conditional every frame, since branch prediction can no longer do its magic in that case. That means regular delays on the order of 10s of cycles - pipeline stalls par excellence. The nesting can occur above or below this boolean flag. I hardly need remind readers of how complex game loops can quickly become.

Function pointers exist for this reason - use them!

Use function pointers or delegates.

The variable holding the function pointer need not be explicitly examined until a change needs to be made. Compare with doing conditionals checks every frame for the entire life of your program - even if that flag was only needed in the first few frames after startup! - Unclean and inefficient. Instead when you no longer need said logic to run, replace with a ref to an empty / no-op function.

Nested conditionals, which these often constitute, are even more costly than having to check one single conditional every frame, since branch prediction can no longer do its magic in that case. That means regular delays on the order of 10s of cycles - pipeline stalls par excellence. The nesting can occur above or below this boolean flag. I hardly need remind readers of how complex game loops can quickly become.

Function pointers exist for this reason - use them!

Use function pointers or delegates.

The variable holding the function pointer need not be explicitly examined until a change needs to be made. And when you no longer need said logic to run, replace with a ref to an empty / no-op function. Compare with doing conditionals checks every frame for the entire life of your program - even if that flag was only needed in the first few frames after startup! - Unclean and inefficient. (Boreal's point about prediction is however acknowledged in this regard.)

Nested conditionals, which these often constitute, are even more costly than having to check one single conditional every frame, since branch prediction can no longer do its magic in that case. That means regular delays on the order of 10s of cycles - pipeline stalls par excellence. The nesting can occur above or below this boolean flag. I hardly need remind readers of how complex game loops can quickly become.

Function pointers exist for this reason - use them!

2 added 102 characters in body
source | link

Use function pointers or delegates.

The variable holding the function pointer need not be explicitly examined until a change needs to be made. Compare with doing conditionals checks every frame for the entire life of your program - even if that flag was only needed in the first few frames after startup! - Unclean and inefficient. Instead when you no longer need said logic to run, replace with a ref to an empty / no-op function.

Nested conditionals, which these often constitute, are even more costly than having to check one single conditional every frame, since branch prediction can no longer do its magic in that case. That means regular delays on the order of 10s of cycles - pipeline stalls par excellence. The nesting can occur above or below this boolean flag. I hardly need remind readers of how complex game loops can quickly become.

Function pointers exist for this reason - use them!

Use function pointers or delegates.

The variable holding the function pointer need not be explicitly examined until a change needs to be made. Compare with doing conditionals checks every frame for the entire life of your program - even if that flag was only needed in the first few frames after startup! - Unclean and inefficient.

Nested conditionals, which these often constitute, are even more costly than having to check one single conditional every frame, since branch prediction can no longer do its magic in that case. That means regular delays on the order of 10s of cycles - pipeline stalls par excellence. The nesting can occur above or below this boolean flag. I hardly need remind readers of how complex game loops can quickly become.

Function pointers exist for this reason - use them!

Use function pointers or delegates.

The variable holding the function pointer need not be explicitly examined until a change needs to be made. Compare with doing conditionals checks every frame for the entire life of your program - even if that flag was only needed in the first few frames after startup! - Unclean and inefficient. Instead when you no longer need said logic to run, replace with a ref to an empty / no-op function.

Nested conditionals, which these often constitute, are even more costly than having to check one single conditional every frame, since branch prediction can no longer do its magic in that case. That means regular delays on the order of 10s of cycles - pipeline stalls par excellence. The nesting can occur above or below this boolean flag. I hardly need remind readers of how complex game loops can quickly become.

Function pointers exist for this reason - use them!

1
source | link

Use function pointers or delegates.

The variable holding the function pointer need not be explicitly examined until a change needs to be made. Compare with doing conditionals checks every frame for the entire life of your program - even if that flag was only needed in the first few frames after startup! - Unclean and inefficient.

Nested conditionals, which these often constitute, are even more costly than having to check one single conditional every frame, since branch prediction can no longer do its magic in that case. That means regular delays on the order of 10s of cycles - pipeline stalls par excellence. The nesting can occur above or below this boolean flag. I hardly need remind readers of how complex game loops can quickly become.

Function pointers exist for this reason - use them!