From 649a78569e9487fc5d3cccee546be50c351560b7 Mon Sep 17 00:00:00 2001 From: tsepez Date: Tue, 7 Jun 2016 18:17:30 -0700 Subject: Use static_casts for cpdf_type1font bsearch on mac. Also sort the static table to be compatible with bsearch(). Review-Url: https://codereview.chromium.org/2047813002 --- core/fpdfapi/fpdf_font/cpdf_type1font.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'core/fpdfapi/fpdf_font') diff --git a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp index 908b6e3a2f..3f1b5d1a40 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp @@ -23,24 +23,21 @@ struct GlyphNameMap { }; const GlyphNameMap g_GlyphNameSubsts[] = {{"ff", "uniFB00"}, - {"fi", "uniFB01"}, - {"fl", "uniFB02"}, {"ffi", "uniFB03"}, - {"ffl", "uniFB04"}}; + {"ffl", "uniFB04"}, + {"fi", "uniFB01"}, + {"fl", "uniFB02"}}; int compareString(const void* key, const void* element) { - return FXSYS_stricmp((const FX_CHAR*)key, - ((GlyphNameMap*)element)->m_pStrAdobe); + return FXSYS_stricmp(static_cast(key), + static_cast(element)->m_pStrAdobe); } const FX_CHAR* GlyphNameRemap(const FX_CHAR* pStrAdobe) { - GlyphNameMap* found = (GlyphNameMap*)FXSYS_bsearch( - pStrAdobe, g_GlyphNameSubsts, - sizeof(g_GlyphNameSubsts) / sizeof(GlyphNameMap), sizeof(GlyphNameMap), - compareString); - if (found) - return found->m_pStrUnicode; - return nullptr; + const GlyphNameMap* found = static_cast(FXSYS_bsearch( + pStrAdobe, g_GlyphNameSubsts, FX_ArraySize(g_GlyphNameSubsts), + sizeof(GlyphNameMap), compareString)); + return found ? found->m_pStrUnicode : nullptr; } #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ -- cgit v1.2.3