I want to make my program run faster. I know pointers are quick but does using pointers in this following example increase or decrease speed?
If this is faster I plan on doing something similar with all my functions to increase the speed of my program.
Example 1. This is the first function returning type Entity.
This is the call.
</p><div>*hero = hero->hero_turning(*hero,'d',mv);</div>
This is the function
</p><div>Entity Entity::hero_turning(Entity hero, char facing1, vector<Tile> mv) {</div>
<div> </div>
<div>if (hero.is_swing_hoe == false) {</div>
<div> </div>
<div>if(hero.facing != facing1) {</div>
<div>hero.facing = facing1;</div>
<div>hero.wait_time = 0;</div>
<div>}</div>
<div> </div>
<div>else if (hero.can_pass(hero.facing,mv,hero)&& hero.wait_time > 3) {</div>
<div>hero.frame = 1;</div>
<div>hero.move_animation = true;</div>
<div>}</div>
<div>}</div>
<div>return hero;</div>
<div>}</div>
Example 2. This one uses pointers and the function is void and doesn't return anything.
This is the call.
hero->hero_turning(hero,'u',mv);
This is the function
void Entity::hero_turning(Entity * hero, char facing1, vector<Tile> mv) {
if (hero->is_swing_hoe == false) {
if(hero->facing != facing1) {
hero->facing = facing1;
hero->wait_time = 0;
}
else if (hero->can_pass(hero->facing,mv,*hero)&& hero->wait_time > 3) {
hero->frame = 1;
hero->move_animation = true;
}
}
}






