From e3063b0495bdd43940c5f3d1806c69c18085d096 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 7 Apr 2013 18:34:16 -0700 Subject: [PATCH] Some small optimizations. --- src/cpp/ripple/Amount.cpp | 12 ++++++++---- src/cpp/ripple/AmountRound.cpp | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cpp/ripple/Amount.cpp b/src/cpp/ripple/Amount.cpp index df38bbee76..cdf7bfd953 100644 --- a/src/cpp/ripple/Amount.cpp +++ b/src/cpp/ripple/Amount.cpp @@ -1148,21 +1148,25 @@ STAmount STAmount::deserialize(SerializerIterator& it) std::string STAmount::getFullText() const { + static boost::format nativeFormat("%s/" SYSTEM_CURRENCY_CODE); + static boost::format noIssuer("%s/%s/0"); + static boost::format issuerOne("%s/%s/1"); + static boost::format normal("%s/%s/%s"); if (mIsNative) { - return str(boost::format("%s/" SYSTEM_CURRENCY_CODE) % getText()); + return str(nativeFormat % getText()); } else if (!mIssuer) { - return str(boost::format("%s/%s/0") % getText() % getHumanCurrency()); + return str(noIssuer % getText() % getHumanCurrency()); } else if (mIssuer == ACCOUNT_ONE) { - return str(boost::format("%s/%s/1") % getText() % getHumanCurrency()); + return str(issuerOne % getText() % getHumanCurrency()); } else { - return str(boost::format("%s/%s/%s") + return str(normal % getText() % getHumanCurrency() % RippleAddress::createHumanAccountID(mIssuer)); diff --git a/src/cpp/ripple/AmountRound.cpp b/src/cpp/ripple/AmountRound.cpp index 5a778b4f74..e25eba9f19 100644 --- a/src/cpp/ripple/AmountRound.cpp +++ b/src/cpp/ripple/AmountRound.cpp @@ -27,7 +27,7 @@ static void canonicalizeRound(bool isNative, uint64& value, int& offset, bool ro if (!roundUp) // canonicalize already rounds down return; - cLog(lsDEBUG) << "canonicalize< " << value << ":" << offset << (roundUp ? " up" : " down"); + cLog(lsTRACE) << "canonicalize< " << value << ":" << offset << (roundUp ? " up" : " down"); if (isNative) { if (offset < 0) @@ -55,7 +55,7 @@ static void canonicalizeRound(bool isNative, uint64& value, int& offset, bool ro value /= 10; ++offset; } - cLog(lsDEBUG) << "canonicalize> " << value << ":" << offset << (roundUp ? " up" : " down"); + cLog(lsTRACE) << "canonicalize> " << value << ":" << offset << (roundUp ? " up" : " down"); } STAmount STAmount::addRound(const STAmount& v1, const STAmount& v2, bool roundUp)