Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Optimized truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed May 30, 2017
1 parent 6942f39 commit 62f170c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ethcore/src/evm/interpreter/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,18 @@ impl Memory for Vec<u8> {
}

fn into_return_data(mut self, offset: U256, size: U256) -> ReturnData {
let offset = offset.low_u64() as usize;
let mut offset = offset.low_u64() as usize;
let size = size.low_u64() as usize;
if !is_valid_range(offset, size) {
return ReturnData::empty()
}
if self.len() - size > MAX_RETURN_WASTE_BYTES {
let mem = self.drain(offset..).take(size).collect();
ReturnData::new(mem, 0, size)
} else {
ReturnData::new(self, offset, size)
{ let _ = self.drain(..offset); }
self.truncate(size);
self.shrink_to_fit();
offset = 0;
}
ReturnData::new(self, offset, size)
}
}

Expand Down

0 comments on commit 62f170c

Please sign in to comment.