mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Replace FontMap's std::map with std::vector. (#13126)
parent
8b8cd9ae2d
commit
23e252ad40
|
@ -105,8 +105,8 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontMapping.count(buff - buff_begin) == 0) {
|
if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) {
|
||||||
fontMapping[buff - buff_begin] = f;
|
fontMapping.emplace_back(buff - buff_begin, f);
|
||||||
}
|
}
|
||||||
f = Layouter::GetFont(state.fontsize, state.cur_colour);
|
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. */
|
/* Better safe than sorry. */
|
||||||
*buff = '\0';
|
*buff = '\0';
|
||||||
|
|
||||||
if (fontMapping.count(buff - buff_begin) == 0) {
|
if (fontMapping.empty() || fontMapping.back().first != buff - buff_begin) {
|
||||||
fontMapping[buff - buff_begin] = f;
|
fontMapping.emplace_back(buff - buff_begin, f);
|
||||||
}
|
}
|
||||||
line.layout = T::GetParagraphLayout(buff_begin, buff, fontMapping);
|
line.layout = T::GetParagraphLayout(buff_begin, buff, fontMapping);
|
||||||
line.state_after = state;
|
line.state_after = state;
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Mapping from index to font. The pointer is owned by FontColourMap. */
|
/** 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.
|
* Interface to glue fallback and normal layouter into one.
|
||||||
|
|
|
@ -102,7 +102,7 @@ public:
|
||||||
|
|
||||||
/* Extract font information for this run. */
|
/* Extract font information for this run. */
|
||||||
CFRange chars = CTRunGetStringRange(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);
|
this->emplace_back(run, map->second, buff);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue