Codechange: Replace FontMap's std::map with std::vector. (#13126)

This commit is contained in:
Peter Nelson 2024-11-27 12:36:56 +00:00 committed by GitHub
parent 8b8cd9ae2d
commit 23e252ad40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -105,8 +105,8 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s
continue;
}
if (fontMapping.count(buff - buff_begin) == 0) {
fontMapping[buff - buff_begin] = f;
if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) {
fontMapping.emplace_back(buff - buff_begin, f);
}
f = Layouter::GetFont(state.fontsize, state.cur_colour);
}
@ -114,8 +114,8 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s
/* Better safe than sorry. */
*buff = '\0';
if (fontMapping.count(buff - buff_begin) == 0) {
fontMapping[buff - buff_begin] = f;
if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) {
fontMapping.emplace_back(buff - buff_begin, f);
}
line.layout = T::GetParagraphLayout(buff_begin, buff, fontMapping);
line.state_after = state;

View File

@ -81,7 +81,7 @@ public:
};
/** Mapping from index to font. The pointer is owned by FontColourMap. */
using FontMap = std::map<int, Font *>;
using FontMap = std::vector<std::pair<int, Font *>>;
/**
* Interface to glue fallback and normal layouter into one.

View File

@ -102,7 +102,7 @@ public:
/* Extract font information for this run. */
CFRange chars = CTRunGetStringRange(run);
auto map = fontMapping.upper_bound(chars.location);
auto map = std::ranges::upper_bound(fontMapping, chars.location, std::less{}, &std::pair<int, Font *>::first);
this->emplace_back(run, map->second, buff);
}