Skip to content

Commit 723db0b

Browse files
committed
snake case for bytearray
1 parent 05fdd4b commit 723db0b

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

vpr/src/server/bytearray.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class ByteArray : public std::vector<uint8_t> {
2727
reinterpret_cast<const uint8_t*>(data + size))
2828
{}
2929

30-
ByteArray(std::size_t sizeHint = DEFAULT_SIZE_HINT) {
31-
reserve(sizeHint);
30+
ByteArray(std::size_t size_hint = DEFAULT_SIZE_HINT) {
31+
reserve(size_hint);
3232
}
3333

3434
template<typename Iterator>
@@ -42,12 +42,12 @@ class ByteArray : public std::vector<uint8_t> {
4242
push_back(b);
4343
}
4444

45-
std::size_t findSequence(const char* sequence, std::size_t sequenceSize) {
46-
const std::size_t mSize = size();
47-
if (mSize >= sequenceSize) {
48-
for (std::size_t i = 0; i <= mSize - sequenceSize; ++i) {
45+
std::size_t find_sequence(const char* sequence, std::size_t sequence_size) {
46+
const std::size_t ssize = size();
47+
if (ssize >= sequence_size) {
48+
for (std::size_t i = 0; i <= ssize - sequence_size; ++i) {
4949
bool found = true;
50-
for (std::size_t j = 0; j < sequenceSize; ++j) {
50+
for (std::size_t j = 0; j < sequence_size; ++j) {
5151
if (at(i + j) != sequence[j]) {
5252
found = false;
5353
break;
@@ -65,12 +65,12 @@ class ByteArray : public std::vector<uint8_t> {
6565
return std::string(reinterpret_cast<const char*>(this->data()), this->size());
6666
}
6767

68-
uint32_t calcCheckSum() {
69-
return calcCheckSum<ByteArray>(*this);
68+
uint32_t calc_check_sum() {
69+
return calc_check_sum<ByteArray>(*this);
7070
}
7171

7272
template<typename T>
73-
static uint32_t calcCheckSum(const T& iterable) {
73+
static uint32_t calc_check_sum(const T& iterable) {
7474
uint32_t sum = 0;
7575
for (uint8_t c : iterable) {
7676
sum += static_cast<unsigned int>(c);

vpr/src/server/telegrambuffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void TelegramBuffer::append(const ByteArray& bytes) {
99
}
1010

1111
bool TelegramBuffer::check_telegram_header_presence() {
12-
std::size_t signature_start_index = m_raw_buffer.findSequence(TelegramHeader::SIGNATURE, TelegramHeader::SIGNATURE_SIZE);
12+
std::size_t signature_start_index = m_raw_buffer.find_sequence(TelegramHeader::SIGNATURE, TelegramHeader::SIGNATURE_SIZE);
1313
if (signature_start_index != std::size_t(-1)) {
1414
if (signature_start_index != 0) {
1515
// discard bytes preceding the header start position.
@@ -45,7 +45,7 @@ void TelegramBuffer::take_telegram_frames(std::vector<comm::TelegramFramePtr>& r
4545
if (m_raw_buffer.size() >= expected_telegram_size) {
4646
// checksum validation
4747
ByteArray data(m_raw_buffer.begin() + TelegramHeader::size(), m_raw_buffer.begin() + expected_telegram_size);
48-
uint32_t actual_check_sum = data.calcCheckSum();
48+
uint32_t actual_check_sum = data.calc_check_sum();
4949
if (actual_check_sum == header.body_check_sum()) {
5050
// construct telegram frame if checksum matches
5151
TelegramFramePtr telegram_frame_ptr = std::make_shared<TelegramFrame>(TelegramFrame{header, std::move(data)});

vpr/src/server/telegramheader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TelegramHeader {
4444

4545
template<typename T>
4646
static comm::TelegramHeader construct_from_data(const T& body, uint8_t compressor_id = 0) {
47-
uint32_t body_check_sum = ByteArray::calcCheckSum(body);
47+
uint32_t body_check_sum = ByteArray::calc_check_sum(body);
4848
return comm::TelegramHeader{static_cast<uint32_t>(body.size()), body_check_sum, compressor_id};
4949
}
5050

0 commit comments

Comments
 (0)