diff options
author | Charles Davis <cdavis@mines.edu> | 2012-05-29 07:01:45 +0000 |
---|---|---|
committer | Charles Davis <cdavis@mines.edu> | 2012-05-29 07:01:45 +0000 |
commit | c4d7675ddd598e3d89237cd04eeba3be322e560c (patch) | |
tree | 118bb80ad380c16e637b544a89168593b8555177 | |
parent | 565204db54a61beacef4eb7a55cfead81ad58834 (diff) |
Use fewer temporaries mangling APSInt objects. The performance difference
is negligible, but it makes the code clearer. Based on a suggestion by
Jordy Rose.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157601 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/MicrosoftMangle.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 753b8174fb..7bcc2f384a 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/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 << '@'; |