Skip to content

Commit

Permalink
let Cursor::peek return span
Browse files Browse the repository at this point in the history
Summary:
Currently, `CursorBase::peek()` returns `pair<uint8_t const*, size_t>` and `CursorBase::peekView()` returns `basic_string_view<uint8_t>`. Consolidate them into `CursorBase::peek()` returning `span<uint8_t const>`.

As one motivation, libc++ v19 removes `basic_string_view<uint8_t>`.

Reviewed By: thevinster

Differential Revision: D62460851

fbshipit-source-id: 72d567817faf778287594c10dfd7f6f379bf2446
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Sep 13, 2024
1 parent 3b39a13 commit ac9ede6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions proxygen/lib/http/codec/HTTP2Framer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ ErrorCode skipPadding(Cursor& cursor, uint8_t length, bool verify) {
if (verify) {
while (length > 0) {
auto cur = cursor.peek();
uint8_t toCmp = std::min<size_t>(cur.second, length);
if (memcmp(cur.first, kZeroPad, toCmp)) {
uint8_t toCmp = std::min<size_t>(cur.size(), length);
if (memcmp(cur.data(), kZeroPad, toCmp) != 0) {
return ErrorCode::PROTOCOL_ERROR;
}
cursor.skip(toCmp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ struct QIFReader : public Reader {
case LINESTART: {
seenR = false;
auto p = c.peek();
switch (p.first[0]) {
switch (p[0]) {
case '#':
state_ = COMMENT;
break;
Expand All @@ -348,12 +348,12 @@ struct QIFReader : public Reader {
break;
case EOL: {
auto p = c.peek();
if (p.first[0] == '\n') {
if (p[0] == '\n') {
c.skip(1);
state_ = LINESTART;
} else if (seenR) { // \r followed by anything but \n -> mac newline
state_ = LINESTART;
} else if (p.first[0] == '\r') {
} else if (p[0] == '\r') {
c.skip(1);
seenR = true;
}
Expand Down

0 comments on commit ac9ede6

Please sign in to comment.