Performance measurement shows Editor::CheckModificationForWrap()
is a hot function for replace all, where most time spend on view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle);
.
The time can be reduced by change allInvalidated
to record rough max validity of all line layout:
void LineLayoutCache::Invalidate(LineLayout::ValidLevel validity_) noexcept {
- if (!cache.empty() && !allInvalidated) {
+ if (!cache.empty() && maxValidity > validity_) {
+ maxValidity = validity_;
for (const std::shared_ptr<LineLayout> &ll : cache) {
if (ll) {
ll->Invalidate(validity_);
}
}
- if (validity_ == LineLayout::ValidLevel::invalid) {
- allInvalidated = true;
- }
}
}
so the loop will only be entered once.
On my i5 with page cache, this change reduced about 200ms for SciTEBase::DoReplaceAll()
on replacing all dot to comma for 0N 9V.txt at https://github.com/notepad-plus-plus/notepad-plus-plus/issues/10930#issuecomment-998760967
This seems worthwhile. The removal of the
if
also seems to make Visual C++ inline this code which helps further.Its delayed by the macOS crash fix release.
Should me add another patch to inline
Editor::CheckModificationForWrap()
? which is basically https://github.com/zufuliu/notepad2/commit/4e872ae2300a9b2fd2169ed8b811cdca94399d5aIt also moved code after
// Some lines are hidden so may need shown.
into a separate function as the block not frequent executed, also to reduce code size ofEditor::NotifyModified()
.!cache.empty()
can also be removed, as the range based for loop already checks empty.Patch removed
!cache.empty()
fromInvalidate()
and addedmaxValidity = LineLayout::ValidLevel::invalid;
intoDeallocate()
.Committed with [2d34aa].
Related
Commit: [2d34aa]
A somewhat unrelated patch: simplify some
FlagSet()
codes, https://github.com/zufuliu/notepad2/commit/9de4a994ceb266f1bca583dd4eb1009e641e80beThis produces different results, probably the ordering of the clauses in first hunk:
There is also a duplicated "Paint the line above the fold" comment that makes merging difficult.
Fixed the typo.
This hunk appears incorrect: what is the second
mh.modificationType
doing?Fixed.
Committed as [7f2549].
Related
Commit: [7f2549]