Browse Source

Added a minimum-size template parameter to Array.

tags/2021-05-28
jules 12 years ago
parent
commit
cb24acca97
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      modules/juce_core/containers/juce_Array.h

+ 4
- 3
modules/juce_core/containers/juce_Array.h View File

@@ -56,7 +56,8 @@
@see OwnedArray, ReferenceCountedArray, StringArray, CriticalSection
*/
template <typename ElementType,
typename TypeOfCriticalSectionToUse = DummyCriticalSection>
typename TypeOfCriticalSectionToUse = DummyCriticalSection,
int minimumAllocatedSize = 0>
class Array
{
private:
@@ -1035,8 +1036,8 @@ private:
void minimiseStorageAfterRemoval()
{
if (data.numAllocated > numUsed * 2)
data.shrinkToNoMoreThan (jmax (numUsed, 64 / (int) sizeof (ElementType)));
if (data.numAllocated > jmax (minimumAllocatedSize, numUsed * 2))
data.shrinkToNoMoreThan (jmax (numUsed, jmax (minimumAllocatedSize, 64 / (int) sizeof (ElementType))));
}
};


Loading…
Cancel
Save