diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-30 21:26:51 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-30 21:26:51 +0000 |
commit | 9daec60824d085db8c2f841fd389c725df1f8b0b (patch) | |
tree | 2defab579e0d19a40932780864e1fe30cd5dbb4c /xfa/fxfa/parser/xfa_utils.cpp | |
parent | 8b357e7504ea804293983453540ae91c9fc57922 (diff) | |
download | pdfium-9daec60824d085db8c2f841fd389c725df1f8b0b.tar.xz |
Cleanup XFA packet code
Remove GetPacketByID, move GetPacketByName to the xfa_utils file.
Cleanup CreateNode to accept the XFA_XDPPACKET instead of the packet
info.
Change-Id: I0f246c84f61b6b4175ca307bdcd125d9bc24bb1e
Reviewed-on: https://pdfium-review.googlesource.com/20010
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/xfa_utils.cpp')
-rw-r--r-- | xfa/fxfa/parser/xfa_utils.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index e9315763b7..a7b31aebec 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -190,14 +190,19 @@ const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PacketType ePacket) { return g_XFAPacketData + static_cast<uint8_t>(ePacket); } -const XFA_PACKETINFO* XFA_GetPacketByID(uint32_t dwPacket) { - int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1; +const XFA_PACKETINFO* XFA_GetPacketByName(const WideStringView& wsName) { + if (wsName.IsEmpty()) + return nullptr; + + uint32_t uHash = FX_HashCode_GetW(wsName, false); + int32_t iStart = 0; + int32_t iEnd = g_iXFAPacketCount - 1; do { int32_t iMid = (iStart + iEnd) / 2; - uint32_t dwFind = (g_XFAPacketData + iMid)->eName; - if (dwPacket == dwFind) - return g_XFAPacketData + iMid; - if (dwPacket < dwFind) + const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid; + if (uHash == pInfo->uHash) + return pInfo; + if (uHash < pInfo->uHash) iEnd = iMid - 1; else iStart = iMid + 1; |