summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/xfa_basic_imp.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-25 11:23:43 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-25 11:23:43 -0700
commitb6853cfe4fd1ee089dfdd0cb09bbc4063532ef82 (patch)
tree1404031e845c8b4b09d5a68fd81f09a7d2865d59 /xfa/fxfa/parser/xfa_basic_imp.cpp
parent2a8a20cde4c8e2294f6868bb097fe450960a709f (diff)
downloadpdfium-b6853cfe4fd1ee089dfdd0cb09bbc4063532ef82.tar.xz
Pass CFX_*StringCs to FX_HashCode_GETA and _GETW hash functions.
Too many calls were of the form fn(x.c_str(), x.GetLength()) which is an anti-pattern given the StringC classes which tie these together. There are a few places where explicit CFX_*StringCs are constructed, but this can be avoided by changing the args to these functions in the same manner. Removed String_ from name of functions since it added little value. Also removed default argument. Review URL: https://codereview.chromium.org/1919563002
Diffstat (limited to 'xfa/fxfa/parser/xfa_basic_imp.cpp')
-rw-r--r--xfa/fxfa/parser/xfa_basic_imp.cpp71
1 files changed, 35 insertions, 36 deletions
diff --git a/xfa/fxfa/parser/xfa_basic_imp.cpp b/xfa/fxfa/parser/xfa_basic_imp.cpp
index 631b7c10ca..728ecfc319 100644
--- a/xfa/fxfa/parser/xfa_basic_imp.cpp
+++ b/xfa/fxfa/parser/xfa_basic_imp.cpp
@@ -21,12 +21,12 @@
#include "xfa/fxfa/parser/xfa_utils.h"
const XFA_PACKETINFO* XFA_GetPacketByName(const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength);
- int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1;
+ 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;
const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid;
@@ -63,12 +63,12 @@ const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PACKET ePacket) {
const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByName(
const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength);
- int32_t iStart = 0, iEnd = g_iXFAEnumCount - 1;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t uHash = FX_HashCode_GetW(wsName, false);
+ int32_t iStart = 0;
+ int32_t iEnd = g_iXFAEnumCount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid;
@@ -87,12 +87,12 @@ const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) {
}
const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength);
- int32_t iStart = 0, iEnd = g_iXFAAttributeCount - 1;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t uHash = FX_HashCode_GetW(wsName, false);
+ int32_t iStart = 0;
+ int32_t iEnd = g_iXFAAttributeCount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid;
@@ -104,7 +104,7 @@ const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) {
iStart = iMid + 1;
}
} while (iStart <= iEnd);
- return NULL;
+ return nullptr;
}
const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName) {
return (eName < g_iXFAAttributeCount) ? (g_XFAAttributeData + eName) : NULL;
@@ -177,12 +177,12 @@ CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT eElement,
}
const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.c_str(), iLength);
- int32_t iStart = 0, iEnd = g_iXFAElementCount - 1;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t uHash = FX_HashCode_GetW(wsName, false);
+ int32_t iStart = 0;
+ int32_t iEnd = g_iXFAElementCount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid;
@@ -334,10 +334,9 @@ const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(XFA_ELEMENT eElement,
const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement,
const CFX_WideStringC& wsMethodName) {
- int32_t iLength = wsMethodName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
+ if (wsMethodName.IsEmpty())
+ return nullptr;
+
int32_t iElementIndex = eElement;
while (iElementIndex != -1) {
const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex;
@@ -346,8 +345,9 @@ const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement,
iElementIndex = scriptIndex->wParentIndex;
continue;
}
- uint32_t uHash = FX_HashCode_String_GetW(wsMethodName.c_str(), iLength);
- int32_t iStart = scriptIndex->wMethodStart, iEnd = iStart + icount - 1;
+ uint32_t uHash = FX_HashCode_GetW(wsMethodName, false);
+ int32_t iStart = scriptIndex->wMethodStart;
+ int32_t iEnd = iStart + icount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_METHODINFO* pInfo = g_SomMethodData + iMid;
@@ -366,10 +366,9 @@ const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement,
const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName(
XFA_ELEMENT eElement,
const CFX_WideStringC& wsAttributeName) {
- int32_t iLength = wsAttributeName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
+ if (wsAttributeName.IsEmpty())
+ return nullptr;
+
int32_t iElementIndex = eElement;
while (iElementIndex != -1) {
const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex;
@@ -378,7 +377,7 @@ const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName(
iElementIndex = scriptIndex->wParentIndex;
continue;
}
- uint32_t uHash = FX_HashCode_String_GetW(wsAttributeName.c_str(), iLength);
+ uint32_t uHash = FX_HashCode_GetW(wsAttributeName, false);
int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;