diff --git a/modules/beast_core/text/beast_StringArray.cpp b/modules/beast_core/text/beast_StringArray.cpp index 8df29ea4f0..26a7a2ef72 100644 --- a/modules/beast_core/text/beast_StringArray.cpp +++ b/modules/beast_core/text/beast_StringArray.cpp @@ -499,6 +499,11 @@ void StringArray::appendNumbersToDuplicates (const bool ignoreCase, } } +void StringArray::ensureStorageAllocated (int minNumElements) +{ + strings.ensureStorageAllocated (minNumElements); +} + void StringArray::minimiseStorageOverheads() { strings.minimiseStorageOverheads(); diff --git a/modules/beast_core/text/beast_StringArray.h b/modules/beast_core/text/beast_StringArray.h index 1b0978fe1e..b98932d8f7 100644 --- a/modules/beast_core/text/beast_StringArray.h +++ b/modules/beast_core/text/beast_StringArray.h @@ -385,6 +385,15 @@ public: */ void sort (bool ignoreCase); + //============================================================================== + /** Increases the array's internal storage to hold a minimum number of elements. + + Calling this before adding a large known number of elements means that + the array won't have to keep dynamically resizing itself as the elements + are added, and it'll therefore be more efficient. + */ + void ensureStorageAllocated (int minNumElements); + //============================================================================== /** Reduces the amount of storage being used by the array.