[cfe-commits] r100928 - /cfe/trunk/lib/CodeGen/Mangle.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sat Apr 10 09:03:31 PDT 2010
Author: d0k
Date: Sat Apr 10 11:03:31 2010
New Revision: 100928
URL: http://llvm.org/viewvc/llvm-project?rev=100928&view=rev
Log:
A bunch of string-related microoptimizations in Mangler.
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=100928&r1=100927&r2=100928&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Sat Apr 10 11:03:31 2010
@@ -1305,7 +1305,7 @@
mangleCalledExpression(CE->getCallee(), CE->getNumArgs());
for (unsigned I = 0, N = CE->getNumArgs(); I != N; ++I)
mangleExpression(CE->getArg(I));
- Out << "E";
+ Out << 'E';
break;
}
@@ -1349,9 +1349,9 @@
Out << "cv";
mangleType(CE->getType());
- if (N != 1) Out << "_";
+ if (N != 1) Out << '_';
for (unsigned I = 0; I != N; ++I) mangleExpression(CE->getArg(I));
- if (N != 1) Out << "E";
+ if (N != 1) Out << 'E';
break;
}
@@ -1362,21 +1362,21 @@
Out << "cv";
mangleType(CE->getType());
- if (N != 1) Out << "_";
+ if (N != 1) Out << '_';
for (unsigned I = 0; I != N; ++I) mangleExpression(CE->getArg(I));
- if (N != 1) Out << "E";
+ if (N != 1) Out << 'E';
break;
}
case Expr::SizeOfAlignOfExprClass: {
const SizeOfAlignOfExpr *SAE = cast<SizeOfAlignOfExpr>(E);
- if (SAE->isSizeOf()) Out << "s";
- else Out << "a";
+ if (SAE->isSizeOf()) Out << 's';
+ else Out << 'a';
if (SAE->isArgumentType()) {
- Out << "t";
+ Out << 't';
mangleType(SAE->getArgumentType());
} else {
- Out << "z";
+ Out << 'z';
mangleExpression(SAE->getArgumentExpr());
}
break;
@@ -1504,7 +1504,7 @@
case Expr::FloatingLiteralClass: {
const FloatingLiteral *FL = cast<FloatingLiteral>(E);
- Out << "L";
+ Out << 'L';
mangleType(FL->getType());
// TODO: avoid this copy with careful stream management.
@@ -1512,12 +1512,12 @@
FL->getValue().bitcastToAPInt().toString(Buffer, 16, false);
Out.write(Buffer.data(), Buffer.size());
- Out << "E";
+ Out << 'E';
break;
}
case Expr::CharacterLiteralClass:
- Out << "L";
+ Out << 'L';
mangleType(E->getType());
Out << cast<CharacterLiteral>(E)->getValue();
Out << 'E';
@@ -1579,20 +1579,20 @@
void CXXNameMangler::mangleTemplateArgs(const TemplateParameterList &PL,
const TemplateArgumentList &AL) {
// <template-args> ::= I <template-arg>+ E
- Out << "I";
+ Out << 'I';
for (unsigned i = 0, e = AL.size(); i != e; ++i)
mangleTemplateArg(PL.getParam(i), AL[i]);
- Out << "E";
+ Out << 'E';
}
void CXXNameMangler::mangleTemplateArgs(const TemplateParameterList &PL,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs) {
// <template-args> ::= I <template-arg>+ E
- Out << "I";
+ Out << 'I';
for (unsigned i = 0; i != NumTemplateArgs; ++i)
mangleTemplateArg(PL.getParam(i), TemplateArgs[i]);
- Out << "E";
+ Out << 'E';
}
void CXXNameMangler::mangleTemplateArg(const NamedDecl *P,
@@ -1688,8 +1688,7 @@
}
bool CXXNameMangler::mangleSubstitution(uintptr_t Ptr) {
- llvm::DenseMap<uintptr_t, unsigned>::iterator I =
- Substitutions.find(Ptr);
+ llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
if (I == Substitutions.end())
return false;
@@ -1701,9 +1700,8 @@
// <seq-id> is encoded in base-36, using digits and upper case letters.
char Buffer[10];
- char *BufferPtr = Buffer + 9;
+ char *BufferPtr = llvm::array_endof(Buffer);
- *BufferPtr = 0;
if (SeqID == 0) *--BufferPtr = '0';
while (SeqID) {
@@ -1715,7 +1713,9 @@
SeqID /= 36;
}
- Out << 'S' << BufferPtr << '_';
+ Out << 'S'
+ << llvm::StringRef(BufferPtr, llvm::array_endof(Buffer)-BufferPtr)
+ << '_';
}
return true;
@@ -1990,7 +1990,7 @@
Mangler.getStream() << "_ZTC";
Mangler.mangleName(RD);
Mangler.getStream() << Offset;
- Mangler.getStream() << "_";
+ Mangler.getStream() << '_';
Mangler.mangleName(Type);
}
More information about the cfe-commits
mailing list