Refactor CPDF_SimpleParser part 2
Make the ordering of current position and data size checks consistent by
always having `cur_pos_` on the left hand side.
Change-Id: Ia19030170ce1554cfcc55615b99907c00d9692b8
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/123411
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_simple_parser.cpp b/core/fpdfapi/parser/cpdf_simple_parser.cpp
index baa1461..9856e2f 100644
--- a/core/fpdfapi/parser/cpdf_simple_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_simple_parser.cpp
@@ -20,13 +20,13 @@
// Skip whitespace and comment lines.
while (true) {
- if (data_.size() <= cur_position_) {
+ if (cur_position_ >= data_.size()) {
return ByteStringView();
}
cur_char = data_[cur_position_++];
while (PDFCharIsWhitespace(cur_char)) {
- if (data_.size() <= cur_position_) {
+ if (cur_position_ >= data_.size()) {
return ByteStringView();
}
cur_char = data_[cur_position_++];
@@ -37,7 +37,7 @@
}
while (true) {
- if (data_.size() <= cur_position_) {
+ if (cur_position_ >= data_.size()) {
return ByteStringView();
}
@@ -54,7 +54,7 @@
// Find names
if (cur_char == '/') {
while (true) {
- if (data_.size() <= cur_position_) {
+ if (cur_position_ >= data_.size()) {
break;
}
@@ -70,7 +70,7 @@
size = 1;
if (cur_char == '<') {
- if (data_.size() <= cur_position_) {
+ if (cur_position_ >= data_.size()) {
return ByteStringView(data_.subspan(start_position, size));
}
cur_char = data_[cur_position_++];
@@ -88,7 +88,7 @@
size = cur_position_ - start_position;
}
} else if (cur_char == '>') {
- if (data_.size() <= cur_position_) {
+ if (cur_position_ >= data_.size()) {
return ByteStringView(data_.subspan(start_position, size));
}
cur_char = data_[cur_position_++];
@@ -107,7 +107,7 @@
}
if (data_[cur_position_] == '\\') {
- if (data_.size() <= cur_position_) {
+ if (cur_position_ >= data_.size()) {
break;
}
@@ -115,7 +115,7 @@
} else if (data_[cur_position_] == '(') {
level++;
}
- if (data_.size() <= cur_position_) {
+ if (cur_position_ >= data_.size()) {
break;
}