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/Device/Context.cpp b/src/Device/Context.cpp
index e41ce74..03987f4 100644
--- a/src/Device/Context.cpp
+++ b/src/Device/Context.cpp
@@ -242,9 +242,9 @@
bool Context::allTargetsColorClamp() const
{
// TODO: remove all of this and support VkPhysicalDeviceFeatures::independentBlend instead
- for (int i = 0; i < RENDERTARGETS; i++)
+ for(int i = 0; i < RENDERTARGETS; i++)
{
- if (renderTarget[i] && renderTarget[i]->getFormat().isFloatFormat())
+ if(renderTarget[i] && renderTarget[i]->getFormat().isFloatFormat())
{
return false;
}
@@ -371,7 +371,7 @@
{
ASSERT((index >= 0) && (index < RENDERTARGETS));
- switch (blendState[index].blendOperationAlpha)
+ switch(blendState[index].blendOperationAlpha)
{
case VK_BLEND_OP_ADD:
case VK_BLEND_OP_SUBTRACT:
@@ -392,7 +392,7 @@
{
ASSERT((index >= 0) && (index < RENDERTARGETS));
- switch (blendState[index].blendOperationAlpha)
+ switch(blendState[index].blendOperationAlpha)
{
case VK_BLEND_OP_ADD:
case VK_BLEND_OP_SUBTRACT:
@@ -413,12 +413,12 @@
{
ASSERT((index >= 0) && (index < RENDERTARGETS));
- switch (blendState[index].blendOperationAlpha)
+ switch(blendState[index].blendOperationAlpha)
{
case VK_BLEND_OP_ADD:
- if (sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
+ if(sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
{
- if (destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
+ if(destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
{
return VK_BLEND_OP_ZERO_EXT;
}
@@ -427,9 +427,9 @@
return VK_BLEND_OP_DST_EXT;
}
}
- else if (sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ONE)
+ else if(sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ONE)
{
- if (destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
+ if(destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
{
return VK_BLEND_OP_SRC_EXT;
}
@@ -440,7 +440,7 @@
}
else
{
- if (destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
+ if(destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
{
return VK_BLEND_OP_SRC_EXT;
}
@@ -450,13 +450,13 @@
}
}
case VK_BLEND_OP_SUBTRACT:
- if (sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO && allTargetsColorClamp())
+ if(sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO && allTargetsColorClamp())
{
return VK_BLEND_OP_ZERO_EXT; // Negative, clamped to zero
}
- else if (sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ONE)
+ else if(sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ONE)
{
- if (destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
+ if(destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
{
return VK_BLEND_OP_SRC_EXT;
}
@@ -467,7 +467,7 @@
}
else
{
- if (destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
+ if(destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
{
return VK_BLEND_OP_SRC_EXT;
}
@@ -477,9 +477,9 @@
}
}
case VK_BLEND_OP_REVERSE_SUBTRACT:
- if (sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
+ if(sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
{
- if (destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
+ if(destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO)
{
return VK_BLEND_OP_ZERO_EXT;
}
@@ -488,9 +488,9 @@
return VK_BLEND_OP_DST_EXT;
}
}
- else if (sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ONE)
+ else if(sourceBlendFactorAlpha(index) == VK_BLEND_FACTOR_ONE)
{
- if (destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO && allTargetsColorClamp())
+ if(destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO && allTargetsColorClamp())
{
return VK_BLEND_OP_ZERO_EXT; // Negative, clamped to zero
}
@@ -501,7 +501,7 @@
}
else
{
- if (destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO && allTargetsColorClamp())
+ if(destBlendFactorAlpha(index) == VK_BLEND_FACTOR_ZERO && allTargetsColorClamp())
{
return VK_BLEND_OP_ZERO_EXT; // Negative, clamped to zero
}
@@ -537,9 +537,9 @@
bool Context::colorWriteActive() const
{
- for (int i = 0; i < RENDERTARGETS; i++)
+ for(int i = 0; i < RENDERTARGETS; i++)
{
- if (colorWriteActive(i))
+ if(colorWriteActive(i))
{
return true;
}