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:
Frédéric Simonis
2021-08-16 11:18:47 +02:00
committed by GitHub
parent 2e6a77a78a
commit ac4a7d02c7
2 changed files with 26 additions and 7 deletions

View File

@@ -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);