mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-01 10:40:20 +03:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user