Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
S
swiftshader
  • Project
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Chen Yisong
  • swiftshader
  • Repository

Switch branch/tag
  • swiftshader
  • src
  • Device
  • Config.cpp
Find file
BlameHistoryPermalink
  • Nicolas Capens's avatar
    Do not indent C++ namespace contents · 157ba260
    Nicolas Capens authored Dec 10, 2019
    This is a style change. Visual Studio defaults to indenting namespace
    contents, and this was adopted for a long time, but with the new Vulkan
    implementation this was abandoned. However the legacy code borrowed from
    the OpenGL ES implementation still used indentation so it was
    inconsistent.
    
    The justification for not indenting namespace contents is that
    namespaces are merely a way to avoid name clashes with other projects
    we don't control directly (and in rare cases internal subprojects when
    we want to reuse the same names). Hence the vast majority of files have
    a single namespace, and unlike indentation used for ease of discerning
    control flow blocks, class contents, or function contents, which can
    become highly nested, there is no such readability advantage to
    indenting namespace contents.
    
    This is also the Google style recommendation (though no justification or
    discussion is provided):
    https://google.github.io/styleguide/cppguide.html#Namespace_Formatting
    
    One reasonable counter-argument is consistency with other blocks of
    curly brackets, but considering that most namespaces span almost the
    entire file, it's a substantial waste of line length.
    
    Because there is no indentation, there's also no need to have the open
    and closing brackets line up as a visual aid, like we prefer for other
    uses of curly brackets. So we place the open bracket on the same line as
    the namespace keyword.
    
    A comment is added to the closing bracket to discern it from other
    closing brackets. It also makes it easier to find the end of anonymous
    namespaces which typically go at the top of the source file.
    
    This change is make separately from applying clang-format because diff
    tools mark all these unindented lines as changes and this makes it hard
    to review the smaller style changes made by clang-format. The OpenGL ES
    and Direct3D code is left untouched because it is in maintenance mode
    and in case of regressions we want easy 'blame' tool usage.
    
    Bug: b/144825072
    Change-Id: Ie2925ebd697e1ffa7c4cbdc9a946531f11f4d934
    Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39348
    Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
    Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
    Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
    157ba260
Config.cpp 1.09 KB
EditWeb IDE
×

Replace Config.cpp

Attach a file by drag & drop or click to upload


Cancel
A new branch will be created in your fork and a new merge request will be started.