Skip to content

Commit e4448e7

Browse files
committed
Make byte writer find API const
1 parent 444ded3 commit e4448e7

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

components/ocs_core/byte_writer.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ size_t ByteWriter::get_cap() const {
2424
return size_;
2525
}
2626

27+
ssize_t ByteWriter::find(uint8_t data) const {
28+
for (size_t n = 0; n < get_len(); ++n) {
29+
if (data_[n] == data) {
30+
return n;
31+
}
32+
}
33+
34+
return -1;
35+
}
36+
2737
uint8_t* ByteWriter::get_data() {
2838
return data_;
2939
}
@@ -51,16 +61,6 @@ void ByteWriter::resize(size_t size) {
5161
offset_ = std::min(size_, size);
5262
}
5363

54-
ssize_t ByteWriter::find(uint8_t data) {
55-
for (size_t n = 0; n < get_len(); ++n) {
56-
if (data_[n] == data) {
57-
return n;
58-
}
59-
}
60-
61-
return -1;
62-
}
63-
6464
size_t ByteWriter::left_() const {
6565
return size_ - offset_;
6666
}

components/ocs_core/byte_writer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class ByteWriter : private core::NonCopyable<> {
2828
//! Return the size of the underlying array of bytes.
2929
size_t get_cap() const;
3030

31+
//! Find the position of the byte.
32+
ssize_t find(uint8_t data) const;
33+
3134
//! Return the underlying data.
3235
uint8_t* get_data();
3336

@@ -43,9 +46,6 @@ class ByteWriter : private core::NonCopyable<> {
4346
//! Change number of written bytes.
4447
void resize(size_t size);
4548

46-
//! Find the position of the byte.
47-
ssize_t find(uint8_t data);
48-
4949
//! Write any integer value.
5050
template <typename T> bool write(const T& t) {
5151
static_assert(std::is_integral<T>::value, "require integral type");

0 commit comments

Comments
 (0)