1515#ifndef BM_BM_SIM_BYTECONTAINER_H_
1616#define BM_BM_SIM_BYTECONTAINER_H_
1717
18- #include < vector>
1918#include < iterator>
2019#include < string>
20+ #include < vector>
2121
22+ #include < boost/container/small_vector.hpp>
2223#include < boost/functional/hash.hpp>
2324
24- #include " short_alloc.h"
25-
2625namespace bm {
2726
2827// ! This class is used everytime a vector of bytes is needed in bmv2. It is most
@@ -32,7 +31,7 @@ class ByteContainer {
3231 static constexpr size_t S = 16u ;
3332 static_assert (sizeof (char ) == 1 , " " );
3433 static_assert (alignof (char ) == 1 , " " );
35- using _vector = std::vector< char , detail::short_alloc <char , S, 1 > >;
34+ using _vector = boost::container::small_vector <char , S>;
3635
3736 public:
3837 using iterator = _vector::iterator;
@@ -42,22 +41,19 @@ class ByteContainer {
4241 using size_type = size_t ;
4342
4443 public:
45- ByteContainer ()
46- : bytes(_a) {
47- bytes.reserve (S);
48- }
44+ ByteContainer () = default ;
4945
5046 // ! Constructs the container with \p nbytes copies of elements with value \p c
5147 explicit ByteContainer (const size_t nbytes, const char c = ' \x00 ' )
52- : bytes(nbytes, c, _a ) { }
48+ : bytes(nbytes, c) {}
5349
5450 // ! Constructs the container by copying the bytes in vector \p bytes
55- explicit ByteContainer (const std::vector<char > & bytes)
56- : bytes(bytes.begin(), bytes.end(), _a ) { }
51+ explicit ByteContainer (const std::vector<char >& bytes)
52+ : bytes(bytes.begin(), bytes.end()) {}
5753
5854 // ! Constructs the container by copying the bytes in this byte array
59- ByteContainer (const char * bytes, size_t nbytes)
60- : bytes(bytes, bytes + nbytes, _a ) { }
55+ ByteContainer (const char * bytes, size_t nbytes)
56+ : bytes(bytes, bytes + nbytes) {}
6157
6258 static char char2digit (char c) {
6359 if (c >= ' 0' && c <= ' 9' )
@@ -72,8 +68,7 @@ class ByteContainer {
7268
7369 // ! Constructs the container from a hexadecimal string. Parameter \p hexstring
7470 // ! can optionally include the `0x` prefix.
75- explicit ByteContainer (const std::string &hexstring)
76- : bytes(_a) {
71+ explicit ByteContainer (const std::string& hexstring) {
7772 bytes.reserve (S);
7873 size_t idx = 0 ;
7974
@@ -97,19 +92,11 @@ class ByteContainer {
9792 }
9893 }
9994
100- ByteContainer (const ByteContainer &other)
101- : bytes(other.bytes, _a) { }
102-
103- ByteContainer &operator =(const ByteContainer &other) {
104- bytes.assign (other.begin (), other.end ());
105- return *this ;
106- }
107-
10895 // ! Returns the number of bytes in the container
10996 size_type size () const noexcept { return bytes.size (); }
11097
11198 // ! Clears the contents of the container
112- void clear () { return bytes.clear (); }
99+ void clear () { bytes.clear (); }
113100
114101 // iterators
115102
@@ -265,7 +252,6 @@ class ByteContainer {
265252 }
266253
267254 private:
268- _vector::allocator_type::arena_type _a;
269255 _vector bytes;
270256};
271257
0 commit comments