Skip to content

Commit

Permalink
refactor: optimize increments
Browse files Browse the repository at this point in the history
  • Loading branch information
Disservin committed Oct 11, 2024
1 parent 6b6082e commit aea8d88
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/pgn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class StreamParser {

void operator+=(char c) {
assert(index_ < N);
buffer_[index_++] = c;
buffer_[index_] = c;
++index_;
}

void remove_suffix(std::size_t n) {
Expand Down Expand Up @@ -153,7 +154,7 @@ class StreamParser {
const auto c = buffer_[buffer_index_];

if (c == '\r') {
buffer_index_++;
++buffer_index_;
return some();
}

Expand Down Expand Up @@ -183,13 +184,13 @@ class StreamParser {
}

if (*ret == open_delim) {
stack++;
++stack;
} else if (*ret == close_delim) {
if (stack == 0) {
// Mismatched closing delimiter
return false;
} else {
stack--;
--stack;
if (stack == 0) {
// Matching closing delimiter found
return true;
Expand Down Expand Up @@ -218,7 +219,7 @@ class StreamParser {
fill();
}

buffer_index_++;
++buffer_index_;
}

char peek() {
Expand Down Expand Up @@ -496,7 +497,7 @@ class StreamParser {
onEnd();
break;
} else if (peek == '/') {
for (size_t i = 0; i <= 6; i++) {
for (size_t i = 0; i <= 6; ++i) {
stream_buffer.advance();
}

Expand Down

0 comments on commit aea8d88

Please sign in to comment.