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/SamplerCore.cpp b/src/Pipeline/SamplerCore.cpp
index 86228a5..b2c2268 100644
--- a/src/Pipeline/SamplerCore.cpp
+++ b/src/Pipeline/SamplerCore.cpp
@@ -33,7 +33,7 @@
case VK_COMPONENT_SWIZZLE_A: f = c.w; break;
case VK_COMPONENT_SWIZZLE_ZERO: f = sw::Float4(0.0f, 0.0f, 0.0f, 0.0f); break;
case VK_COMPONENT_SWIZZLE_ONE:
- if (integer)
+ if(integer)
{
f = rr::As<sw::Float4>(sw::Int4(1, 1, 1, 1));
}
@@ -155,9 +155,9 @@
{
c = sampleFloatFilter(texture, uuuu, vvvv, wwww, qqqq, offset, cubeArrayCoord, sampleId, lod, anisotropy, uDelta, vDelta, function);
- if (!hasFloatTexture() && !hasUnnormalizedIntegerTexture() && !state.compareEnable)
+ if(!hasFloatTexture() && !hasUnnormalizedIntegerTexture() && !state.compareEnable)
{
- switch (state.textureFormat)
+ switch(state.textureFormat)
{
case VK_FORMAT_R5G6B5_UNORM_PACK16:
c.x *= Float4(1.0f / 0xF800);
@@ -200,7 +200,7 @@
c.w *= Float4(1.0f / 0xFF00u);
break;
default:
- for (int component = 0; component < textureComponentCount(); component++)
+ for(int component = 0; component < textureComponentCount(); component++)
{
c[component] *= Float4(hasUnsignedTextureComponent(component) ? 1.0f / 0xFFFF : 1.0f / 0x7FFF);
}
@@ -211,7 +211,7 @@
{
Vector4s cs = sampleFilter(texture, uuuu, vvvv, wwww, offset, cubeArrayCoord, sampleId, lod, anisotropy, uDelta, vDelta, function);
- switch (state.textureFormat)
+ switch(state.textureFormat)
{
case VK_FORMAT_R5G6B5_UNORM_PACK16:
c.x = Float4(As<UShort4>(cs.x)) * Float4(1.0f / 0xF800);
@@ -1646,7 +1646,7 @@
}
else ASSERT(false);
- if (state.textureFormat.isSRGBformat())
+ if(state.textureFormat.isSRGBformat())
{
for(int i = 0; i < textureComponentCount(); i++)
{
@@ -1830,7 +1830,7 @@
if(hasFloatTexture() || has32bitIntegerTextureComponents())
{
- switch (state.textureFormat)
+ switch(state.textureFormat)
{
case VK_FORMAT_R16_SFLOAT:
t0 = Int4(*Pointer<UShort4>(buffer + index[0] * 2));