1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-18 00:54:19 +00:00

Removed the (rather pointless) granularity value from the array objects. Converted a few macros into functions and other misc code clean-ups.

This commit is contained in:
Julian Storer 2010-01-13 18:58:40 +00:00
parent c368805559
commit 97035bb3a1
69 changed files with 218 additions and 369 deletions

View file

@ -27,14 +27,6 @@
#define __JUCE_ARRAYALLOCATIONBASE_JUCEHEADER__
//==============================================================================
/** The default size of chunk in which arrays increase their storage.
Used by ArrayAllocationBase and its subclasses.
*/
const int juceDefaultArrayGranularity = 8;
//==============================================================================
/**
Implements some basic array storage allocation functions.
@ -49,17 +41,11 @@ class ArrayAllocationBase
{
public:
//==============================================================================
/** Creates an empty array.
@param granularity_ this is the size of increment by which the internal storage
will be increased.
*/
ArrayAllocationBase (const int granularity_) throw()
/** Creates an empty array. */
ArrayAllocationBase() throw()
: elements (0),
numAllocated (0),
granularity (granularity_)
numAllocated (0)
{
jassert (granularity > 0);
}
/** Destructor. */
@ -114,25 +100,21 @@ public:
void ensureAllocatedSize (int minNumElements) throw()
{
if (minNumElements > numAllocated)
{
// for arrays with small granularity that get big, start
// increasing the size in bigger jumps
if (minNumElements > (granularity << 6))
{
minNumElements += (minNumElements / granularity);
if (minNumElements > (granularity << 8))
minNumElements += granularity << 6;
else
minNumElements += granularity << 5;
}
setAllocatedSize ((minNumElements + minNumElements / 2 + 8) & ~7);
}
setAllocatedSize (granularity * (minNumElements / granularity + 1));
}
/** Minimises the amount of storage allocated so that it's no more than
the given number of elements.
*/
void shrinkToNoMoreThan (int maxNumElements) throw()
{
if (maxNumElements < numAllocated)
setAllocatedSize (maxNumElements);
}
//==============================================================================
ElementType* elements;
int numAllocated, granularity;
int numAllocated;
private:
ArrayAllocationBase (const ArrayAllocationBase&);