Micro-optimizations.

This commit is contained in:
JoelKatz
2011-12-16 21:51:05 -08:00
parent ad8dcaa473
commit 715bff43ef
2 changed files with 3 additions and 151 deletions

View File

@@ -11,7 +11,7 @@ void LedgerHistory::addLedger(Ledger::pointer ledger)
{
uint256 h(ledger->getHash());
boost::recursive_mutex::scoped_lock sl(mLock);
if(!mLedgersByHash.count(h)) mLedgersByHash.insert(std::make_pair(h, ledger));
mLedgersByHash.insert(std::make_pair(h, ledger));
}
void LedgerHistory::addAcceptedLedger(Ledger::pointer ledger)
@@ -69,59 +69,3 @@ Ledger::pointer LedgerHistory::canonicalizeLedger(Ledger::pointer ledger, bool s
if(ledger->isAccepted()) mLedgersByIndex.insert(std::make_pair(ledger->getLedgerSeq(), ledger));
return ledger;
}
#if 0
bool LedgerHistory::loadLedger(const uint256& hash)
{
Ledger::pointer ledger=Ledger::pointer(new Ledger());
if(ledger->load(hash))
{
mAllLedgers[hash]=ledger;
return(true);
}
return(false);
}
bool LedgerHistory::loadAcceptedLedger(uint32 index)
{
// TODO: LedgerHistory::loadAcceptedLedger(uint32 index)
/*
Ledger::pointer ledger=theApp->getSerializer()->loadAcceptedLedger(index);
if(ledger)
{
mAcceptedLedgers[index]=ledger;
return(true);
}*/
return(false);
}
void LedgerHistory::addAcceptedLedger(Ledger::pointer ledger)
{
mAcceptedLedgers[ledger->getIndex()]=ledger;
}
// this will see if the ledger is in memory
// if not it will check disk and load it
// if not it will return NULL
Ledger::pointer LedgerHistory::getAcceptedLedger(uint32 index)
{
if(mAcceptedLedgers.count(index))
return(mAcceptedLedgers[index]);
if(loadAcceptedLedger(index)) return(mAcceptedLedgers[index]);
return(Ledger::pointer());
}
void LedgerHistory::addLedger(Ledger::pointer ledger)
{
mAcceptedLedgers[ledger->getIndex()]=ledger;
ledger->save();
}
Ledger::pointer LedgerHistory::getLedger(const uint256& hash)
{
if(mAllLedgers.count(hash))
return(mAllLedgers[hash]);
if(loadLedger(hash)) return(mAllLedgers[hash]);
return(Ledger::pointer());
}
#endif