Refining code
Code refinement is performed to improve the overall quality of code and make changes to its external behavior. This usually involves improving performance, enhancing functionality, adding new features, and fixing bugs, which in turn improve the user experience.
We have identified two ways to refine the code:
- Using caching variables
- Creating a fireball pool
Let’s go through each one.
Using caching variables
A caching variable is used to store a retrieved value that will be frequently used in the future. If you review the old APlayerAvatar
and AEnemy
source code, you will find the following two lines of code are executed at every frame in the Tick
functions of the two classes:
auto animInst = Cast<UPlayerAvatarAnimInstance>( GetMesh()->GetAnimInstance()); auto animInst = Cast<...