diff options
author | Alexander Potapenko <glider@google.com> | 2016-05-23 13:58:04 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2016-05-23 13:58:04 +0000 |
commit | 1c9f2a9b4336d20e4e90ccea0d53e749b806bb9b (patch) | |
tree | 935716f1d8f9790b4a4b1c45588e7ad797a48867 | |
parent | f6a6e81b7ef51de0cd9cdd7e1b4d566246349b79 (diff) |
[InlineAsm] Avoid creating extra string instances in ConstraintInfo::Parse()
Don't create unnecessary std::string objects when pushing back to |pCodes|.
NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270436 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/IR/InlineAsm.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/IR/InlineAsm.cpp b/lib/IR/InlineAsm.cpp index 15d3b830b8f..d6cf8c543db 100644 --- a/lib/IR/InlineAsm.cpp +++ b/lib/IR/InlineAsm.cpp @@ -142,14 +142,14 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str, // Find the end of the register name. StringRef::iterator ConstraintEnd = std::find(I+1, E, '}'); if (ConstraintEnd == E) return true; // "{foo" - pCodes->push_back(std::string(I, ConstraintEnd+1)); + pCodes->push_back(StringRef(I, ConstraintEnd+1 - I)); I = ConstraintEnd+1; } else if (isdigit(static_cast<unsigned char>(*I))) { // Matching Constraint // Maximal munch numbers. StringRef::iterator NumStart = I; while (I != E && isdigit(static_cast<unsigned char>(*I))) ++I; - pCodes->push_back(std::string(NumStart, I)); + pCodes->push_back(StringRef(NumStart, I - NumStart)); unsigned N = atoi(pCodes->back().c_str()); // Check that this is a valid matching constraint! if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[N].Type != isOutput|| @@ -183,11 +183,11 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str, } else if (*I == '^') { // Multi-letter constraint // FIXME: For now assuming these are 2-character constraints. - pCodes->push_back(std::string(I+1, I+3)); + pCodes->push_back(StringRef(I+1, 2)); I += 3; } else { // Single letter constraint. - pCodes->push_back(std::string(I, I+1)); + pCodes->push_back(StringRef(I, 1)); ++I; } } |