[clang-tidy] Promote some performance-* as a coding error (#7194)
authorLoïc Blot <nerzhul@users.noreply.github.com>
Wed, 4 Apr 2018 18:49:42 +0000 (20:49 +0200)
committerGitHub <noreply@github.com>
Wed, 4 Apr 2018 18:49:42 +0000 (20:49 +0200)
* Promote performance-type-promotion-in-math-fn as a coding error
* Promote performance-faster-string-find too (which is not problematic currently)
* Same for performance-implicit-cast-in-loop
* Fix remaining tidy points

src/content_cao.cpp
src/game.cpp
util/travis/clangtidy.sh

index 81443c824f6cc52459e45972e12cf439321aefab..64109375147add73ac2862ad53c2060186e5de6e 100644 (file)
@@ -908,8 +908,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
                        updateTextures(m_previous_texture_modifier);
                }
        }
-       if(!getParent() && fabs(m_prop.automatic_rotate) > 0.001)
-       {
+       if (!getParent() && std::fabs(m_prop.automatic_rotate) > 0.001) {
                m_yaw += dtime * m_prop.automatic_rotate * 180 / M_PI;
                updateNodePos();
        }
index 3d11ddbaad81ad170648afae3d290add9d021274..4dfb46a125ddb456b4380ab641d9890a2b44f840 100644 (file)
@@ -3638,12 +3638,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
        float time_of_day_smooth = runData.time_of_day_smooth;
        float time_of_day = client->getEnv().getTimeOfDayF();
 
-       static const float maxsm = 0.05;
-       static const float todsm = 0.05;
+       static const float maxsm = 0.05f;
+       static const float todsm = 0.05f;
 
-       if (fabs(time_of_day - time_of_day_smooth) > maxsm &&
-                       fabs(time_of_day - time_of_day_smooth + 1.0) > maxsm &&
-                       fabs(time_of_day - time_of_day_smooth - 1.0) > maxsm)
+       if (std::fabs(time_of_day - time_of_day_smooth) > maxsm &&
+                       std::fabs(time_of_day - time_of_day_smooth + 1.0) > maxsm &&
+                       std::fabs(time_of_day - time_of_day_smooth - 1.0) > maxsm)
                time_of_day_smooth = time_of_day;
 
        if (time_of_day_smooth > 0.8 && time_of_day < 0.2)
@@ -3715,7 +3715,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
                                video::EFT_FOG_LINEAR,
                                100000 * BS,
                                110000 * BS,
-                               0.01,
+                               0.01f,
                                false, // pixel fog
                                false // range fog
                );
index 2d44afe32e0263b8a33a863c8e938fedc0698729..6f76765a15b2d198ef9ed9b16ad9bf57aaf95b91 100755 (executable)
@@ -19,7 +19,7 @@ cd ..
 echo "Performing clang-tidy checks..."
 ./util/travis/run-clang-tidy.py -clang-tidy-binary=${CLANG_TIDY} -p cmakebuild \
        -checks='-*,modernize-use-emplace,modernize-avoid-bind,performance-*' \
-       -warningsaserrors='-*,modernize-use-emplace' \
+       -warningsaserrors='-*,modernize-use-emplace,performance-type-promotion-in-math-fn,performance-faster-string-find,performance-implicit-cast-in-loop' \
        -no-command-on-stdout -quiet \
        files 'src/.*'
 RET=$?