summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-12-05 20:34:36 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-05 20:34:36 +0000
commit6eda94d78313f18a8f0708c4492d0962649fa709 (patch)
tree29e0e340e47865b3ee2f2f3f45e40a606ec46198 /core/fpdfapi
parentc5352efd9c0f86a189181f93405ee10919915841 (diff)
downloadpdfium-6eda94d78313f18a8f0708c4492d0962649fa709.tar.xz
Replace uses of bsearch().chromium/3286
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 <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/font/cpdf_type1font.cpp16
1 files changed, 7 insertions, 9 deletions
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 <algorithm>
+
#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<const char*>(key),
- static_cast<const GlyphNameMap*>(element)->m_pStrAdobe);
-}
-
const char* GlyphNameRemap(const char* pStrAdobe) {
- const GlyphNameMap* found = static_cast<const GlyphNameMap*>(
- 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_