Bug 1398999 - nsDequeFunctor::operator() doesn't need to return anything - r?froydnj
Its return value is never used, and most implementations return nullptr anyway.
MozReview-Commit-ID: 8rxC053mmE8
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3782,41 +3782,39 @@ class VideoQueueMemoryFunctor : public n
public:
VideoQueueMemoryFunctor()
: mSize(0)
{
}
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf);
- virtual void* operator()(void* aObject)
+ virtual void operator()(void* aObject)
{
const VideoData* v = static_cast<const VideoData*>(aObject);
mSize += v->SizeOfIncludingThis(MallocSizeOf);
- return nullptr;
}
size_t mSize;
};
class AudioQueueMemoryFunctor : public nsDequeFunctor
{
public:
AudioQueueMemoryFunctor()
: mSize(0)
{
}
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf);
- virtual void* operator()(void* aObject)
+ virtual void operator()(void* aObject)
{
const AudioData* audioData = static_cast<const AudioData*>(aObject);
mSize += audioData->SizeOfIncludingThis(MallocSizeOf);
- return nullptr;
}
size_t mSize;
};
size_t
MediaDecoderStateMachine::SizeOfVideoQueue() const
{
--- a/dom/media/MediaQueue.h
+++ b/dom/media/MediaQueue.h
@@ -13,19 +13,19 @@
#include "MediaEventSource.h"
#include "TimeUnits.h"
namespace mozilla {
// Thread and type safe wrapper around nsDeque.
template <class T>
class MediaQueueDeallocator : public nsDequeFunctor {
- virtual void* operator() (void* aObject) {
+ virtual void operator()(void* aObject)
+ {
RefPtr<T> releaseMe = dont_AddRef(static_cast<T*>(aObject));
- return nullptr;
}
};
template <class T>
class MediaQueue : private nsDeque {
public:
MediaQueue()
: nsDeque(new MediaQueueDeallocator<T>()),
--- a/dom/media/gtest/TestAudioCompactor.cpp
+++ b/dom/media/gtest/TestAudioCompactor.cpp
@@ -12,20 +12,20 @@ using mozilla::AudioData;
using mozilla::AudioDataValue;
using mozilla::MediaQueue;
class MemoryFunctor : public nsDequeFunctor {
public:
MemoryFunctor() : mSize(0) {}
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf);
- void* operator()(void* aObject) override {
+ void operator()(void* aObject) override
+ {
const AudioData* audioData = static_cast<const AudioData*>(aObject);
mSize += audioData->SizeOfIncludingThis(MallocSizeOf);
- return nullptr;
}
size_t mSize;
};
class TestCopy
{
public:
--- a/dom/media/mediasource/ResourceQueue.cpp
+++ b/dom/media/mediasource/ResourceQueue.cpp
@@ -32,19 +32,19 @@ ResourceItem::SizeOfIncludingThis(Malloc
// size excluding this
size += mData->ShallowSizeOfExcludingThis(aMallocSizeOf);
return size;
}
class ResourceQueueDeallocator : public nsDequeFunctor {
- void* operator() (void* aObject) override {
+ void operator()(void* aObject) override
+ {
delete static_cast<ResourceItem*>(aObject);
- return nullptr;
}
};
ResourceQueue::ResourceQueue()
: nsDeque(new ResourceQueueDeallocator())
, mLogicalLength(0)
, mOffset(0)
{
--- a/dom/media/ogg/OggCodecState.h
+++ b/dom/media/ogg/OggCodecState.h
@@ -43,20 +43,19 @@ struct OggPacketDeletePolicy
}
};
using OggPacketPtr = UniquePtr<ogg_packet, OggPacketDeletePolicy>;
// Deallocates a packet, used in OggPacketQueue below.
class OggPacketDeallocator : public nsDequeFunctor
{
- virtual void* operator()(void* aPacket)
+ virtual void operator()(void* aPacket)
{
OggPacketDeletePolicy()(static_cast<ogg_packet*>(aPacket));
- return nullptr;
}
};
// A queue of ogg_packets. When we read a page, we extract the page's packets
// and buffer them in the owning stream's OggCodecState. This is because
// if we're skipping up to the next keyframe in very large frame sized videos,
// there may be several megabytes of data between keyframes, and the
// ogg_stream_state would end up resizing its buffer every time we added a
--- a/editor/txmgr/nsTransactionStack.cpp
+++ b/editor/txmgr/nsTransactionStack.cpp
@@ -6,19 +6,19 @@
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsISupportsUtils.h"
#include "nsTransactionItem.h"
#include "nsTransactionStack.h"
#include "nscore.h"
class nsTransactionStackDeallocator : public nsDequeFunctor {
- virtual void* operator() (void* aObject) {
+ virtual void operator()(void* aObject)
+ {
RefPtr<nsTransactionItem> releaseMe = dont_AddRef(static_cast<nsTransactionItem*>(aObject));
- return nullptr;
}
};
nsTransactionStack::nsTransactionStack(Type aType)
: nsDeque(new nsTransactionStackDeallocator())
, mType(aType)
{
}
--- a/netwerk/streamconv/nsStreamConverterService.cpp
+++ b/netwerk/streamconv/nsStreamConverterService.cpp
@@ -174,20 +174,19 @@ nsStreamConverterService::ParseFromTo(co
typedef nsClassHashtable<nsCStringHashKey, BFSTableData> BFSHashTable;
// nsObjectHashtable enumerator functions.
class CStreamConvDeallocator : public nsDequeFunctor {
public:
- void* operator()(void* anObject) override {
+ void operator()(void* anObject) override {
nsCString *string = (nsCString*)anObject;
delete string;
- return nullptr;
}
};
// walks the graph using a breadth-first-search algorithm which generates a discovered
// verticies tree. This tree is then walked up (from destination vertex, to origin vertex)
// and each link in the chain is added to an nsStringArray. A direct lookup for the given
// CONTRACTID should be made prior to calling this method in an attempt to find a direct
// converter rather than walking the graph.
--- a/xpcom/ds/nsDeque.h
+++ b/xpcom/ds/nsDeque.h
@@ -34,17 +34,17 @@
/**
* The nsDequeFunctor class is used when you want to create
* callbacks between the deque and your generic code.
* Use these objects in a call to ForEach(), and as custom deallocators.
*/
class nsDequeFunctor
{
public:
- virtual void* operator()(void* aObject) = 0;
+ virtual void operator()(void* aObject) = 0;
virtual ~nsDequeFunctor() {}
};
/******************************************************
* Here comes the nsDeque class itself...
******************************************************/
/**
--- a/xpcom/tests/gtest/TestNsDeque.cpp
+++ b/xpcom/tests/gtest/TestNsDeque.cpp
@@ -16,55 +16,49 @@ using mozilla::DeclVal;
/**************************************************************
Now define the token deallocator class...
**************************************************************/
namespace TestNsDeque {
class _Dealloc: public nsDequeFunctor
{
- virtual void* operator()(void* aObject) {
- return 0;
- }
+ virtual void operator()(void* aObject) {}
};
static bool VerifyContents(const nsDeque& aDeque, const int* aContents, size_t aLength)
{
for (size_t i=0; i<aLength; ++i) {
if (*(int*)aDeque.ObjectAt(i) != aContents[i]) {
return false;
}
}
return true;
}
class Deallocator: public nsDequeFunctor
{
- virtual void* operator()(void* aObject)
+ virtual void operator()(void* aObject)
{
if (aObject)
{
// Set value to -1, to use in test function.
*((int*)aObject) = -1;
}
-
- return nullptr;
}
};
class ForEachAdder: public nsDequeFunctor
{
- virtual void* operator()(void* aObject)
+ virtual void operator()(void* aObject)
{
if (aObject)
{
sum += *(int*)aObject;
}
-
- return aObject;
}
private:
int sum = 0;
public:
int GetSum() { return sum; }