Codechange: Improve LineCache queries (#9417)
Adds the support to query the linecache without copying the string. This uses a custom transparent comparator in conjunction with a query type using a std::string_view.
This commit is contained in:
@@ -888,6 +888,12 @@ Layouter::LineCacheItem &Layouter::GetCachedParagraphLayout(const char *str, siz
|
||||
linecache = new LineCache();
|
||||
}
|
||||
|
||||
if (auto match = linecache->find(LineCacheQuery{state, std::string_view{str, len}});
|
||||
match != linecache->end()) {
|
||||
return match->second;
|
||||
}
|
||||
|
||||
/* Create missing entry */
|
||||
LineCacheKey key;
|
||||
key.state_before = state;
|
||||
key.str.assign(str, len);
|
||||
|
Reference in New Issue
Block a user