diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-04-17 09:39:10 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-17 19:30:08 +0000 |
commit | e190e7ce1e03ac536ecf825550482b84f7a3dfaa (patch) | |
tree | 9d4094535a1144542d172fb469bbd4668269468e /core/fxcrt/xml/cfx_saxreader.cpp | |
parent | 65a2192443ec9a111012fb02693ceaa513c0035f (diff) | |
download | pdfium-e190e7ce1e03ac536ecf825550482b84f7a3dfaa.tar.xz |
Replace indirect calls with switch in CFX_SaxReader.
Split off from a forthcoming CL to make it smaller.
Change-Id: I4409e8c7e87c0954a909e7c1dbeace9d4435b472
Reviewed-on: https://pdfium-review.googlesource.com/4259
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cfx_saxreader.cpp')
-rw-r--r-- | core/fxcrt/xml/cfx_saxreader.cpp | 70 |
1 files changed, 49 insertions, 21 deletions
diff --git a/core/fxcrt/xml/cfx_saxreader.cpp b/core/fxcrt/xml/cfx_saxreader.cpp index c571e8be96..a7810c9884 100644 --- a/core/fxcrt/xml/cfx_saxreader.cpp +++ b/core/fxcrt/xml/cfx_saxreader.cpp @@ -28,7 +28,6 @@ enum class CFX_SaxMode { TagClose, TagEnd, TargetData, - MAX }; class CFX_SAXCommentContext { @@ -42,25 +41,6 @@ namespace { const uint32_t kSaxFileBufSize = 32768; -typedef void (CFX_SAXReader::*FX_SAXReader_LPFParse)(); -static const FX_SAXReader_LPFParse - g_FX_SAXReader_LPFParse[static_cast<int>(CFX_SaxMode::MAX)] = { - &CFX_SAXReader::ParseText, - &CFX_SAXReader::ParseNodeStart, - &CFX_SAXReader::ParseDeclOrComment, - &CFX_SAXReader::ParseDeclNode, - &CFX_SAXReader::ParseComment, - &CFX_SAXReader::ParseCommentContent, - &CFX_SAXReader::ParseTagName, - &CFX_SAXReader::ParseTagAttributeName, - &CFX_SAXReader::ParseTagAttributeEqual, - &CFX_SAXReader::ParseTagAttributeValue, - &CFX_SAXReader::ParseMaybeClose, - &CFX_SAXReader::ParseTagClose, - &CFX_SAXReader::ParseTagEnd, - &CFX_SAXReader::ParseTargetData, -}; - } // namespace CFX_SAXFile::CFX_SAXFile() @@ -244,7 +224,7 @@ int32_t CFX_SAXReader::ContinueParse(IFX_Pause* pPause) { const uint8_t* pBuf = m_File.m_pBuf; while (index < size) { m_CurByte = pBuf[index]; - (this->*g_FX_SAXReader_LPFParse[static_cast<int>(m_eMode)])(); + ParseInternal(); index++; } m_File.m_dwCur += index; @@ -264,6 +244,54 @@ int32_t CFX_SAXReader::ContinueParse(IFX_Pause* pPause) { } return m_iState; } + +void CFX_SAXReader::ParseInternal() { + switch (m_eMode) { + case CFX_SaxMode::Text: + ParseText(); + break; + case CFX_SaxMode::NodeStart: + ParseNodeStart(); + break; + case CFX_SaxMode::DeclOrComment: + ParseDeclOrComment(); + break; + case CFX_SaxMode::DeclNode: + ParseDeclNode(); + break; + case CFX_SaxMode::Comment: + ParseComment(); + break; + case CFX_SaxMode::CommentContent: + ParseCommentContent(); + break; + case CFX_SaxMode::TagName: + ParseTagName(); + break; + case CFX_SaxMode::TagAttributeName: + ParseTagAttributeName(); + break; + case CFX_SaxMode::TagAttributeEqual: + ParseTagAttributeEqual(); + break; + case CFX_SaxMode::TagAttributeValue: + ParseTagAttributeValue(); + break; + case CFX_SaxMode::TagMaybeClose: + ParseMaybeClose(); + break; + case CFX_SaxMode::TagClose: + ParseTagClose(); + break; + case CFX_SaxMode::TagEnd: + ParseTagEnd(); + break; + case CFX_SaxMode::TargetData: + ParseTargetData(); + break; + } +} + void CFX_SAXReader::ParseChar(uint8_t ch) { ReallocDataBuffer(); m_pszData[m_iDataPos] = ch; |