Browse Source

Renamed the swapWithArray methods in the array classes to "swapWith" to be more consistent with other swap method naming, and templated the methods for more flexibility.

tags/2021-05-28
jules 12 years ago
parent
commit
5b25ac6609
17 changed files with 47 additions and 31 deletions
  1. +1
    -1
      extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp
  2. +1
    -1
      modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp
  3. +1
    -1
      modules/juce_audio_devices/native/juce_win32_ASIO.cpp
  4. +1
    -1
      modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp
  5. +2
    -2
      modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp
  6. +9
    -4
      modules/juce_core/containers/juce_Array.h
  7. +4
    -3
      modules/juce_core/containers/juce_HashMap.h
  8. +8
    -3
      modules/juce_core/containers/juce_OwnedArray.h
  9. +10
    -5
      modules/juce_core/containers/juce_ReferenceCountedArray.h
  10. +1
    -1
      modules/juce_core/containers/juce_SortedSet.h
  11. +1
    -1
      modules/juce_core/text/juce_StringArray.cpp
  12. +1
    -1
      modules/juce_graphics/geometry/juce_RectangleList.cpp
  13. +1
    -1
      modules/juce_gui_basics/components/juce_Desktop.cpp
  14. +2
    -2
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp
  15. +1
    -1
      modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp
  16. +2
    -2
      modules/juce_gui_basics/windows/juce_ComponentPeer.cpp
  17. +1
    -1
      modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp

+ 1
- 1
extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp View File

@@ -111,7 +111,7 @@ void AppearanceSettings::refreshPresetSchemeList()
if (newSchemes != presetSchemeFiles)
{
presetSchemeFiles.swapWithArray (newSchemes);
presetSchemeFiles.swapWith (newSchemes);
commandManager->commandStatusChanged();
}
}


+ 1
- 1
modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp View File

@@ -43,7 +43,7 @@ MidiMessageSequence& MidiMessageSequence::operator= (const MidiMessageSequence&
void MidiMessageSequence::swapWith (MidiMessageSequence& other) noexcept
{
list.swapWithArray (other.list);
list.swapWith (other.list);
}
MidiMessageSequence::~MidiMessageSequence()


+ 1
- 1
modules/juce_audio_devices/native/juce_win32_ASIO.cpp View File

@@ -387,7 +387,7 @@ public:
if (sampleRates != newRates)
{
sampleRates.swapWithArray (newRates);
sampleRates.swapWith (newRates);
#if JUCE_ASIO_DEBUGGING
StringArray s;


+ 1
- 1
modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp View File

@@ -162,7 +162,7 @@ bool BufferingAudioReader::readNextBufferChunk()
{
const ScopedLock sl (lock);
newBlocks.swapWithArray (blocks);
newBlocks.swapWith (blocks);
}
for (int i = blocks.size(); --i >= 0;)


+ 2
- 2
modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp View File

@@ -1180,7 +1180,7 @@ void AudioProcessorGraph::clearRenderingSequence()
{
const ScopedLock sl (getCallbackLock());
renderingOps.swapWithArray (oldOps);
renderingOps.swapWith (oldOps);
}
deleteRenderOpArray (oldOps);
@@ -1254,7 +1254,7 @@ void AudioProcessorGraph::buildRenderingSequence()
while (midiBuffers.size() < numMidiBuffersNeeded)
midiBuffers.add (new MidiBuffer());
renderingOps.swapWithArray (newRenderingOps);
renderingOps.swapWith (newRenderingOps);
}
// delete the old ones..


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

@@ -137,7 +137,7 @@ public:
if (this != &other)
{
Array<ElementType, TypeOfCriticalSectionToUse> otherCopy (other);
swapWithArray (otherCopy);
swapWith (otherCopy);
}
return *this;
@@ -576,11 +576,11 @@ public:
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
because it just swaps their internal pointers.
*/
void swapWithArray (Array& otherArray) noexcept
template <class OtherArrayType>
void swapWith (OtherArrayType& otherArray) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherArray.getLock());
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
data.swapWith (otherArray.data);
std::swap (numUsed, otherArray.numUsed);
}
@@ -1025,6 +1025,11 @@ public:
typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType;
//==============================================================================
// Note that the swapWithArray method has been replaced by a more flexible templated version,
// and renamed "swapWith" to be more consistent with the names used in other classes.
JUCE_DEPRECATED_WITH_BODY (void swapWithArray (Array& other) noexcept, { swapWith (other); })
private:
//==============================================================================
ArrayAllocationBase <ElementType, TypeOfCriticalSectionToUse> data;


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

@@ -317,12 +317,13 @@ public:
//==============================================================================
/** Efficiently swaps the contents of two hash-maps. */
void swapWith (HashMap& otherHashMap) noexcept
template <class OtherHashMapType>
void swapWith (OtherHashMapType& otherHashMap) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherHashMap.getLock());
const typename OtherHashMapType::ScopedLockType lock2 (otherHashMap.getLock());
slots.swapWithArray (otherHashMap.slots);
slots.swapWith (otherHashMap.slots);
std::swap (totalNumItems, otherHashMap.totalNumItems);
}


+ 8
- 3
modules/juce_core/containers/juce_OwnedArray.h View File

