summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/MicrosoftMangle.cpp
diff options
context:
space:
mode:
authorCharles Davis <cdavis@mines.edu>2012-05-29 07:01:45 +0000
committerCharles Davis <cdavis@mines.edu>2012-05-29 07:01:45 +0000
commite8ccc1134bf2b5597517ffce0e27d1c4f72bf9b7 (patch)
tree7428dcb278725ae7d9a463565771e00e6e524d49 /clang/lib/AST/MicrosoftMangle.cpp
parent80bc3b0d2b2828a124ec8b37c427cb65fffd4e40 (diff)
downloadbcm5719-llvm-e8ccc1134bf2b5597517ffce0e27d1c4f72bf9b7.tar.gz
bcm5719-llvm-e8ccc1134bf2b5597517ffce0e27d1c4f72bf9b7.zip
Use fewer temporaries mangling APSInt objects. The performance difference
is negligible, but it makes the code clearer. Based on a suggestion by Jordy Rose. llvm-svn: 157601
Diffstat (limited to 'clang/lib/AST/MicrosoftMangle.cpp')
-rw-r--r--clang/lib/AST/MicrosoftMangle.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index 753b8174fb2..7bcc2f384ac 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -308,10 +308,11 @@ void MicrosoftCXXNameMangler::mangleNumber(const llvm::APSInt &Value) {
mangleNumber(llvm::APSInt(Value.abs()));
return;
}
- if (Value.uge(1) && Value.ule(10))
- (Value-llvm::APSInt(llvm::APInt(Value.getBitWidth(), 1, Value.isSigned()),
- Value.isUnsigned())).print(Out, false);
- else {
+ llvm::APSInt Temp(Value);
+ if (Value.uge(1) && Value.ule(10)) {
+ --Temp;
+ Temp.print(Out, false);
+ } else {
// We have to build up the encoding in reverse order, so it will come
// out right when we write it out.
char Encoding[64];
@@ -320,8 +321,8 @@ void MicrosoftCXXNameMangler::mangleNumber(const llvm::APSInt &Value) {
llvm::APSInt NibbleMask(Value.getBitWidth(), Value.isUnsigned());
NibbleMask = 0xf;
for (int i = 0, e = Value.getActiveBits() / 4; i != e; ++i) {
- *--CurPtr = 'A' + Value.And(NibbleMask).lshr(i*4).getLimitedValue(0xf);
- NibbleMask = NibbleMask.shl(4);
+ *--CurPtr = 'A' + Temp.And(NibbleMask).getLimitedValue(0xf);
+ Temp = Temp.lshr(4);
};
Out.write(CurPtr, EndPtr-CurPtr);
Out << '@';
OpenPOWER on IntegriCloud