Bug 1418156 - Don't zero newly added PrefHashEntrys. r=glandium
They are guaranteed to be zeroed already by PLDHashTable.
MozReview-Commit-ID: LBeGa9ABYc3
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -169,22 +169,16 @@ public:
{
}
explicit PrefTypeFlags(PrefType aType)
: mValue(AsInt(aType))
{
}
- PrefTypeFlags& Reset()
- {
- mValue = AsInt(PrefType::Invalid);
- return *this;
- }
-
bool IsTypeValid() const { return !IsPrefType(PrefType::Invalid); }
bool IsTypeString() const { return IsPrefType(PrefType::String); }
bool IsTypeInt() const { return IsPrefType(PrefType::Int); }
bool IsTypeBool() const { return IsPrefType(PrefType::Bool); }
bool IsPrefType(PrefType type) const { return GetPrefType() == type; }
void SetPrefType(PrefType aType)
{
@@ -761,23 +755,20 @@ pref_SetPref(const char* aKey,
return NS_ERROR_OUT_OF_MEMORY;
}
auto pref = static_cast<PrefHashEntry*>(gHashTable->Add(aKey, fallible));
if (!pref) {
return NS_ERROR_OUT_OF_MEMORY;
}
- // New entry, need to initialize.
if (!pref->mKey) {
- // Initialize the pref entry.
- pref->mPrefFlags.Reset().SetPrefType(aType);
+ // New (zeroed) entry. Initialize it.
+ pref->mPrefFlags.SetPrefType(aType);
pref->mKey = ArenaStrdup(aKey, gPrefNameArena);
- memset(&pref->mDefaultValue, 0, sizeof(pref->mDefaultValue));
- memset(&pref->mUserValue, 0, sizeof(pref->mUserValue));
} else if (pref->mPrefFlags.HasDefaultValue() &&
!pref->mPrefFlags.IsPrefType(aType)) {
NS_WARNING(
nsPrintfCString(
"Ignoring attempt to overwrite value of default pref %s (type %s) with "
"the wrong type (%s)!",
aKey,