[lld] 0534791 - lld/COFF: simplify startswith+substr
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 15:28:15 PST 2023
Author: Fangrui Song
Date: 2023-01-30T15:28:10-08:00
New Revision: 053479118f18e0407f6b91304ebf19a8a735ec1f
URL: https://github.com/llvm/llvm-project/commit/053479118f18e0407f6b91304ebf19a8a735ec1f
DIFF: https://github.com/llvm/llvm-project/commit/053479118f18e0407f6b91304ebf19a8a735ec1f.diff
LOG: lld/COFF: simplify startswith+substr
Added:
Modified:
lld/COFF/Driver.cpp
Removed:
################################################################################
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index a927d414e7b18..bd859140209ba 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1765,20 +1765,17 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
ltoDebugPM = true;
} else if (s == "noltodebugpassmanager") {
ltoDebugPM = false;
- } else if (s.startswith("lldlto=")) {
- StringRef optLevel = s.substr(7);
- if (optLevel.getAsInteger(10, config->ltoo) || config->ltoo > 3)
- error("/opt:lldlto: invalid optimization level: " + optLevel);
- } else if (s.startswith("lldltojobs=")) {
- StringRef jobs = s.substr(11);
- if (!get_threadpool_strategy(jobs))
- error("/opt:lldltojobs: invalid job count: " + jobs);
- config->thinLTOJobs = jobs.str();
- } else if (s.startswith("lldltopartitions=")) {
- StringRef n = s.substr(17);
- if (n.getAsInteger(10, config->ltoPartitions) ||
+ } else if (s.consume_front("lldlto=")) {
+ if (s.getAsInteger(10, config->ltoo) || config->ltoo > 3)
+ error("/opt:lldlto: invalid optimization level: " + s);
+ } else if (s.consume_front("lldltojobs=")) {
+ if (!get_threadpool_strategy(s))
+ error("/opt:lldltojobs: invalid job count: " + s);
+ config->thinLTOJobs = s.str();
+ } else if (s.consume_front("lldltopartitions=")) {
+ if (s.getAsInteger(10, config->ltoPartitions) ||
config->ltoPartitions == 0)
- error("/opt:lldltopartitions: invalid partition count: " + n);
+ error("/opt:lldltopartitions: invalid partition count: " + s);
} else if (s != "lbr" && s != "nolbr")
error("/opt: unknown option: " + s);
}
More information about the llvm-commits
mailing list