Remove spaces after control statements keywords
Spaces are useful to separate independent constructs, but can cause
confusion when added between dependent ones. For example "a*b [i]"
is hard for humans to read correctly at a glance. "a*b[i]" is better,
and "a * b[i]" is the easiest to understand immediately.
Control statements are no different. "if (a)if (b)x;" is hard to parse.
"if (a) if (b) x;" is better, but "if(a) if(b) x;" leaves no confusion
of what belongs where.
This recommendation also follows the 'zero one infinity' rule of thumb:
https://en.wikipedia.org/wiki/Zero_one_infinity_rule
Whether we write "a + b" or "a + b", they are equally readable, and
the additional spaces may help with alignment of surrounding
expressions. "for (int i : c)" on the other hand makes the keyword
unintentionally even more dissociated from its header than
"for (int i : c)" already does.
The argument that the space helps set it apart from function calls seems
moot when practically every editor supports keyword highlighting,
function names are typically longer than 2-3 characters, and function
calls are not followed by curly brackets (which while optional for
singular statements, are still recommended for reasons other than this
one).
Bug: b/144825072
Change-Id: I3432fadae8e5604123f5c537097323504fecbc8c
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39588
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Pipeline/PixelProgram.cpp b/src/Pipeline/PixelProgram.cpp
index 81c137e..332f82e 100644
--- a/src/Pipeline/PixelProgram.cpp
+++ b/src/Pipeline/PixelProgram.cpp
@@ -109,7 +109,7 @@
routine.constants = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData, constants));
auto it = spirvShader->inputBuiltins.find(spv::BuiltInFrontFacing);
- if (it != spirvShader->inputBuiltins.end())
+ if(it != spirvShader->inputBuiltins.end())
{
ASSERT(it->second.SizeInComponents == 1);
auto frontFacing = Int4(*Pointer<Int>(primitive + OFFSET(Primitive, clockwiseMask)));
@@ -117,13 +117,13 @@
}
it = spirvShader->inputBuiltins.find(spv::BuiltInSampleMask);
- if (it != spirvShader->inputBuiltins.end())
+ if(it != spirvShader->inputBuiltins.end())
{
static_assert(SIMD::Width == 4, "Expects SIMD width to be 4");
Int4 laneBits = Int4(1, 2, 4, 8);
Int4 inputSampleMask = Int4(1) & CmpNEQ(Int4(cMask[0]) & laneBits, Int4(0));
- for (auto i = 1u; i < state.multiSample; i++)
+ for(auto i = 1u; i < state.multiSample; i++)
{
inputSampleMask |= Int4(1 << i) & CmpNEQ(Int4(cMask[i]) & laneBits, Int4(0));
}
@@ -131,7 +131,7 @@
routine.getVariable(it->second.Id)[it->second.FirstComponent] = As<Float4>(inputSampleMask);
// Sample mask input is an array, as the spec contemplates MSAA levels higher than 32.
// Fill any non-zero indices with 0.
- for (auto i = 1u; i < it->second.SizeInComponents; i++)
+ for(auto i = 1u; i < it->second.SizeInComponents; i++)
routine.getVariable(it->second.Id)[it->second.FirstComponent + i] = Float4(0);
}
@@ -156,25 +156,25 @@
if(spirvShader->getModes().ContainsKill)
{
- for (auto i = 0u; i < state.multiSample; i++)
+ for(auto i = 0u; i < state.multiSample; i++)
{
cMask[i] &= ~routine.killMask;
}
}
it = spirvShader->outputBuiltins.find(spv::BuiltInSampleMask);
- if (it != spirvShader->outputBuiltins.end())
+ if(it != spirvShader->outputBuiltins.end())
{
auto outputSampleMask = As<SIMD::Int>(routine.getVariable(it->second.Id)[it->second.FirstComponent]);
- for (auto i = 0u; i < state.multiSample; i++)
+ for(auto i = 0u; i < state.multiSample; i++)
{
cMask[i] &= SignMask(CmpNEQ(outputSampleMask & SIMD::Int(1<<i), SIMD::Int(0)));
}
}
it = spirvShader->outputBuiltins.find(spv::BuiltInFragDepth);
- if (it != spirvShader->outputBuiltins.end())
+ if(it != spirvShader->outputBuiltins.end())
{
oDepth = Min(Max(routine.getVariable(it->second.Id)[it->second.FirstComponent], Float4(0.0f)), Float4(1.0f));
}