From 0fc1ede50f8a9fdf059c509043a02cbc269ccd89 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 22 Apr 2021 17:35:48 +0100 Subject: [PATCH] Used MemoryBlock::isEmpty() in a few places --- .../juce_audio_devices/native/juce_win32_WASAPI.cpp | 2 +- .../codecs/juce_AiffAudioFormat.cpp | 12 ++++++------ .../codecs/juce_WavAudioFormat.cpp | 4 ++-- modules/juce_core/native/juce_android_Network.cpp | 2 +- modules/juce_core/native/juce_curl_Network.cpp | 4 ++-- modules/juce_core/native/juce_mac_Network.mm | 2 +- modules/juce_core/network/juce_URL.cpp | 4 ++-- modules/juce_core/streams/juce_OutputStream.cpp | 2 +- .../native/juce_mac_CoreGraphicsContext.mm | 2 +- .../native/juce_android_WebBrowserComponent.cpp | 2 +- .../native/juce_win32_WebBrowserComponent.cpp | 2 +- .../marketplace/juce_OnlineUnlockStatus.cpp | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index e86cfd08e7..dbe72c3fd6 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -975,7 +975,7 @@ public: void copyBuffersFromReservoir (float** destBuffers, int numDestBuffers, int bufferSize) { - if ((numChannels <= 0 && bufferSize == 0) || reservoir.getSize() == 0) + if ((numChannels <= 0 && bufferSize == 0) || reservoir.isEmpty()) return; int offset = jmax (0, bufferSize - getNumSamplesInReservoir()); diff --git a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index a389d009a5..c24b29874b 100644 --- a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp @@ -728,9 +728,9 @@ private: // to be able to seek back to write the header jassert (couldSeekOk); - auto headerLen = (int) (54 + (markChunk.getSize() > 0 ? markChunk.getSize() + 8 : 0) - + (comtChunk.getSize() > 0 ? comtChunk.getSize() + 8 : 0) - + (instChunk.getSize() > 0 ? instChunk.getSize() + 8 : 0)); + auto headerLen = (int) (54 + (markChunk.isEmpty() ? 0 : markChunk.getSize() + 8) + + (comtChunk.isEmpty() ? 0 : comtChunk.getSize() + 8) + + (instChunk.isEmpty() ? 0 : instChunk.getSize() + 8)); auto audioBytes = (int) (lengthInSamples * ((bitsPerSample * numChannels) / 8)); audioBytes += (audioBytes & 1); @@ -786,21 +786,21 @@ private: output->write (sampleRateBytes, 10); - if (markChunk.getSize() > 0) + if (! markChunk.isEmpty()) { output->writeInt (chunkName ("MARK")); output->writeIntBigEndian ((int) markChunk.getSize()); *output << markChunk; } - if (comtChunk.getSize() > 0) + if (! comtChunk.isEmpty()) { output->writeInt (chunkName ("COMT")); output->writeIntBigEndian ((int) comtChunk.getSize()); *output << comtChunk; } - if (instChunk.getSize() > 0) + if (! instChunk.isEmpty()) { output->writeInt (chunkName ("INST")); output->writeIntBigEndian ((int) instChunk.getSize()); diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 7642040bd9..eddc9d3cf5 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -1509,7 +1509,7 @@ private: usesFloatingPointData = (bitsPerSample == 32); } - static size_t chunkSize (const MemoryBlock& data) noexcept { return data.getSize() > 0 ? (8 + data.getSize()) : 0; } + static size_t chunkSize (const MemoryBlock& data) noexcept { return data.isEmpty() ? 0 : (8 + data.getSize()); } void writeChunkHeader (int chunkType, int size) const { @@ -1519,7 +1519,7 @@ private: void writeChunk (const MemoryBlock& data, int chunkType, int size = 0) const { - if (data.getSize() > 0) + if (! data.isEmpty()) { writeChunkHeader (chunkType, size != 0 ? size : (int) data.getSize()); *output << data; diff --git a/modules/juce_core/native/juce_android_Network.cpp b/modules/juce_core/native/juce_android_Network.cpp index b9de1e21d8..dcd0abc191 100644 --- a/modules/juce_core/native/juce_android_Network.cpp +++ b/modules/juce_core/native/juce_android_Network.cpp @@ -390,7 +390,7 @@ public: jbyteArray postDataArray = nullptr; - if (postData.getSize() > 0) + if (! postData.isEmpty()) { postDataArray = env->NewByteArray (static_cast (postData.getSize())); env->SetByteArrayRegion (postDataArray, 0, static_cast (postData.getSize()), (const jbyte*) postData.getData()); diff --git a/modules/juce_core/native/juce_curl_Network.cpp b/modules/juce_core/native/juce_curl_Network.cpp index f80b806abe..b021103e85 100644 --- a/modules/juce_core/native/juce_curl_Network.cpp +++ b/modules/juce_core/native/juce_curl_Network.cpp @@ -144,7 +144,7 @@ public: //============================================================================== // Input Stream overrides bool isError() const { return curl == nullptr || lastError != CURLE_OK; } - bool isExhausted() { return (isError() || finished) && curlBuffer.getSize() == 0; } + bool isExhausted() { return (isError() || finished) && curlBuffer.isEmpty(); } int64 getPosition() { return streamPos; } int64 getTotalLength() { return contentLength; } @@ -336,7 +336,7 @@ public: // step until either: 1) there is an error 2) the transaction is complete // or 3) data is in the in buffer - while ((! finished) && curlBuffer.getSize() == 0) + while ((! finished) && curlBuffer.isEmpty()) { { const ScopedLock lock (cleanupLock); diff --git a/modules/juce_core/native/juce_mac_Network.mm b/modules/juce_core/native/juce_mac_Network.mm index bbf61c3b0c..e8755ea3f7 100644 --- a/modules/juce_core/native/juce_mac_Network.mm +++ b/modules/juce_core/native/juce_mac_Network.mm @@ -1121,7 +1121,7 @@ private: postData, addParametersToRequestBody); - if (postData.getSize() > 0) + if (! postData.isEmpty()) [req setHTTPBody: [NSData dataWithBytes: postData.getData() length: postData.getSize()]]; } diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index 8bcfb656ae..98159340f3 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -454,7 +454,7 @@ URL URL::getChildURL (const String& subPath) const bool URL::hasBodyDataToSend() const { - return filesToUpload.size() > 0 || postData.getSize() > 0; + return filesToUpload.size() > 0 || ! postData.isEmpty(); } void URL::createHeadersAndPostData (String& headers, @@ -466,7 +466,7 @@ void URL::createHeadersAndPostData (String& headers, if (filesToUpload.size() > 0) { // (this doesn't currently support mixing custom post-data with uploads..) - jassert (postData.getSize() == 0); + jassert (postData.isEmpty()); auto boundary = String::toHexString (Random::getSystemRandom().nextInt64()); diff --git a/modules/juce_core/streams/juce_OutputStream.cpp b/modules/juce_core/streams/juce_OutputStream.cpp index ca868fae4d..c572771229 100644 --- a/modules/juce_core/streams/juce_OutputStream.cpp +++ b/modules/juce_core/streams/juce_OutputStream.cpp @@ -364,7 +364,7 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const cha JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryBlock& data) { - if (data.getSize() > 0) + if (! data.isEmpty()) stream.write (data.getData(), data.getSize()); return stream; diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index f627781f8b..77350dcc09 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -829,7 +829,7 @@ Image juce_loadWithCoreImage (InputStream& input) MemoryBlockHolder::Ptr memBlockHolder = new MemoryBlockHolder(); input.readIntoMemoryBlock (memBlockHolder->block, -1); - if (memBlockHolder->block.getSize() == 0) + if (memBlockHolder->block.isEmpty()) return {}; #if JUCE_IOS diff --git a/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp index 3f6236c4e5..fbecb064b0 100644 --- a/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp @@ -681,7 +681,7 @@ void WebBrowserComponent::reloadLastURL() { if (lastURL.isNotEmpty()) { - goToURL (lastURL, &lastHeaders, lastPostData.getSize() == 0 ? nullptr : &lastPostData); + goToURL (lastURL, &lastHeaders, lastPostData.isEmpty() ? nullptr : &lastPostData); lastURL.clear(); } } diff --git a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp index 285e7bce37..2c7b7bed22 100644 --- a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp @@ -538,7 +538,7 @@ private: { String method ("GET"); - if (urlRequest.postData.getSize() > 0) + if (! urlRequest.postData.isEmpty()) { method = "POST"; diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp index 83a6334d67..4d47bee7d7 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp @@ -229,7 +229,7 @@ void OnlineUnlockStatus::load() MemoryBlock mb; mb.fromBase64Encoding (getState()); - if (mb.getSize() > 0) + if (! mb.isEmpty()) status = ValueTree::readFromGZIPData (mb.getData(), mb.getSize()); else status = ValueTree (stateTagName);