From 5218b62655b877af64f9980efa668a1dcb82ed43 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 29 Jul 2022 09:52:43 +1000 Subject: Add growSize argument to SplitVector constructor with default value so can be used more simply. Add default value to growSize argument of Partitioning to enable default construction. --- src/Partitioning.h | 4 ++-- src/SplitVector.h | 2 +- test/unit/testPartitioning.cxx | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Partitioning.h b/src/Partitioning.h index 165672a15..da68dfb56 100644 --- a/src/Partitioning.h +++ b/src/Partitioning.h @@ -17,7 +17,7 @@ namespace Scintilla::Internal { template class SplitVectorWithRangeAdd : public SplitVector { public: - explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_) { + explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_=8) { this->SetGrowSize(growSize_); this->ReAllocate(growSize_); } @@ -94,7 +94,7 @@ private: } public: - explicit Partitioning(int growSize) : stepPartition(0), stepLength(0) { + explicit Partitioning(size_t growSize=8) : stepPartition(0), stepLength(0) { Allocate(growSize); } diff --git a/src/SplitVector.h b/src/SplitVector.h index adaa8eeb8..d0823b0b6 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -71,7 +71,7 @@ protected: public: /// Construct a split buffer. - SplitVector() : empty(), lengthBody(0), part1Length(0), gapLength(0), growSize(8) { + SplitVector(size_t growSize_=8) : empty(), lengthBody(0), part1Length(0), gapLength(0), growSize(growSize_) { } // Deleted so SplitVector objects can not be copied. diff --git a/test/unit/testPartitioning.cxx b/test/unit/testPartitioning.cxx index b8989cdff..7e12c2ff0 100644 --- a/test/unit/testPartitioning.cxx +++ b/test/unit/testPartitioning.cxx @@ -22,8 +22,6 @@ using namespace Scintilla::Internal; -constexpr int growSize = 4; - constexpr int lengthTestArray = 8; static const int testArray[lengthTestArray] = {3, 4, 5, 6, 7, 8, 9, 10}; @@ -31,7 +29,7 @@ static const int testArray[lengthTestArray] = {3, 4, 5, 6, 7, 8, 9, 10}; TEST_CASE("SplitVectorWithRangeAdd") { - SplitVectorWithRangeAdd svwra(growSize); + SplitVectorWithRangeAdd svwra; SECTION("IsEmptyInitially") { REQUIRE(0 == svwra.Length()); @@ -54,7 +52,7 @@ TEST_CASE("SplitVectorWithRangeAdd") { TEST_CASE("Partitioning") { - Partitioning part(growSize); + Partitioning part; SECTION("IsEmptyInitially") { REQUIRE(1 == part.Partitions()); -- cgit v1.2.3