From b6853cfe4fd1ee089dfdd0cb09bbc4063532ef82 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 25 Apr 2016 11:23:43 -0700 Subject: 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 --- xfa/fde/css/fde_cssdatatable.cpp | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'xfa/fde/css/fde_cssdatatable.cpp') diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp index 6abe5a7a26..f37f77b86c 100644 --- a/xfa/fde/css/fde_cssdatatable.cpp +++ b/xfa/fde/css/fde_cssdatatable.cpp @@ -557,10 +557,10 @@ FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo) { return (ePersudo < FDE_CSSPERSUDO_NONE) ? (g_FDE_CSSPersudoType + ePersudo) : NULL; } -FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const FX_WCHAR* pszName, - int32_t iLength) { - FXSYS_assert(pszName != NULL && iLength > 0); - uint32_t dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE); +FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName( + const CFX_WideStringC& wsName) { + FXSYS_assert(!wsName.IsEmpty()); + uint32_t dwHash = FX_HashCode_GetW(wsName, true); int32_t iEnd = FDE_CSSPROPERTY_MAX - 1; int32_t iMid, iStart = 0; uint32_t dwMid; @@ -581,10 +581,9 @@ FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName) { return (eName < FDE_CSSPROPERTY_MAX) ? (g_FDE_CSSProperties + eName) : NULL; } FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName( - const FX_WCHAR* pszName, - int32_t iLength) { - FXSYS_assert(pszName != NULL && iLength > 0); - uint32_t dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE); + const CFX_WideStringC& wsName) { + FXSYS_assert(!wsName.IsEmpty()); + uint32_t dwHash = FX_HashCode_GetW(wsName, true); int32_t iEnd = FDE_CSSPROPERTYVALUE_MAX - 1; int32_t iMid, iStart = 0; uint32_t dwMid; @@ -606,10 +605,10 @@ FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum( return (eName < FDE_CSSPROPERTYVALUE_MAX) ? (g_FDE_CSSPropertyValues + eName) : NULL; } -FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName, - int32_t iLength) { - FXSYS_assert(pszName != NULL && iLength > 0); - uint16_t wHash = (uint16_t)FX_HashCode_String_GetW(pszName, iLength, TRUE); +FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName( + const CFX_WideStringC& wsName) { + FXSYS_assert(!wsName.IsEmpty()); + uint16_t wHash = FX_HashCode_GetW(wsName, true); int32_t iEnd = sizeof(g_FDE_CSSMediaTypes) / sizeof(FDE_CSSMEDIATYPETABLE) - 1; int32_t iMid, iStart = 0; @@ -627,10 +626,10 @@ FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName, } while (iStart <= iEnd); return NULL; } -FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName, - int32_t iLength) { - FXSYS_assert(pszName != NULL && iLength > 0); - uint16_t wHash = (uint16_t)FX_HashCode_String_GetW(pszName, iLength, TRUE); +FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName( + const CFX_WideStringC& wsName) { + FXSYS_assert(!wsName.IsEmpty()); + uint16_t wHash = FX_HashCode_GetW(wsName, true); int32_t iEnd = sizeof(g_FDE_CSSLengthUnits) / sizeof(FDE_CSSLENGTHUNITTABLE) - 1; int32_t iMid, iStart = 0; @@ -648,10 +647,9 @@ FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName, } while (iStart <= iEnd); return NULL; } -FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName, - int32_t iLength) { - FXSYS_assert(pszName != NULL && iLength > 0); - uint32_t dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE); +FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const CFX_WideStringC& wsName) { + FXSYS_assert(!wsName.IsEmpty()); + uint32_t dwHash = FX_HashCode_GetW(wsName, true); int32_t iEnd = sizeof(g_FDE_CSSColors) / sizeof(FDE_CSSCOLORTABLE) - 1; int32_t iMid, iStart = 0; uint32_t dwMid; @@ -684,7 +682,8 @@ FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue, if (iValueLen >= 1 && *pszValue == '%') { eUnit = FDE_CSSPRIMITIVETYPE_Percent; } else if (iValueLen == 2) { - FDE_LPCCSSLENGTHUNITTABLE pUnit = FDE_GetCSSLengthUnitByName(pszValue, 2); + FDE_LPCCSSLENGTHUNITTABLE pUnit = + FDE_GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2)); if (pUnit != NULL) { eUnit = (FDE_CSSPRIMITIVETYPE)pUnit->wValue; } @@ -770,7 +769,8 @@ FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue, dwColor = ArgbEncode(255, rgb[0], rgb[1], rgb[2]); return TRUE; } else { - FDE_LPCCSSCOLORTABLE pColor = FDE_GetCSSColorByName(pszValue, iValueLen); + FDE_LPCCSSCOLORTABLE pColor = + FDE_GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen)); if (pColor != NULL) { dwColor = pColor->dwValue; return TRUE; -- cgit v1.2.3