Finds a Character based on distance and health I need to improve the efficiency of my program and, using the profiler, have narrowed the problem down to 2 key areas, but I am having trouble coming up with ways to make the program run better.

Based on my profiler's report, it seems to be telling me that my if functions are inefficient. Whats a better way to achieve a better result?

Character* FindAttackTarget() const
        {
            float weakestHp = FLT_MAX;
            Character* weakestEnemy = nullptr;
            uint64_t weakestCharId = INT64_MAX;

            //Only attack characters that are within attack range
            auto&amp; gameChars = m_pGame-&gt;m_gameCharacters;


            for (size_t i = 0; i &lt; gameChars.size(); ++i)
            {
                auto&amp; c = gameChars[i];
                if (Location.Dist(c.GetLocation()) &lt;= AttackRange &amp;&amp;
                    c.HP &gt; 0 &amp;&amp;
                    c.Team != Team)
                {
                    //We want the weakest with the lowest ID number - this keeps consistent results when re-playing the same part of the game (eg. after a load game)
                    if (c.HP &lt; weakestHp || (c.HP == weakestHp &amp;&amp; c.ID &lt; weakestCharId))
                    {
                        weakestEnemy = &amp;gameChars[i];
                        weakestHp = c.HP;
                        weakestCharId = c.ID;
                    }
                }
            }

            return weakestEnemy;
        }
The tests c.HP &gt; 0 and c.Team != Team are probably blazingly fast tests.  Location.Dist(c.GetLocation()) &lt;= AttackRange probably involves the square-root of the sum of the squares of the difference of coordinates in two or three dimensions. Plus, GetLocation() may involve memory allocation and/or copying constructors.  It is by far the slowest test, yet you are testing it first!  Take advantage of the short-circuit logical and operators by reordering the tests so the fastest tests are done first, so the slowest test may not even need to be executed, resulting in faster execution. 

Since all conditions must pass before you update weakestEnemy, you could even test whether or not the target passes the “weakest with lowest ID” test before checking the attack range. 

Bonus: the square-root can be avoided; simply compute the square distance, and compare against the \$AttackRange^2\$ (computed outside of the loop) for another speed gain.