ruby: SubBlock: refactor code

This commit is contained in:
Nilay Vaish 2015-08-14 19:28:44 -05:00
parent 514f18cdda
commit ca368765a1
2 changed files with 4 additions and 10 deletions

View file

@ -41,7 +41,7 @@ SubBlock::SubBlock(Addr addr, int size)
} }
void void
SubBlock::internalMergeFrom(const DataBlock& data) SubBlock::mergeFrom(const DataBlock& data)
{ {
int size = getSize(); int size = getSize();
assert(size > 0); assert(size > 0);
@ -52,7 +52,7 @@ SubBlock::internalMergeFrom(const DataBlock& data)
} }
void void
SubBlock::internalMergeTo(DataBlock& data) const SubBlock::mergeTo(DataBlock& data) const
{ {
int size = getSize(); int size = getSize();
assert(size > 0); assert(size > 0);
@ -68,6 +68,3 @@ SubBlock::print(std::ostream& out) const
{ {
out << "[" << m_address << ", " << getSize() << ", " << m_data << "]"; out << "[" << m_address << ", " << getSize() << ", " << m_data << "]";
} }

View file

@ -56,15 +56,12 @@ class SubBlock
// Merging to and from DataBlocks - We only need to worry about // Merging to and from DataBlocks - We only need to worry about
// updates when we are using DataBlocks // updates when we are using DataBlocks
void mergeTo(DataBlock& data) const { internalMergeTo(data); } void mergeTo(DataBlock& data) const;
void mergeFrom(const DataBlock& data) { internalMergeFrom(data); } void mergeFrom(const DataBlock& data);
void print(std::ostream& out) const; void print(std::ostream& out) const;
private: private:
void internalMergeTo(DataBlock& data) const;
void internalMergeFrom(const DataBlock& data);
// Data Members (m_ prefix) // Data Members (m_ prefix)
Addr m_address; Addr m_address;
std::vector<uint8_t> m_data; std::vector<uint8_t> m_data;