Everywhere: Use Optional<T>::ensure() where useful

No functional changes.
This commit is contained in:
Jelle Raaijmakers 2025-09-17 15:48:22 +02:00 committed by Tim Flynn
commit c31eff6a47
Notes: github-actions[bot] 2025-09-17 16:02:17 +00:00
14 changed files with 53 additions and 87 deletions

View file

@ -21,15 +21,14 @@ bool ListOfAvailableImages::Key::operator==(Key const& other) const
u32 ListOfAvailableImages::Key::hash() const
{
if (!cached_hash.has_value()) {
return cached_hash.ensure([&] {
u32 url_hash = url.hash();
u32 mode_hash = static_cast<u32>(mode);
u32 origin_hash = 0;
if (origin.has_value())
origin_hash = Traits<URL::Origin>::hash(origin.value());
cached_hash = pair_int_hash(url_hash, pair_int_hash(mode_hash, origin_hash));
}
return cached_hash.value();
return pair_int_hash(url_hash, pair_int_hash(mode_hash, origin_hash));
});
}
void ListOfAvailableImages::visit_edges(JS::Cell::Visitor& visitor)