aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PositionCache.cxx
diff options
context:
space:
mode:
authorZufu Liu <unknown>2021-09-28 13:04:23 +1000
committerZufu Liu <unknown>2021-09-28 13:04:23 +1000
commit30bc23dbb011c9394714aa304fa88ac356ccce17 (patch)
treec5493442c6efcead5e9248968dd5494311cf0db3 /src/PositionCache.cxx
parentfe41a24534e1280f088835ea1813fa64120f4169 (diff)
downloadscintilla-mirror-30bc23dbb011c9394714aa304fa88ac356ccce17.tar.gz
Feature [feature-requests:#1416] Change evaluation order so that monospaceASCII
checked before cache which may improve performance for monospaceASCII. Only reset clear state when storing into cache.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r--src/PositionCache.cxx24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index f24164636..6eee26113 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -882,7 +882,17 @@ size_t PositionCache::GetSize() const noexcept {
void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber,
std::string_view sv, XYPOSITION *positions) {
- allClear = false;
+ const Style &style = vstyle.styles[styleNumber];
+ if (style.monospaceASCII) {
+ if (AllGraphicASCII(sv)) {
+ const XYPOSITION monospaceCharacterWidth = style.monospaceCharacterWidth;
+ for (size_t i = 0; i < sv.length(); i++) {
+ positions[i] = monospaceCharacterWidth * (i+1);
+ }
+ return;
+ }
+ }
+
size_t probe = pces.size(); // Out of bounds
if ((!pces.empty()) && (sv.length() < 30)) {
// Only store short strings in the cache so it doesn't churn with
@@ -903,15 +913,8 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns
probe = probe2;
}
}
- if (vstyle.styles[styleNumber].monospaceASCII) {
- if (AllGraphicASCII(sv)) {
- for (size_t i = 0; i < sv.length(); i++) {
- positions[i] = vstyle.styles[styleNumber].monospaceCharacterWidth * (i+1);
- }
- return;
- }
- }
- const Font *fontStyle = vstyle.styles[styleNumber].font.get();
+
+ const Font *fontStyle = style.font.get();
surface->MeasureWidths(fontStyle, sv, positions);
if (probe < pces.size()) {
// Store into cache
@@ -924,6 +927,7 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns
}
clock = 2;
}
+ allClear = false;
pces[probe].Set(styleNumber, sv, positions, clock);
}
}