mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Avoid copying and improve optimization opportunities
This commit is contained in:
committed by
Tom Ritchford
parent
b4058a813b
commit
f072b5b679
@@ -44,6 +44,7 @@
|
||||
#include <ripple/protocol/UintTypes.h>
|
||||
#include <beast/module/core/text/LexicalCast.h>
|
||||
#include <beast/utility/make_lock.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -1306,10 +1307,10 @@ private:
|
||||
|
||||
s.set_ledgerseq (ledger.getLedgerSeq ());
|
||||
s.set_networktime (getApp().getOPs ().getNetworkTimeNC ());
|
||||
uint256 hash = ledger.getParentHash ();
|
||||
s.set_ledgerhashprevious (hash.begin (), hash.size ());
|
||||
hash = ledger.getHash ();
|
||||
s.set_ledgerhash (hash.begin (), hash.size ());
|
||||
s.set_ledgerhashprevious(ledger.getParentHash ().begin (),
|
||||
std::decay_t<decltype(ledger.getParentHash ())>::bytes);
|
||||
s.set_ledgerhash (ledger.getHash ().begin (),
|
||||
std::decay_t<decltype(ledger.getHash ())>::bytes);
|
||||
|
||||
std::uint32_t uMin, uMax;
|
||||
if (!getApp().getOPs ().getFullValidatedRange (uMin, uMax))
|
||||
|
||||
@@ -616,7 +616,8 @@ bool Ledger::getMetaHex (uint256 const& transID, std::string& hex) const
|
||||
return true;
|
||||
}
|
||||
|
||||
uint256 Ledger::getHash ()
|
||||
uint256 const&
|
||||
Ledger::getHash ()
|
||||
{
|
||||
if (!mValidHash)
|
||||
updateHash ();
|
||||
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
void addRaw (Serializer & s) const;
|
||||
void setRaw (Serializer & s, bool hasPrefix);
|
||||
|
||||
uint256 getHash ();
|
||||
uint256 const& getHash ();
|
||||
uint256 const& getParentHash () const
|
||||
{
|
||||
return mParentHash;
|
||||
|
||||
@@ -19,22 +19,9 @@
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace ripple {
|
||||
|
||||
char charHex (int iDigit)
|
||||
{
|
||||
if (iDigit >= 0)
|
||||
{
|
||||
if(iDigit < 10)
|
||||
return '0' + iDigit;
|
||||
if(iDigit < 16)
|
||||
return 'A' - 10 + iDigit;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int charUnHex (unsigned char c)
|
||||
{
|
||||
struct HexTab
|
||||
|
||||
@@ -26,14 +26,24 @@
|
||||
#define RIPPLE_BASICS_STRHEX_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace ripple {
|
||||
|
||||
/** Converts an integer to the corresponding hex digit
|
||||
@param iDigit 0-15 inclusive
|
||||
@return a character from '0'-'9' or 'A'-'F' on success; 0 on failure.
|
||||
@return a character from '0'-'9' or 'A'-'F'.
|
||||
*/
|
||||
char charHex (int iDigit);
|
||||
inline
|
||||
char
|
||||
charHex (unsigned int digit)
|
||||
{
|
||||
static
|
||||
char const xtab[] = "0123456789ABCDEF";
|
||||
|
||||
assert (digit < 16);
|
||||
|
||||
return xtab[digit];
|
||||
}
|
||||
|
||||
/** @{ */
|
||||
/** Converts a hex digit to the corresponding integer
|
||||
|
||||
Reference in New Issue
Block a user