Bug 1850713: remove duplicated setting of early hint preloader id in `ScriptLoader...
[gecko.git] / dom / canvas / CacheInvalidator.cpp
blobc796cfce6be2676e7415b5ea83fb1db7af81d528
1 /* -*- Mode: C++; tab-width: 13; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=13 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "CacheInvalidator.h"
9 namespace mozilla {
11 void CacheInvalidator::InvalidateCaches() const {
12 // The only sane approach is to require caches to remove invalidators.
13 while (!mCaches.empty()) {
14 const auto& itr = mCaches.begin();
15 const auto pEntry = *itr;
16 pEntry->OnInvalidate();
17 MOZ_ASSERT(mCaches.find(pEntry) == mCaches.end());
21 // -
23 void AbstractCache::ResetInvalidators(InvalidatorListT&& newList) {
24 for (const auto& cur : mInvalidators) {
25 if (cur) {
26 (void)cur->mCaches.erase(this);
30 mInvalidators = std::move(newList);
32 for (const auto& cur : mInvalidators) {
33 // Don't assert that we insert, since there may be dupes in `invalidators`.
34 // (and it's not worth removing the dupes)
35 if (cur) {
36 (void)cur->mCaches.insert(this);
41 void AbstractCache::AddInvalidator(const CacheInvalidator& x) {
42 mInvalidators.push_back(&x);
43 x.mCaches.insert(this);
46 } // namespace mozilla