From a4fba6ddb3a7e925b49329793914f25e39a0a621 Mon Sep 17 00:00:00 2001 From: KyleWong Date: Fri, 9 Nov 2018 16:41:58 +0800 Subject: [PATCH] Use find for vector to avoid side effect. --- third_party/txt/src/txt/font_collection.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/third_party/txt/src/txt/font_collection.cc b/third_party/txt/src/txt/font_collection.cc index 9c8f78eb9b919..b3c3a481daf58 100644 --- a/third_party/txt/src/txt/font_collection.cc +++ b/third_party/txt/src/txt/font_collection.cc @@ -127,10 +127,9 @@ FontCollection::GetMinikinFontCollectionForFamily( }; if (enable_font_fallback_) { for (std::string fallback_family : fallback_fonts_for_locale_[locale]) { - std::shared_ptr fallback_font_ = - fallback_fonts_[fallback_family]; - if (fallback_font_.get() != nullptr) { - minikin_families.push_back(fallback_font_); + auto it = fallback_fonts_.find(fallback_family); + if (it != fallback_fonts_.end()) { + minikin_families.push_back(it->second); } } }