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:
parent
c368805559
commit
97035bb3a1
69 changed files with 218 additions and 369 deletions
|
|
@ -51,22 +51,15 @@ class ReferenceCountedArray
|
|||
public:
|
||||
//==============================================================================
|
||||
/** Creates an empty array.
|
||||
|
||||
@param granularity this is the size of increment by which the internal storage
|
||||
used by the array will grow. Only change it from the default if you know the
|
||||
array is going to be very big and needs to be able to grow efficiently.
|
||||
|
||||
@see ReferenceCountedObject, Array, OwnedArray
|
||||
*/
|
||||
ReferenceCountedArray (const int granularity = juceDefaultArrayGranularity) throw()
|
||||
: data (granularity),
|
||||
numUsed (0)
|
||||
ReferenceCountedArray() throw()
|
||||
: numUsed (0)
|
||||
{
|
||||
}
|
||||
|
||||
/** Creates a copy of another array */
|
||||
ReferenceCountedArray (const ReferenceCountedArray<ObjectClass, TypeOfCriticalSectionToUse>& other) throw()
|
||||
: data (other.data.granularity)
|
||||
{
|
||||
other.lockArray();
|
||||
numUsed = other.numUsed;
|
||||
|
|
@ -93,7 +86,6 @@ public:
|
|||
|
||||
clear();
|
||||
|
||||
data.granularity = other.granularity;
|
||||
data.ensureAllocatedSize (other.numUsed);
|
||||
numUsed = other.numUsed;
|
||||
memcpy (data.elements, other.data.elements, numUsed * sizeof (ObjectClass*));
|
||||
|
|
@ -738,19 +730,7 @@ public:
|
|||
void minimiseStorageOverheads() throw()
|
||||
{
|
||||
lock.enter();
|
||||
|
||||
if (numUsed == 0)
|
||||
{
|
||||
data.setAllocatedSize (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int newAllocation = data.granularity * (numUsed / data.granularity + 1);
|
||||
|
||||
if (newAllocation < data.numAllocated)
|
||||
data.setAllocatedSize (newAllocation);
|
||||
}
|
||||
|
||||
data.shrinkToNoMoreThan (numUsed);
|
||||
lock.exit();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue