Bug 1371925 - Remove unnecessary hashtable lookups in DOMIntersectionObserver. r=froydnj

MozReview-Commit-ID: LUt03nCz3SD
This commit is contained in:
Mats Palmgren 2017-06-17 00:06:04 +02:00
Родитель a8cf987309
Коммит 4264d9480f
1 изменённых файлов: 9 добавлений и 13 удалений

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

@ -150,12 +150,11 @@ DOMIntersectionObserver::GetThresholds(nsTArray<double>& aRetVal)
void
DOMIntersectionObserver::Observe(Element& aTarget)
{
if (mObservationTargets.Contains(&aTarget)) {
return;
if (mObservationTargets.EnsureInserted(&aTarget)) {
// A new entry was created.
aTarget.RegisterIntersectionObserver(this);
Connect();
}
aTarget.RegisterIntersectionObserver(this);
mObservationTargets.PutEntry(&aTarget);
Connect();
}
void
@ -173,14 +172,11 @@ DOMIntersectionObserver::Unobserve(Element& aTarget)
void
DOMIntersectionObserver::UnlinkTarget(Element& aTarget)
{
if (!mObservationTargets.Contains(&aTarget)) {
return;
}
mObservationTargets.RemoveEntry(&aTarget);
if (mObservationTargets.Count() == 0) {
Disconnect();
}
if (mObservationTargets.EnsureRemoved(&aTarget) &&
mObservationTargets.Count() == 0) {
// We removed the last entry.
Disconnect();
}
}
void