Browse Source

Renamed actualSizeOfPrefix to sizeAsEncoded.

cl-refactor
chriseth 10 years ago
parent
commit
16b62e5a84
  1. 10
      libdevcore/RLP.cpp
  2. 4
      libdevcore/RLP.h

10
libdevcore/RLP.cpp

@ -50,7 +50,7 @@ RLP::iterator& RLP::iterator::operator++()
if (m_remaining)
{
m_currentItem.retarget(m_currentItem.next().data(), m_remaining);
m_currentItem = m_currentItem.cropped(0, actualSizeOfPrefix(m_currentItem));
m_currentItem = m_currentItem.cropped(0, sizeAsEncoded(m_currentItem));
m_remaining -= std::min<size_t>(m_remaining, m_currentItem.size());
}
else
@ -63,7 +63,7 @@ RLP::iterator::iterator(RLP const& _parent, bool _begin)
if (_begin && _parent.isList())
{
auto pl = _parent.payload();
m_currentItem = pl.cropped(0, actualSizeOfPrefix(pl));
m_currentItem = pl.cropped(0, sizeAsEncoded(pl));
m_remaining = pl.size() - m_currentItem.size();
}
else
@ -77,14 +77,14 @@ RLP RLP::operator[](size_t _i) const
{
if (_i < m_lastIndex)
{
m_lastEnd = actualSizeOfPrefix(payload());
m_lastEnd = sizeAsEncoded(payload());
m_lastItem = payload().cropped(0, m_lastEnd);
m_lastIndex = 0;
}
for (; m_lastIndex < _i && m_lastItem.size(); ++m_lastIndex)
{
m_lastItem = payload().cropped(m_lastEnd);
m_lastItem = m_lastItem.cropped(0, actualSizeOfPrefix(m_lastItem));
m_lastItem = m_lastItem.cropped(0, sizeAsEncoded(m_lastItem));
m_lastEnd += m_lastItem.size();
}
return RLP(m_lastItem, ThrowOnFail | FailIfTooSmall);
@ -206,7 +206,7 @@ size_t RLP::items() const
bytesConstRef d = payload().cropped(0, length());
size_t i = 0;
for (; d.size(); ++i)
d = d.cropped(actualSizeOfPrefix(d));
d = d.cropped(sizeAsEncoded(d));
return i;
}
return 0;

4
libdevcore/RLP.h

@ -327,8 +327,8 @@ private:
/// @returns the number of data items.
size_t items() const;
/// @returns the "actualSize" of the RLP encoded in the largest prefix of @a _data and throws on error.
static size_t actualSizeOfPrefix(bytesConstRef _data) { return RLP(_data, ThrowOnFail | FailIfTooSmall).actualSize(); }
/// @returns the size encoded into the RLP in @a _data and throws if _data is too short.
static size_t sizeAsEncoded(bytesConstRef _data) { return RLP(_data, ThrowOnFail | FailIfTooSmall).actualSize(); }
/// Our byte data.
bytesConstRef m_data;

Loading…
Cancel
Save