Remove CPDF_StreamParser::MatchWordBuffer()
Using GetWord() == kConstant is an effective way to compare a
string view against a literal.
Bug: pdfium:1706
Change-Id: I3624ab0b4fea02686ebd568f6431c8cd9fed312d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/83750
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index 707b0b2..9677083 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -278,16 +278,16 @@
return Name;
if (m_WordSize == 4) {
- if (WordBufferMatches(kTrue)) {
+ if (GetWord() == kTrue) {
m_pLastObj = pdfium::MakeRetain<CPDF_Boolean>(true);
return Others;
}
- if (WordBufferMatches(kNull)) {
+ if (GetWord() == kNull) {
m_pLastObj = pdfium::MakeRetain<CPDF_Null>();
return Others;
}
} else if (m_WordSize == 5) {
- if (WordBufferMatches(kFalse)) {
+ if (GetWord() == kFalse) {
m_pLastObj = pdfium::MakeRetain<CPDF_Boolean>(false);
return Others;
}
@@ -367,11 +367,11 @@
return pArray;
}
- if (WordBufferMatches(kFalse))
+ if (GetWord() == kFalse)
return pdfium::MakeRetain<CPDF_Boolean>(false);
- if (WordBufferMatches(kTrue))
+ if (GetWord() == kTrue)
return pdfium::MakeRetain<CPDF_Boolean>(true);
- if (WordBufferMatches(kNull))
+ if (GetWord() == kNull)
return pdfium::MakeRetain<CPDF_Null>();
return nullptr;
}
@@ -597,8 +597,3 @@
bool CPDF_StreamParser::PositionIsInBounds() const {
return m_Pos < m_pBuf.size();
}
-
-bool CPDF_StreamParser::WordBufferMatches(const char* pWord) const {
- const size_t iLength = strlen(pWord);
- return m_WordSize == iLength && memcmp(m_WordBuffer, pWord, iLength) == 0;
-}
diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h
index d2794ba..1878708 100644
--- a/core/fpdfapi/page/cpdf_streamparser.h
+++ b/core/fpdfapi/page/cpdf_streamparser.h
@@ -48,7 +48,6 @@
ByteString ReadString();
ByteString ReadHexString();
bool PositionIsInBounds() const;
- bool WordBufferMatches(const char* pWord) const;
uint32_t m_Pos = 0; // Current byte position within |m_pBuf|.
uint32_t m_WordSize = 0; // Current byte position within |m_WordBuffer|.