Reduce unnecessary allocations (#5944)
This commit is contained in:
parent
944f9d7fb5
commit
72094a8bee
@ -493,8 +493,8 @@ impl Engine for Tendermint {
|
|||||||
let seal_length = header.seal().len();
|
let seal_length = header.seal().len();
|
||||||
if seal_length == self.seal_fields() {
|
if seal_length == self.seal_fields() {
|
||||||
// Either proposal or commit.
|
// Either proposal or commit.
|
||||||
if (header.seal()[1] == ::rlp::NULL_RLP.to_vec())
|
if (header.seal()[1] == ::rlp::NULL_RLP)
|
||||||
!= (header.seal()[2] == ::rlp::EMPTY_LIST_RLP.to_vec()) {
|
!= (header.seal()[2] == ::rlp::EMPTY_LIST_RLP) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
warn!(target: "engine", "verify_block_basic: Block is neither a Commit nor Proposal.");
|
warn!(target: "engine", "verify_block_basic: Block is neither a Commit nor Proposal.");
|
||||||
|
@ -177,7 +177,7 @@ impl JournalDB for ArchiveDB {
|
|||||||
fn latest_era(&self) -> Option<u64> { self.latest_era }
|
fn latest_era(&self) -> Option<u64> { self.latest_era }
|
||||||
|
|
||||||
fn state(&self, id: &H256) -> Option<Bytes> {
|
fn state(&self, id: &H256) -> Option<Bytes> {
|
||||||
self.backing.get_by_prefix(self.column, &id[0..DB_PREFIX_LEN]).map(|b| b.to_vec())
|
self.backing.get_by_prefix(self.column, &id[0..DB_PREFIX_LEN]).map(|b| b.into_vec())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_pruned(&self) -> bool { false }
|
fn is_pruned(&self) -> bool { false }
|
||||||
|
@ -371,7 +371,7 @@ impl JournalDB for EarlyMergeDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn state(&self, id: &H256) -> Option<Bytes> {
|
fn state(&self, id: &H256) -> Option<Bytes> {
|
||||||
self.backing.get_by_prefix(self.column, &id[0..DB_PREFIX_LEN]).map(|b| b.to_vec())
|
self.backing.get_by_prefix(self.column, &id[0..DB_PREFIX_LEN]).map(|b| b.into_vec())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> Result<u32, UtilError> {
|
fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> Result<u32, UtilError> {
|
||||||
|
@ -244,7 +244,7 @@ impl JournalDB for OverlayRecentDB {
|
|||||||
let key = to_short_key(key);
|
let key = to_short_key(key);
|
||||||
journal_overlay.backing_overlay.get(&key).map(|v| v.to_vec())
|
journal_overlay.backing_overlay.get(&key).map(|v| v.to_vec())
|
||||||
.or_else(|| journal_overlay.pending_overlay.get(&key).map(|d| d.clone().to_vec()))
|
.or_else(|| journal_overlay.pending_overlay.get(&key).map(|d| d.clone().to_vec()))
|
||||||
.or_else(|| self.backing.get_by_prefix(self.column, &key[0..DB_PREFIX_LEN]).map(|b| b.to_vec()))
|
.or_else(|| self.backing.get_by_prefix(self.column, &key[0..DB_PREFIX_LEN]).map(|b| b.into_vec()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> Result<u32, UtilError> {
|
fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> Result<u32, UtilError> {
|
||||||
|
@ -115,7 +115,7 @@ impl JournalDB for RefCountedDB {
|
|||||||
fn latest_era(&self) -> Option<u64> { self.latest_era }
|
fn latest_era(&self) -> Option<u64> { self.latest_era }
|
||||||
|
|
||||||
fn state(&self, id: &H256) -> Option<Bytes> {
|
fn state(&self, id: &H256) -> Option<Bytes> {
|
||||||
self.backing.get_by_prefix(self.column, &id[0..DB_PREFIX_LEN]).map(|b| b.to_vec())
|
self.backing.get_by_prefix(self.column, &id[0..DB_PREFIX_LEN]).map(|b| b.into_vec())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> Result<u32, UtilError> {
|
fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> Result<u32, UtilError> {
|
||||||
|
Loading…
Reference in New Issue
Block a user