Bug 820652 (part 2) - DMD: Embriefen the hash policy of LiveBlockGroup and DoubleReportBlockGroup. r=jlebar.

--HG--
extra : rebase_source : 41d1190f86cb2514c3b93717be6975d197226474
This commit is contained in:
Nicholas Nethercote 2012-12-11 19:46:53 -08:00
Родитель 56c4585ece
Коммит 74f12beb72
1 изменённых файлов: 12 добавлений и 37 удалений

Просмотреть файл

@ -685,23 +685,25 @@ public:
return isRep;
}
// Quasi-hash policy (used by LiveBlockGroup's hash policy).
// Hash policy.
//
// Hash() and Match() both assume that identical reporter names have
// hash() and match() both assume that identical reporter names have
// identical pointers. In practice this always happens because they are
// static strings (as specified in the NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN
// macro). This is true even for multi-reporters. (If it ever became
// untrue, the worst that would happen is that some blocks that should be in
// the same block group would end up in separate block groups.)
static uint32_t Hash(const LiveBlockKey& aKey)
typedef LiveBlockKey Lookup;
static uint32_t hash(const LiveBlockKey& aKey)
{
return mozilla::HashGeneric(aKey.mAllocStackTrace,
aKey.mReportStackTrace,
aKey.mReporterName);
}
static bool Match(const LiveBlockKey& aA, const LiveBlockKey& aB)
static bool match(const LiveBlockKey& aA, const LiveBlockKey& aB)
{
return aA.mAllocStackTrace == aB.mAllocStackTrace &&
aA.mReportStackTrace == aB.mReportStackTrace &&
@ -747,12 +749,14 @@ public:
mReporterName2 != gUnreportedName;
}
// Quasi-hash policy (used by DoubleReportBlockGroup's hash policy).
// Hash policy.
//
// Hash() and Match() both assume that identical reporter names have
// hash() and match() both assume that identical reporter names have
// identical pointers. See LiveBlockKey for more.
static uint32_t Hash(const DoubleReportBlockKey& aKey)
typedef DoubleReportBlockKey Lookup;
static uint32_t hash(const DoubleReportBlockKey& aKey)
{
return mozilla::HashGeneric(aKey.mAllocStackTrace,
aKey.mReportStackTrace1,
@ -761,7 +765,7 @@ public:
aKey.mReporterName2);
}
static bool Match(const DoubleReportBlockKey& aA,
static bool match(const DoubleReportBlockKey& aA,
const DoubleReportBlockKey& aB)
{
return aA.mAllocStackTrace == aB.mAllocStackTrace &&
@ -1096,20 +1100,6 @@ public:
return BlockSize::Cmp(a->mCombinedSize, b->mCombinedSize);
}
// Hash policy
typedef LiveBlockKey Lookup;
static uint32_t hash(const LiveBlockKey& aKey)
{
return LiveBlockKey::Hash(aKey);
}
static bool match(const LiveBlockGroup& aBg, const LiveBlockKey& aKey)
{
return LiveBlockKey::Match(aBg, aKey);
}
};
typedef js::HashSet<LiveBlockGroup, LiveBlockGroup, InfallibleAllocPolicy>
@ -1177,21 +1167,6 @@ public:
return BlockSize::Cmp(a->mCombinedSize, b->mCombinedSize);
}
// Hash policy
typedef DoubleReportBlockKey Lookup;
static uint32_t hash(const DoubleReportBlockKey& aKey)
{
return DoubleReportBlockKey::Hash(aKey);
}
static bool match(const DoubleReportBlockGroup& aBg,
const DoubleReportBlockKey& aKey)
{
return DoubleReportBlockKey::Match(aBg, aKey);
}
};
typedef js::HashSet<DoubleReportBlockGroup, DoubleReportBlockGroup,