diff --git a/modules/juce_core/text/juce_StringArray.cpp b/modules/juce_core/text/juce_StringArray.cpp index cbbaca52d7..859110bec8 100644 --- a/modules/juce_core/text/juce_StringArray.cpp +++ b/modules/juce_core/text/juce_StringArray.cpp @@ -504,6 +504,11 @@ void StringArray::appendNumbersToDuplicates (const bool ignoreCase, } } +void StringArray::ensureStorageAllocated (int minNumElements) +{ + strings.ensureStorageAllocated (minNumElements); +} + void StringArray::minimiseStorageOverheads() { strings.minimiseStorageOverheads(); diff --git a/modules/juce_core/text/juce_StringArray.h b/modules/juce_core/text/juce_StringArray.h index 7dd9ef1a29..b14f63f7f0 100644 --- a/modules/juce_core/text/juce_StringArray.h +++ b/modules/juce_core/text/juce_StringArray.h @@ -391,6 +391,14 @@ 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. Arrays typically allocate slightly more storage than they need, and after