name: Optimization of Name implementation
Now, Name directly uses Block as underlying storage for name components
and name::Components (aka Name::Components) class is a helper wrapped on
top of Block class.
Change-Id: I15ca58cc6dba76dd02e973709b7b153c2613de51
refs: #1171
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index da81e64..f515727 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -348,12 +348,12 @@
for (element_iterator i = m_subBlocks.begin();
i != m_subBlocks.end();
++i)
- {
+ {
if (i->type() != type)
newContainer.push_back(*i);
- }
+ }
m_subBlocks.swap(newContainer);
-}
+ }
inline Block::element_iterator
Block::erase(Block::element_iterator position)
diff --git a/src/encoding/encoding-buffer.hpp b/src/encoding/encoding-buffer.hpp
index eac26f9..8870941 100644
--- a/src/encoding/encoding-buffer.hpp
+++ b/src/encoding/encoding-buffer.hpp
@@ -24,8 +24,8 @@
namespace ndn {
namespace encoding {
-const bool Buffer = true;
-const bool Estimator = false;
+static const bool Buffer = true;
+static const bool Estimator = false;
} // encoding
template<bool isRealEncoderNotEstimator>
@@ -91,9 +91,6 @@
prependByteArray (const uint8_t *arr, size_t len);
inline size_t
- prependBuffer (const Buffer& arr);
-
- inline size_t
prependNonNegativeInteger (uint64_t varNumber);
inline size_t
@@ -106,9 +103,6 @@
appendByteArray (const uint8_t *arr, size_t len);
inline size_t
- appendBuffer (const Buffer& arr);
-
- inline size_t
appendNonNegativeInteger (uint64_t varNumber);
inline size_t
@@ -158,9 +152,6 @@
prependByteArray (const uint8_t *arr, size_t len);
inline size_t
- prependBuffer (const Buffer& arr);
-
- inline size_t
prependNonNegativeInteger (uint64_t varNumber);
inline size_t
@@ -173,9 +164,6 @@
appendByteArray (const uint8_t *arr, size_t len);
inline size_t
- appendBuffer (const Buffer& arr);
-
- inline size_t
appendNonNegativeInteger (uint64_t varNumber);
inline size_t
@@ -324,24 +312,6 @@
}
inline size_t
-EncodingImpl<encoding::Buffer>::prependBuffer (const Buffer& arr)
-{
- if ((m_buffer->begin () + arr.size ()) > m_begin)
- resize (m_buffer->size () * 2 + arr.size (), true);
-
- m_begin -= arr.size ();
- std::copy (arr.begin (), arr.end (), m_begin);
- return arr.size ();
-}
-
-inline size_t
-EncodingImpl<encoding::Estimator>::prependBuffer (const Buffer& arr)
-{
- m_size += arr.size ();
- return arr.size ();
-}
-
-inline size_t
EncodingImpl<encoding::Buffer>::prependNonNegativeInteger (uint64_t varNumber)
{
if (varNumber < 253) {
@@ -469,23 +439,6 @@
}
inline size_t
-EncodingImpl<encoding::Buffer>::appendBuffer (const Buffer& arr)
-{
- if ((m_end + arr.size ()) > m_buffer->end ())
- resize (m_buffer->size () * 2 + arr.size (), false);
-
- std::copy (arr.begin (), arr.end (), m_end);
- m_end -= arr.size ();
- return arr.size ();
-}
-
-inline size_t
-EncodingImpl<encoding::Estimator>::appendBuffer (const Buffer& arr)
-{
- return prependBuffer(arr);
-}
-
-inline size_t
EncodingImpl<encoding::Buffer>::appendNonNegativeInteger (uint64_t varNumber)
{
if (varNumber < 253) {