diff options
author | Bruce Mitchener <bruce.mitchener@gmail.com> | 2015-09-01 23:57:17 +0000 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2015-09-01 23:57:17 +0000 |
commit | e8433cc17941d760f8ec96c6f280e152e4f00ef0 (patch) | |
tree | 7a788e52e18bfb377bacbe2cf4660c98cf6486e4 | |
parent | 11deaae8a132906a0acdfa0d5801c5dd1b557b81 (diff) | |
download | bcm5719-llvm-e8433cc17941d760f8ec96c6f280e152e4f00ef0.tar.gz bcm5719-llvm-e8433cc17941d760f8ec96c6f280e152e4f00ef0.zip |
Simplify find_first_of & find_last_of on single char.
Summary:
When calling find_first_of and find_last_of on a single character,
we can instead just call find / rfind and make our intent more
clear.
Reviewers: clayborg
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D12518
llvm-svn: 246609
-rw-r--r-- | lldb/source/Core/FormatEntity.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Host/common/FileSpec.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Host/common/ThisThread.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Utility/UriParser.cpp | 2 | ||||
-rw-r--r-- | lldb/tools/lldb-mi/MICmdArgValFile.cpp | 8 | ||||
-rw-r--r-- | lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp | 4 | ||||
-rw-r--r-- | lldb/tools/lldb-mi/MICmdArgValString.cpp | 4 | ||||
-rw-r--r-- | lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp | 2 | ||||
-rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdBreak.cpp | 4 |
11 files changed, 19 insertions, 19 deletions
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index a53b46a5301..4e0258889f1 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -2424,10 +2424,10 @@ FormatEntity::ExtractVariableInfo (llvm::StringRef &format_str, llvm::StringRef variable_name = llvm::StringRef(); variable_format = llvm::StringRef(); - const size_t paren_pos = format_str.find_first_of('}'); + const size_t paren_pos = format_str.find('}'); if (paren_pos != llvm::StringRef::npos) { - const size_t percent_pos = format_str.find_first_of('%'); + const size_t percent_pos = format_str.find('%'); if (percent_pos < paren_pos) { if (percent_pos > 0) diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp index a917a89d507..9efdacb010b 100644 --- a/lldb/source/Host/common/FileSpec.cpp +++ b/lldb/source/Host/common/FileSpec.cpp @@ -107,7 +107,7 @@ FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path) return; llvm::StringRef path_str(path.data(), path.size()); - size_t slash_pos = path_str.find_first_of("/", 1); + size_t slash_pos = path_str.find('/', 1); if (slash_pos == 1 || path.size() == 1) { // A path of ~/ resolves to the current user's home dir diff --git a/lldb/source/Host/common/ThisThread.cpp b/lldb/source/Host/common/ThisThread.cpp index 289ec780e9f..763701441c1 100644 --- a/lldb/source/Host/common/ThisThread.cpp +++ b/lldb/source/Host/common/ThisThread.cpp @@ -37,7 +37,7 @@ ThisThread::SetName(llvm::StringRef name, int max_length) { // We're still too long. Since this is a dotted component, use everything after the last // dot, up to a maximum of |length| characters. - std::string::size_type last_dot = truncated_name.find_last_of("."); + std::string::size_type last_dot = truncated_name.rfind('.'); if (last_dot != std::string::npos) begin = last_dot + 1; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index 40879e1100a..9308c7a668d 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -230,7 +230,7 @@ AppleObjCTypeEncodingParser::BuildObjCObjectPointerType (clang::ASTContext &ast_ if (for_expression && !name.empty()) { - size_t less_than_pos = name.find_first_of('<'); + size_t less_than_pos = name.find('<'); if (less_than_pos != std::string::npos) { diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index cc477783b67..b3670b5a30d 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -609,12 +609,12 @@ RSModuleDescriptor::ParseRSInfo() std::string info((const char *)buffer->GetBytes()); std::vector<std::string> info_lines; - size_t lpos = info.find_first_of("\n"); + size_t lpos = info.find('\n'); while (lpos != std::string::npos) { info_lines.push_back(info.substr(0, lpos)); info = info.substr(lpos + 1); - lpos = info.find_first_of("\n"); + lpos = info.find('\n'); } size_t offset = 0; while (offset < info_lines.size()) diff --git a/lldb/source/Utility/UriParser.cpp b/lldb/source/Utility/UriParser.cpp index 6febae2b17b..77e16b02aae 100644 --- a/lldb/source/Utility/UriParser.cpp +++ b/lldb/source/Utility/UriParser.cpp @@ -40,7 +40,7 @@ UriParser::Parse(const std::string& uri, // Extract path. tmp_scheme = uri.substr(0, pos); auto host_pos = pos + strlen(kSchemeSep); - auto path_pos = uri.find_first_of("/", host_pos); + auto path_pos = uri.find('/', host_pos); if (path_pos != std::string::npos) tmp_path = uri.substr(path_pos); else diff --git a/lldb/tools/lldb-mi/MICmdArgValFile.cpp b/lldb/tools/lldb-mi/MICmdArgValFile.cpp index 9e59dec1d02..7f5b20ec314 100644 --- a/lldb/tools/lldb-mi/MICmdArgValFile.cpp +++ b/lldb/tools/lldb-mi/MICmdArgValFile.cpp @@ -142,8 +142,8 @@ CMICmdArgValFile::IsFilePath(const CMIUtilString &vrFileNamePath) const if (vrFileNamePath.empty()) return false; - const bool bHavePosSlash = (vrFileNamePath.find_first_of("/") != std::string::npos); - const bool bHaveBckSlash = (vrFileNamePath.find_first_of("\\") != std::string::npos); + const bool bHavePosSlash = (vrFileNamePath.find('/') != std::string::npos); + const bool bHaveBckSlash = (vrFileNamePath.find('\\') != std::string::npos); // Look for --someLongOption size_t nPos = vrFileNamePath.find("--"); @@ -152,13 +152,13 @@ CMICmdArgValFile::IsFilePath(const CMIUtilString &vrFileNamePath) const return false; // Look for -f type short parameters - nPos = vrFileNamePath.find_first_of("-"); + nPos = vrFileNamePath.find('-'); const bool bShort = (nPos == 0); if (bShort) return false; // Look for i1 i2 i3.... - nPos = vrFileNamePath.find_first_of("i"); + nPos = vrFileNamePath.find('i'); const bool bFoundI1 = ((nPos == 0) && (::isdigit(vrFileNamePath[1]))); if (bFoundI1) return false; diff --git a/lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp b/lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp index fef180e04b9..1b03849829f 100644 --- a/lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp +++ b/lldb/tools/lldb-mi/MICmdArgValOptionLong.cpp @@ -249,8 +249,8 @@ CMICmdArgValOptionLong::ExtractExpectedOptions(CMICmdArgContext &vrwTxt, const M bool CMICmdArgValOptionLong::IsArgLongOption(const CMIUtilString &vrTxt) const { - const bool bHavePosSlash = (vrTxt.find_first_of("/") != std::string::npos); - const bool bHaveBckSlash = (vrTxt.find_first_of("\\") != std::string::npos); + const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos); + const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos); if (bHavePosSlash || bHaveBckSlash) return false; diff --git a/lldb/tools/lldb-mi/MICmdArgValString.cpp b/lldb/tools/lldb-mi/MICmdArgValString.cpp index aefcffeadf4..bea59355232 100644 --- a/lldb/tools/lldb-mi/MICmdArgValString.cpp +++ b/lldb/tools/lldb-mi/MICmdArgValString.cpp @@ -220,8 +220,8 @@ CMICmdArgValString::IsStringArgSingleText(const CMIUtilString &vrTxt) const if (!m_bHandleDirPaths) { // Look for directory file paths, if found reject - const bool bHavePosSlash = (vrTxt.find_first_of("/") != std::string::npos); - const bool bHaveBckSlash = (vrTxt.find_first_of("\\") != std::string::npos); + const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos); + const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos); if (bHavePosSlash || bHaveBckSlash) return false; } diff --git a/lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp b/lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp index 400ec70dca9..6b79fc84ee9 100644 --- a/lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp +++ b/lldb/tools/lldb-mi/MICmdArgValThreadGrp.cpp @@ -117,7 +117,7 @@ bool CMICmdArgValThreadGrp::IsArgThreadGrp(const CMIUtilString &vrTxt) const { // Look for i1 i2 i3.... - const MIint nPos = vrTxt.find_first_of("i"); + const MIint nPos = vrTxt.find('i'); if (nPos != 0) return false; diff --git a/lldb/tools/lldb-mi/MICmdCmdBreak.cpp b/lldb/tools/lldb-mi/MICmdCmdBreak.cpp index 87db5ab753a..3c16e2e1c6e 100644 --- a/lldb/tools/lldb-mi/MICmdCmdBreak.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdBreak.cpp @@ -118,10 +118,10 @@ static size_t findFileSeparatorPos(const std::string& x) { // Full paths in windows can have ':' after a drive letter, so we // search backwards, taking care to skip C++ namespace tokens '::'. - size_t n = x.find_last_of(':'); + size_t n = x.rfind(':'); while (n != std::string::npos && n > 1 && x[n-1] == ':') { - n = x.find_last_of(':', n - 2); + n = x.rfind(':', n - 2); } return n; } |