mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1475461
- part 2: Make callers of PLDHashTable::Search() const methods if possible r=Ehsan
Some callers of PLDHashTable::Search() use const_cast, some others are not const methods due to non-const PLDHashTable::Search(). This patch removes const_cast from the former and mark some methods of the latter const. MozReview-Commit-ID: C8ayoi7mXc1 --HG-- extra : rebase_source : 2cba0339756e3278ba6e5f0e8a11e68217a61d34
This commit is contained in:
parent
78077d5b3c
commit
5c3723acb2
@ -295,8 +295,7 @@ nsCommandParams::RemoveValue(const char* aName)
|
||||
nsCommandParams::HashEntry*
|
||||
nsCommandParams::GetNamedEntry(const char* aName) const
|
||||
{
|
||||
return static_cast<HashEntry*>(
|
||||
const_cast<PLDHashTable&>(mValuesHash).Search((void*)aName));
|
||||
return static_cast<HashEntry*>(mValuesHash.Search((void*)aName));
|
||||
}
|
||||
|
||||
nsCommandParams::HashEntry*
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
|
||||
static Native2WrappedNativeMap* newMap(int length);
|
||||
|
||||
inline XPCWrappedNative* Find(nsISupports* Obj)
|
||||
inline XPCWrappedNative* Find(nsISupports* Obj) const
|
||||
{
|
||||
MOZ_ASSERT(Obj,"bad param");
|
||||
auto entry = static_cast<Entry*>(mTable.Search(Obj));
|
||||
@ -178,7 +178,7 @@ public:
|
||||
|
||||
static IID2WrappedJSClassMap* newMap(int length);
|
||||
|
||||
inline nsXPCWrappedJSClass* Find(REFNSIID iid)
|
||||
inline nsXPCWrappedJSClass* Find(REFNSIID iid) const
|
||||
{
|
||||
auto entry = static_cast<Entry*>(mTable.Search(&iid));
|
||||
return entry ? entry->value : nullptr;
|
||||
@ -232,7 +232,7 @@ public:
|
||||
|
||||
static IID2NativeInterfaceMap* newMap(int length);
|
||||
|
||||
inline XPCNativeInterface* Find(REFNSIID iid)
|
||||
inline XPCNativeInterface* Find(REFNSIID iid) const
|
||||
{
|
||||
auto entry = static_cast<Entry*>(mTable.Search(&iid));
|
||||
return entry ? entry->value : nullptr;
|
||||
@ -290,7 +290,7 @@ public:
|
||||
|
||||
static ClassInfo2NativeSetMap* newMap(int length);
|
||||
|
||||
inline XPCNativeSet* Find(nsIClassInfo* info)
|
||||
inline XPCNativeSet* Find(nsIClassInfo* info) const
|
||||
{
|
||||
auto entry = static_cast<Entry*>(mTable.Search(info));
|
||||
return entry ? entry->value : nullptr;
|
||||
@ -343,7 +343,7 @@ public:
|
||||
|
||||
static ClassInfo2WrappedNativeProtoMap* newMap(int length);
|
||||
|
||||
inline XPCWrappedNativeProto* Find(nsIClassInfo* info)
|
||||
inline XPCWrappedNativeProto* Find(nsIClassInfo* info) const
|
||||
{
|
||||
auto entry = static_cast<Entry*>(mTable.Search(info));
|
||||
return entry ? entry->value : nullptr;
|
||||
@ -401,7 +401,7 @@ public:
|
||||
|
||||
static NativeSetMap* newMap(int length);
|
||||
|
||||
inline XPCNativeSet* Find(XPCNativeSetKey* key)
|
||||
inline XPCNativeSet* Find(XPCNativeSetKey* key) const
|
||||
{
|
||||
auto entry = static_cast<Entry*>(mTable.Search(key));
|
||||
return entry ? entry->key_value : nullptr;
|
||||
|
2
netwerk/cache/nsCacheEntry.cpp
vendored
2
netwerk/cache/nsCacheEntry.cpp
vendored
@ -422,7 +422,7 @@ nsCacheEntryHashTable::Shutdown()
|
||||
|
||||
|
||||
nsCacheEntry *
|
||||
nsCacheEntryHashTable::GetEntry( const nsCString * key)
|
||||
nsCacheEntryHashTable::GetEntry( const nsCString * key) const
|
||||
{
|
||||
NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
|
||||
if (!initialized) return nullptr;
|
||||
|
2
netwerk/cache/nsCacheEntry.h
vendored
2
netwerk/cache/nsCacheEntry.h
vendored
@ -270,7 +270,7 @@ public:
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
nsCacheEntry *GetEntry( const nsCString * key);
|
||||
nsCacheEntry *GetEntry( const nsCString * key) const;
|
||||
nsresult AddEntry( nsCacheEntry *entry);
|
||||
void RemoveEntry( nsCacheEntry *entry);
|
||||
|
||||
|
2
netwerk/cache/nsDiskCacheBinding.cpp
vendored
2
netwerk/cache/nsDiskCacheBinding.cpp
vendored
@ -192,7 +192,7 @@ nsDiskCacheBindery::CreateBinding(nsCacheEntry * entry,
|
||||
* FindActiveEntry : to find active colliding entry so we can doom it
|
||||
*/
|
||||
nsDiskCacheBinding *
|
||||
nsDiskCacheBindery::FindActiveBinding(uint32_t hashNumber)
|
||||
nsDiskCacheBindery::FindActiveBinding(uint32_t hashNumber) const
|
||||
{
|
||||
NS_ASSERTION(initialized, "nsDiskCacheBindery not initialized");
|
||||
// find hash entry for key
|
||||
|
2
netwerk/cache/nsDiskCacheBinding.h
vendored
2
netwerk/cache/nsDiskCacheBinding.h
vendored
@ -103,7 +103,7 @@ public:
|
||||
nsDiskCacheBinding * CreateBinding(nsCacheEntry * entry,
|
||||
nsDiskCacheRecord * record);
|
||||
|
||||
nsDiskCacheBinding * FindActiveBinding(uint32_t hashNumber);
|
||||
nsDiskCacheBinding * FindActiveBinding(uint32_t hashNumber) const;
|
||||
void RemoveBinding(nsDiskCacheBinding * binding);
|
||||
bool ActiveBindings();
|
||||
|
||||
|
@ -1396,7 +1396,8 @@ void nsDocLoader::RemoveRequestInfo(nsIRequest *aRequest)
|
||||
mRequestInfoHash.Remove(aRequest);
|
||||
}
|
||||
|
||||
nsDocLoader::nsRequestInfo* nsDocLoader::GetRequestInfo(nsIRequest* aRequest)
|
||||
nsDocLoader::nsRequestInfo*
|
||||
nsDocLoader::GetRequestInfo(nsIRequest* aRequest) const
|
||||
{
|
||||
return static_cast<nsRequestInfo*>(mRequestInfoHash.Search(aRequest));
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ private:
|
||||
|
||||
nsresult AddRequestInfo(nsIRequest* aRequest);
|
||||
void RemoveRequestInfo(nsIRequest* aRequest);
|
||||
nsRequestInfo *GetRequestInfo(nsIRequest* aRequest);
|
||||
nsRequestInfo *GetRequestInfo(nsIRequest* aRequest) const;
|
||||
void ClearRequestInfoHash();
|
||||
int64_t CalculateMaxProgress();
|
||||
/// void DumpChannelInfo(void);
|
||||
|
@ -956,7 +956,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
PtrToNodeEntry* FindNodeEntry(void* aPtr)
|
||||
PtrToNodeEntry* FindNodeEntry(void* aPtr) const
|
||||
{
|
||||
return static_cast<PtrToNodeEntry*>(mPtrToNodeMap.Search(aPtr));
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ class nsAtomSubTable
|
||||
void AddSizeOfExcludingThisLocked(MallocSizeOf aMallocSizeOf,
|
||||
AtomsSizes& aSizes);
|
||||
|
||||
AtomTableEntry* Search(AtomTableKey& aKey)
|
||||
AtomTableEntry* Search(AtomTableKey& aKey) const
|
||||
{
|
||||
mLock.AssertCurrentThreadOwns();
|
||||
return static_cast<AtomTableEntry*>(mTable.Search(&aKey));
|
||||
|
@ -163,7 +163,7 @@ nsStaticCaseInsensitiveNameTable::~nsStaticCaseInsensitiveNameTable()
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsStaticCaseInsensitiveNameTable::Lookup(const nsACString& aName)
|
||||
nsStaticCaseInsensitiveNameTable::Lookup(const nsACString& aName) const
|
||||
{
|
||||
NS_ASSERTION(mNameArray, "not inited");
|
||||
|
||||
@ -176,7 +176,7 @@ nsStaticCaseInsensitiveNameTable::Lookup(const nsACString& aName)
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName)
|
||||
nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName) const
|
||||
{
|
||||
NS_ASSERTION(mNameArray, "not inited");
|
||||
|
||||
|
@ -33,8 +33,8 @@ class nsStaticCaseInsensitiveNameTable
|
||||
public:
|
||||
enum { NOT_FOUND = -1 };
|
||||
|
||||
int32_t Lookup(const nsACString& aName);
|
||||
int32_t Lookup(const nsAString& aName);
|
||||
int32_t Lookup(const nsACString& aName) const;
|
||||
int32_t Lookup(const nsAString& aName) const;
|
||||
const nsCString& GetStringValue(int32_t aIndex);
|
||||
|
||||
nsStaticCaseInsensitiveNameTable(const char* const aNames[], int32_t aLength);
|
||||
|
@ -132,7 +132,7 @@ public:
|
||||
EntryType* GetEntry(KeyType aKey) const
|
||||
{
|
||||
return static_cast<EntryType*>(
|
||||
const_cast<PLDHashTable*>(&mTable)->Search(EntryType::KeyToPointer(aKey)));
|
||||
mTable.Search(EntryType::KeyToPointer(aKey)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user