@@ -792,11 +792,11 @@ public:
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
because it just swaps their internal pointers.
*/
void swapWithArray (OwnedArray& otherArray) noexcept
template <class OtherArrayType>
void swapWith (OtherArrayType& otherArray) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherArray.getLock());
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
data.swapWith (otherArray.data);
std::swap (numUsed, otherArray.numUsed);
}
@@ -874,6 +874,11 @@ public:
typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType;
//==============================================================================
// Note that the swapWithArray method has been replaced by a more flexible templated version,
// and renamed "swapWith" to be more consistent with the names used in other classes.
JUCE_DEPRECATED_WITH_BODY (void swapWithArray (OwnedArray& other) noexcept, { swapWith (other); })
private:
//==============================================================================
ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse> data;


+ 10
- 5
modules/juce_core/containers/juce_ReferenceCountedArray.h View File

@@ -96,7 +96,7 @@ public:
ReferenceCountedArray& operator= (const ReferenceCountedArray& other) noexcept
{
ReferenceCountedArray otherCopy (other);
swapWithArray (otherCopy);
swapWith (otherCopy);
return *this;
}
@@ -107,7 +107,7 @@ public:
ReferenceCountedArray<ObjectClass, TypeOfCriticalSectionToUse>& operator= (const ReferenceCountedArray<OtherObjectClass, TypeOfCriticalSectionToUse>& other) noexcept
{
ReferenceCountedArray<ObjectClass, TypeOfCriticalSectionToUse> otherCopy (other);
swapWithArray (otherCopy);
swapWith (otherCopy);
return *this;
}
@@ -745,11 +745,11 @@ public:
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
because it just swaps their internal pointers.
*/
void swapWithArray (ReferenceCountedArray& otherArray) noexcept
template <class OtherArrayType>
void swapWith (OtherArrayType& otherArray) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherArray.getLock());
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
data.swapWith (otherArray.data);
std::swap (numUsed, otherArray.numUsed);
}
@@ -857,6 +857,11 @@ public:
typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType;
//==============================================================================
// Note that the swapWithArray method has been replaced by a more flexible templated version,
// and renamed "swapWith" to be more consistent with the names used in other classes.
JUCE_DEPRECATED_WITH_BODY (void swapWithArray (ReferenceCountedArray& other) noexcept, { swapWith (other); })
private:
//==============================================================================
ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse> data;


+ 1
- 1
modules/juce_core/containers/juce_SortedSet.h View File

@@ -450,7 +450,7 @@ public:
*/
void swapWith (SortedSet& otherSet) noexcept
{
data.swapWithArray (otherSet.data);
data.swapWith (otherSet.data);
}
//==============================================================================


+ 1
- 1
modules/juce_core/text/juce_StringArray.cpp View File

@@ -127,7 +127,7 @@ bool StringArray::operator!= (const StringArray& other) const noexcept
void StringArray::swapWith (StringArray& other) noexcept
{
strings.swapWithArray (other.strings);
strings.swapWith (other.strings);
}
void StringArray::clear()


+ 1
- 1
modules/juce_graphics/geometry/juce_RectangleList.cpp View File

@@ -332,7 +332,7 @@ bool RectangleList::getIntersectionWith (const Rectangle<int>& rect, RectangleLi
void RectangleList::swapWith (RectangleList& otherList) noexcept
{
rects.swapWithArray (otherList.rects);
rects.swapWith (otherList.rects);
}


+ 1
- 1
modules/juce_gui_basics/components/juce_Desktop.cpp View File

@@ -420,7 +420,7 @@ void Desktop::Displays::init (Desktop& desktop)
void Desktop::Displays::refresh()
{
Array<Display> oldDisplays;
oldDisplays.swapWithArray (displays);
oldDisplays.swapWith (displays);
init (Desktop::getInstance());


+ 2
- 2
modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

@@ -1150,14 +1150,14 @@ PopupMenu& PopupMenu::operator= (const PopupMenu& other)
PopupMenu::PopupMenu (PopupMenu&& other) noexcept
: lookAndFeel (other.lookAndFeel)
{
items.swapWithArray (other.items);
items.swapWith (other.items);
}
PopupMenu& PopupMenu::operator= (PopupMenu&& other) noexcept
{
jassert (this != &other); // hopefully the compiler should make this situation impossible!
items.swapWithArray (other.items);
items.swapWith (other.items);
lookAndFeel = other.lookAndFeel;
return *this;
}


+ 1
- 1
modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp View File

@@ -94,7 +94,7 @@ bool RelativePointPath::operator!= (const RelativePointPath& other) const noexce
void RelativePointPath::swapWith (RelativePointPath& other) noexcept
{
elements.swapWithArray (other.elements);
elements.swapWith (other.elements);
std::swap (usesNonZeroWinding, other.usesNonZeroWinding);
std::swap (containsDynamicPoints, other.containsDynamicPoints);
}


+ 2
- 2
modules/juce_gui_basics/windows/juce_ComponentPeer.cpp View File

@@ -22,7 +22,7 @@
==============================================================================
*/
static uint32 lastUniqueID = 1;
static uint32 lastUniquePeerID = 1;
//==============================================================================
ComponentPeer::ComponentPeer (Component& comp, const int flags)
@@ -30,7 +30,7 @@ ComponentPeer::ComponentPeer (Component& comp, const int flags)
styleFlags (flags),
constrainer (nullptr),
lastDragAndDropCompUnderMouse (nullptr),
uniqueID (lastUniqueID += 2), // increment by 2 so that this can never hit 0
uniqueID (lastUniquePeerID += 2), // increment by 2 so that this can never hit 0
isWindowMinimised (false)
{
Desktop::getInstance().peers.add (this);


+ 1
- 1
modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp View File

@@ -76,7 +76,7 @@ public:
return false;
}
tokens.swapWithArray (newTokens);
tokens.swapWith (newTokens);
return true;
}


Loading…
Cancel
Save