diff options
author | Alexander Kornienko <alexfh@google.com> | 2019-12-12 16:51:08 +0100 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2019-12-12 17:00:57 +0100 |
commit | 65996c302a4472e597780c99bd834f9bf8978712 (patch) | |
tree | 96574f4cd9810a16590833da3bb6049ebc35d9cf /clang-tools-extra/clang-tidy | |
parent | 2b09390c136247b42c1b54f42ce925e31d51062a (diff) | |
download | bcm5719-llvm-65996c302a4472e597780c99bd834f9bf8978712.tar.gz bcm5719-llvm-65996c302a4472e597780c99bd834f9bf8978712.zip |
[clang-tidy] Use early returns to make the code easier to read and potentially run faster
Diffstat (limited to 'clang-tools-extra/clang-tidy')
-rw-r--r-- | clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index 5b78155cd54..e046023106b 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -262,26 +262,25 @@ static bool matchesStyle(StringRef Name, llvm::Regex("^[a-z]([a-z0-9]*(_[A-Z])?)*"), }; - bool Matches = true; if (Name.startswith(Style.Prefix)) Name = Name.drop_front(Style.Prefix.size()); else - Matches = false; + return false; if (Name.endswith(Style.Suffix)) Name = Name.drop_back(Style.Suffix.size()); else - Matches = false; + return false; // Ensure the name doesn't have any extra underscores beyond those specified // in the prefix and suffix. if (Name.startswith("_") || Name.endswith("_")) - Matches = false; + return false; if (Style.Case && !Matchers[static_cast<size_t>(*Style.Case)].match(Name)) - Matches = false; + return false; - return Matches; + return true; } static std::string fixupWithCase(StringRef Name, |