Skip to content

Commit 077f231

Browse files
authoredApr 4, 2018
[clang-tidy] Promote some performance-* as a coding error (#7194)
* 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
1 parent 392e80e commit 077f231

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed
 

Diff for: ‎src/content_cao.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
908908
updateTextures(m_previous_texture_modifier);
909909
}
910910
}
911-
if(!getParent() && fabs(m_prop.automatic_rotate) > 0.001)
912-
{
911+
if (!getParent() && std::fabs(m_prop.automatic_rotate) > 0.001) {
913912
m_yaw += dtime * m_prop.automatic_rotate * 180 / M_PI;
914913
updateNodePos();
915914
}

Diff for: ‎src/game.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -3638,12 +3638,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
36383638
float time_of_day_smooth = runData.time_of_day_smooth;
36393639
float time_of_day = client->getEnv().getTimeOfDayF();
36403640

3641-
static const float maxsm = 0.05;
3642-
static const float todsm = 0.05;
3641+
static const float maxsm = 0.05f;
3642+
static const float todsm = 0.05f;
36433643

3644-
if (fabs(time_of_day - time_of_day_smooth) > maxsm &&
3645-
fabs(time_of_day - time_of_day_smooth + 1.0) > maxsm &&
3646-
fabs(time_of_day - time_of_day_smooth - 1.0) > maxsm)
3644+
if (std::fabs(time_of_day - time_of_day_smooth) > maxsm &&
3645+
std::fabs(time_of_day - time_of_day_smooth + 1.0) > maxsm &&
3646+
std::fabs(time_of_day - time_of_day_smooth - 1.0) > maxsm)
36473647
time_of_day_smooth = time_of_day;
36483648

36493649
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,
37153715
video::EFT_FOG_LINEAR,
37163716
100000 * BS,
37173717
110000 * BS,
3718-
0.01,
3718+
0.01f,
37193719
false, // pixel fog
37203720
false // range fog
37213721
);

Diff for: ‎util/travis/clangtidy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ cd ..
1919
echo "Performing clang-tidy checks..."
2020
./util/travis/run-clang-tidy.py -clang-tidy-binary=${CLANG_TIDY} -p cmakebuild \
2121
-checks='-*,modernize-use-emplace,modernize-avoid-bind,performance-*' \
22-
-warningsaserrors='-*,modernize-use-emplace' \
22+
-warningsaserrors='-*,modernize-use-emplace,performance-type-promotion-in-math-fn,performance-faster-string-find,performance-implicit-cast-in-loop' \
2323
-no-command-on-stdout -quiet \
2424
files 'src/.*'
2525
RET=$?

0 commit comments

Comments
 (0)
Please sign in to comment.