From 6eda94d78313f18a8f0708c4492d0962649fa709 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 5 Dec 2017 20:34:36 +0000 Subject: Replace uses of bsearch(). Either switch to std::lower_bound(), or brute force when the search space is very small. Change-Id: I54db346aeb6f2e8000e95a6a9c8fbdd512df500a Reviewed-on: https://pdfium-review.googlesource.com/20431 Reviewed-by: dsinclair Commit-Queue: Lei Zhang --- core/fpdfapi/font/cpdf_type1font.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'core/fpdfapi/font/cpdf_type1font.cpp') diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp index 9975943d9a..21d9da42c8 100644 --- a/core/fpdfapi/font/cpdf_type1font.cpp +++ b/core/fpdfapi/font/cpdf_type1font.cpp @@ -6,6 +6,8 @@ #include "core/fpdfapi/font/cpdf_type1font.h" +#include + #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fxge/cfx_gemodule.h" #include "core/fxge/fx_freetype.h" @@ -28,16 +30,12 @@ const GlyphNameMap g_GlyphNameSubsts[] = {{"ff", "uniFB00"}, {"fi", "uniFB01"}, {"fl", "uniFB02"}}; -int compareString(const void* key, const void* element) { - return FXSYS_stricmp(static_cast(key), - static_cast(element)->m_pStrAdobe); -} - const char* GlyphNameRemap(const char* pStrAdobe) { - const GlyphNameMap* found = static_cast( - bsearch(pStrAdobe, g_GlyphNameSubsts, FX_ArraySize(g_GlyphNameSubsts), - sizeof(GlyphNameMap), compareString)); - return found ? found->m_pStrUnicode : nullptr; + for (const auto& element : g_GlyphNameSubsts) { + if (!FXSYS_stricmp(element.m_pStrAdobe, pStrAdobe)) + return element.m_pStrUnicode; + } + return nullptr; } #endif // _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ -- cgit v1.2.3