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/+/39588Tested-by:Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by:
Ben Clayton <bclayton@google.com>
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| SubmoduleCheck/gtest | Loading commit data... | |
| BUILD.gn | Loading commit data... | |
| CPUID.cpp | Loading commit data... | |
| CPUID.hpp | Loading commit data... | |
| Coroutine.hpp | Loading commit data... | |
| Debug.cpp | Loading commit data... | |
| Debug.hpp | Loading commit data... | |
| DebugAndroid.cpp | Loading commit data... | |
| DebugAndroid.hpp | Loading commit data... | |
| EmulatedReactor.cpp | Loading commit data... | |
| EmulatedReactor.hpp | Loading commit data... | |
| ExecutableMemory.cpp | Loading commit data... | |
| ExecutableMemory.hpp | Loading commit data... | |
| LLVMReactor.cpp | Loading commit data... | |
| LLVMReactor.hpp | Loading commit data... | |
| LLVMReactorDebugInfo.cpp | Loading commit data... | |
| LLVMReactorDebugInfo.hpp | Loading commit data... | |
| MutexLock.hpp | Loading commit data... | |
| Nucleus.hpp | Loading commit data... | |
| Optimizer.cpp | Loading commit data... | |
| Optimizer.hpp | Loading commit data... | |
| Print.hpp | Loading commit data... | |
| Reactor.cpp | Loading commit data... | |
| Reactor.hpp | Loading commit data... | |
| Reactor.vcxproj | Loading commit data... | |
| Reactor.vcxproj.filters | Loading commit data... | |
| ReactorUnitTests.cpp | Loading commit data... | |
| ReactorUnitTests.vcxproj | Loading commit data... | |
| ReactorUnitTests.vcxproj.filters | Loading commit data... | |
| ReactorUnitTests.vcxproj.user | Loading commit data... | |
| Routine.hpp | Loading commit data... | |
| Subzero.vcxproj | Loading commit data... | |
| Subzero.vcxproj.filters | Loading commit data... | |
| SubzeroLLVMDependencies.vcxproj | Loading commit data... | |
| SubzeroLLVMDependencies.vcxproj.filters | Loading commit data... | |
| SubzeroReactor.cpp | Loading commit data... | |
| Thread.cpp | Loading commit data... | |
| Thread.hpp | Loading commit data... | |
| Traits.hpp | Loading commit data... | |
| Traits.inl | Loading commit data... | |
| x86.hpp | Loading commit data... |