[lld] r193712 - Use StringRef::startswith_lower().
Rui Ueyama
ruiu at google.com
Wed Oct 30 13:33:51 PDT 2013
Author: ruiu
Date: Wed Oct 30 15:33:51 2013
New Revision: 193712
URL: http://llvm.org/viewvc/llvm-project?rev=193712&view=rev
Log:
Use StringRef::startswith_lower().
Modified:
lld/trunk/lib/Driver/WinLinkDriver.cpp
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=193712&r1=193711&r2=193712&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Wed Oct 30 15:33:51 2013
@@ -151,33 +151,25 @@ llvm::COFF::MachineTypes stringToMachine
// Parse /manifest:EMBED[,ID=#]|NO.
bool parseManifest(StringRef option, bool &enable, bool &embed, int &id) {
- std::string optionLower = option.lower();
- if (optionLower == "no") {
+ if (option.equals_lower("no")) {
enable = false;
return true;
}
- if (!StringRef(optionLower).startswith("embed"))
+ if (!option.startswith_lower("embed"))
return false;
embed = true;
- optionLower = optionLower.substr(strlen("embed"));
- if (optionLower.empty())
+ option = option.substr(strlen("embed"));
+ if (option.empty())
return true;
- if (!StringRef(optionLower).startswith(",id="))
+ if (!option.startswith_lower(",id="))
return false;
- optionLower = optionLower.substr(strlen(",id="));
- if (StringRef(optionLower).getAsInteger(0, id))
+ option = option.substr(strlen(",id="));
+ if (option.getAsInteger(0, id))
return false;
return true;
}
-// Returns true if \p str starts with \p prefix, ignoring case.
-bool startswith_lower(StringRef str, StringRef prefix) {
- if (str.size() < prefix.size())
- return false;
- return str.substr(0, prefix.size()).equals_lower(prefix);
-}
-
// Parse /manifestuac:(level=<string>|uiAccess=<string>).
//
// The arguments will be embedded to the manifest XML file with no error check,
@@ -189,14 +181,14 @@ bool parseManifestUac(StringRef option,
option = option.ltrim();
if (option.empty())
return true;
- if (startswith_lower(option, "level=")) {
+ if (option.startswith_lower("level=")) {
option = option.substr(strlen("level="));
StringRef value;
llvm::tie(value, option) = option.split(" ");
level = value.str();
continue;
}
- if (startswith_lower(option, "uiaccess=")) {
+ if (option.startswith_lower("uiaccess=")) {
option = option.substr(strlen("uiaccess="));
StringRef value;
llvm::tie(value, option) = option.split(" ");
More information about the llvm-commits
mailing list