From 24355e17fb5bcf8e01430376c58ab7be64bcbbb8 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 20 Feb 2013 11:58:57 -0800 Subject: [PATCH] I apologize for this moderate buchery, but we need to save the calls to base58::ToString --- src/cpp/ripple/RippleAddress.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cpp/ripple/RippleAddress.cpp b/src/cpp/ripple/RippleAddress.cpp index 701faa81cd..aac1695e19 100644 --- a/src/cpp/ripple/RippleAddress.cpp +++ b/src/cpp/ripple/RippleAddress.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include @@ -293,6 +295,9 @@ uint160 RippleAddress::getAccountID() const } } +static boost::mutex rncLock; +static boost::unordered_map< std::vector, std::string > rncMap; + std::string RippleAddress::humanAccountID() const { switch (nVersion) { @@ -300,7 +305,13 @@ std::string RippleAddress::humanAccountID() const throw std::runtime_error("unset source - humanAccountID"); case VER_ACCOUNT_ID: - return ToString(); + { + boost::mutex::scoped_lock sl(rncLock); + boost::unordered_map< std::vector, std::string >::iterator it = rncMap.find(vchData); + if (it != rncMap.end()) + return it->second; + return rncMap[vchData] = ToString(); + } case VER_ACCOUNT_PUBLIC: {