Open Bug 1006208 Opened 7 years ago Updated 7 years ago

nsTHashtable::SizeOfEntryExcludingThisFun should use a reference instead of a pointer


(Core :: XPCOM, defect)

Not set




(Reporter: erahm, Unassigned)



In there was a consensus that switching |nsTHashtable::SizeOfEntryExcludingThisFun| over to taking a reference the the hash table entry rather than a pointer would be helpful in that:
1) It would help avoid accidentally doing |entry->SizeOfIncludingThis|
2) It would make it easier for us to find instances of 
   |blah->SizeOfExcludingThis| that should be |blah->SizeOfIncludingThis|

It would be nice to do this for |PLDHashSizeOfEntryExcludingThisFun| as well, but that's less feasible as that is passing a generic pointer around that is eventually cast to the actual type. As an improvement we could modify existing instances[1] of |PLDHashSizeOfEntryExcludingThisFun| to cast to a ref rather than a pointer.

My proposal is as follows:
* Modify |nsTHashtable::SizeOfEntryExcludingThisFun| to take |EntryType&| instead of |EntryType*|
* Update all instances of |nsTHashtable::SizeOfEntryExcludingThisFun| to use the new parameter type [2]
* Update all existing |PLDHashSizeOfEntryExcludingThisFun| instances to cast to a reference instead of a pointer, ie |Type& type = *static_cast<Type*>(entry);|

Whiteboard: [MemShrink]
Whiteboard: [MemShrink]
You need to log in before you can comment on or make changes to this bug.