From 622990db744be0aaef3cf9aabf0aa48e5e7e35e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 19 May 2024 21:15:28 -0300 Subject: [PATCH] Some performance optimizations. --- include/eepp/ui/doc/textdocument.hpp | 2 ++ src/eepp/ui/uicodeeditor.cpp | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/eepp/ui/doc/textdocument.hpp b/include/eepp/ui/doc/textdocument.hpp index 51a2af56c..623ca5544 100644 --- a/include/eepp/ui/doc/textdocument.hpp +++ b/include/eepp/ui/doc/textdocument.hpp @@ -63,6 +63,8 @@ class EE_API TextDocument { ranges.reserve( size() ); for ( const auto& r : *this ) ranges.push_back( r.result ); + if ( isSorted() ) + ranges.setSorted(); return ranges; } diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 2e8e95c1b..c233127d9 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -3289,6 +3289,8 @@ void UICodeEditor::drawWordRanges( const TextRanges& ranges, const std::pairgetSelection( true ); + Rectf area = getScreenBounds(); + Int64 lastSkipLine = -1; for ( const auto& range : ranges ) { if ( !( range.start().line() >= lineRange.first && @@ -3301,7 +3303,7 @@ void UICodeEditor::drawWordRanges( const TextRanges& ranges, const std::pair area.Right ) { + lastSkipLine = range.start().line(); + } + } } primitives.setForceDraw( true ); @@ -4127,6 +4134,7 @@ void UICodeEditor::drawMinimap( const Vector2f& start, const std::pairquadsSetColor( backgroundColor ); Int64 lineSkip = -1; for ( const auto& range : ranges ) { + if ( !mLineWrapping.isWrapEnabled() && range.start().column() > maxVisibleColumn ) + continue; + auto rangeStart = mLineWrapping.getVisualLineInfo( range.start() ); auto rangeEnd = mLineWrapping.getVisualLineInfo( range.end() ); - if ( !( endidx < rangeStart.visualIndex || minimapStartLine < rangeEnd.visualIndex ) ) + if ( minimapStartLine > rangeEnd.visualIndex || endidx < rangeStart.visualIndex ) continue; if ( ranges.isSorted() && rangeEnd.visualIndex > endidx )