perf: keep common text selections in inline storage

- migrate TextRanges to SmallVector with capacity for two selections
  - preserve vector, initializer-list, and single-range construction
  - add coverage for inline storage, copying, and heap fallback
  - export UIStyle::PropertyResolution for Windows shared builds
This commit is contained in:
Martín Lucas Golini
2026-08-09 22:09:29 -03:00
parent 23cf9084ce
commit 357f00c8ed
4 changed files with 31 additions and 5 deletions
+6 -2
View File
@@ -254,9 +254,13 @@ Int64 TextRange::minimumDistance( const TextRange& other ) const {
TextRanges::TextRanges() {}
TextRanges::TextRanges( const std::vector<TextRange>& ranges ) : std::vector<TextRange>( ranges ) {}
TextRanges::TextRanges( const std::vector<TextRange>& ranges ) :
SmallVector<TextRange, 2>( ranges.begin(), ranges.end() ) {}
TextRanges::TextRanges( const TextRange& ranges ) : std::vector<TextRange>( { ranges } ) {}
TextRanges::TextRanges( std::initializer_list<TextRange> ranges ) :
SmallVector<TextRange, 2>( ranges ) {}
TextRanges::TextRanges( const TextRange& range ) : SmallVector<TextRange, 2>( { range } ) {}
bool TextRanges::isSorted() const {
return mIsSorted;
@@ -6,6 +6,24 @@
using namespace EE::UI::Doc;
using namespace EE::System;
UTEST( TextRanges, keepsCommonSelectionsInline ) {
TextRanges ranges;
EXPECT_TRUE( ranges.is_small() );
ranges.emplace_back( TextPosition{ 0, 0 }, TextPosition{ 0, 1 } );
ranges.emplace_back( TextPosition{ 1, 0 }, TextPosition{ 1, 1 } );
EXPECT_EQ( 2u, ranges.size() );
EXPECT_TRUE( ranges.is_small() );
TextRanges copy = ranges;
EXPECT_TRUE( ranges == copy );
EXPECT_TRUE( copy.is_small() );
ranges.emplace_back( TextPosition{ 2, 0 }, TextPosition{ 2, 1 } );
EXPECT_EQ( 3u, ranges.size() );
EXPECT_FALSE( ranges.is_small() );
}
UTEST( TextDocument, insertSingleLineAtDifferentPositions ) {
TextDocument doc;