From 731a9b1d5938c6577e6f09aae5bc6d6c94052cee Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 15 Jul 2013 11:08:45 +0100 Subject: [PATCH] Added method StringArray::ensureStorageAllocated() --- modules/juce_core/text/juce_StringArray.cpp | 5 +++++ modules/juce_core/text/juce_StringArray.h | 8 ++++++++ 2 files changed, 13 insertions(+) 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