mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 07:29:44 +00:00
Codechange: Replace FontMap's std::map with std::vector. (#13126)
This commit is contained in:
parent
8b8cd9ae2d
commit
23e252ad40
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user