forked from OSchip/llvm-project
[InlineAsm] Avoid creating extra string instances in ConstraintInfo::Parse()
Don't create unnecessary std::string objects when pushing back to |pCodes|. NFC. llvm-svn: 270436
This commit is contained in:
parent
c345705bee
commit
7d68c2604a
|
@ -142,14 +142,14 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
|
||||||
// Find the end of the register name.
|
// Find the end of the register name.
|
||||||
StringRef::iterator ConstraintEnd = std::find(I+1, E, '}');
|
StringRef::iterator ConstraintEnd = std::find(I+1, E, '}');
|
||||||
if (ConstraintEnd == E) return true; // "{foo"
|
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;
|
I = ConstraintEnd+1;
|
||||||
} else if (isdigit(static_cast<unsigned char>(*I))) { // Matching Constraint
|
} else if (isdigit(static_cast<unsigned char>(*I))) { // Matching Constraint
|
||||||
// Maximal munch numbers.
|
// Maximal munch numbers.
|
||||||
StringRef::iterator NumStart = I;
|
StringRef::iterator NumStart = I;
|
||||||
while (I != E && isdigit(static_cast<unsigned char>(*I)))
|
while (I != E && isdigit(static_cast<unsigned char>(*I)))
|
||||||
++I;
|
++I;
|
||||||
pCodes->push_back(std::string(NumStart, I));
|
pCodes->push_back(StringRef(NumStart, I - NumStart));
|
||||||
unsigned N = atoi(pCodes->back().c_str());
|
unsigned N = atoi(pCodes->back().c_str());
|
||||||
// Check that this is a valid matching constraint!
|
// Check that this is a valid matching constraint!
|
||||||
if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[N].Type != isOutput||
|
if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[N].Type != isOutput||
|
||||||
|
@ -183,11 +183,11 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
|
||||||
} else if (*I == '^') {
|
} else if (*I == '^') {
|
||||||
// Multi-letter constraint
|
// Multi-letter constraint
|
||||||
// FIXME: For now assuming these are 2-character constraints.
|
// 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;
|
I += 3;
|
||||||
} else {
|
} else {
|
||||||
// Single letter constraint.
|
// Single letter constraint.
|
||||||
pCodes->push_back(std::string(I, I+1));
|
pCodes->push_back(StringRef(I, 1));
|
||||||
++I;
|
++I;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue