Repository: LadybirdBrowser/ladybird
File: Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp (C++)

Code before:

    // 6. Let position be cursor’s position.
    auto position = cursor->position();

    // 7. Let object store position be cursor’s object store position.
    auto object_store_position = cursor->object_store_position();

    // 8. If count is not given, let count be 1.
    // NOTE: This is handled by the default parameter

    auto next_requirements = [&](Variant<ObjectStoreRecord, IndexRecord> const& record) -> bool {
        bool satisfies = true;
        auto retain_satisfaction = [&](bool condition) -> bool {
            if (satisfies)
                satisfies = condition;

            return satisfies;
        };

        // * If key is defined:
        if (key) {
            // * The record’s key is greater than or equal to key.
            auto is_greater_than_or_equal = record.visit(
                [](Empty) { VERIFY_NOT_REACHED(); },
                [key](auto const& inner_record) {
                    return Key::greater_than_or_equal(inner_record.key, *key);
                });

            retain_satisfaction(is_greater_than_or_equal);
        }

        // * If primaryKey is defined:
        if (primary_key) {
            auto const& inner_record = record.get<IndexRecord>();

            // * If the record’s key is equal to key:
            if (Key::equals(inner_record.key, *key)) {
                // * The record’s value is greater than or equal to primaryKey
                retain_satisfaction(Key::greater_than_or_equal(inner_record.value, *primary_key));
            }
            // * Else:
            else {
                // * The record’s key is greater than key.
                retain_satisfaction(Key::greater_than(inner_record.key, *key));
            }
        }

        // * If position is defined and source is an object store:
        if (position && source.has<GC::Ref<ObjectStore>>()) {
            auto const& inner_record = record.get<ObjectStoreRecord>();


Review comment (suggestion):
Not sure about the `retain_satisfaction` I find this harder to read and the code doesn't short circuit there anymore 

Seems like you could just keep the old style with the changes? 

```c++
if (Key::equals(inner_record.key, *key)) {
    if (!(Key::greater_than(inner_record.value, *primary_key) || Key::equals(inner_record.value, *primary_key)))
        return false;
} else {
    if (!Key::greater_than(inner_record.key, *key))
        return false;
}
``` 

Code after:

    // 6. Let position be cursor’s position.
    auto position = cursor->position();

    // 7. Let object store position be cursor’s object store position.
    auto object_store_position = cursor->object_store_position();

    // 8. If count is not given, let count be 1.
    // NOTE: This is handled by the default parameter

    auto next_requirements = [&](Variant<ObjectStoreRecord, IndexRecord> const& record) -> bool {
        // * If key is defined:
        if (key) {
            // * The record’s key is greater than or equal to key.
            if (!record.visit([&](auto const& inner_record) {
                    return Key::greater_than_or_equal(inner_record.key, *key);
                }))
                return false;
        }

        // * If primaryKey is defined:
        if (primary_key) {
            auto const& inner_record = record.get<IndexRecord>();

            // * If the record’s key is equal to key:
            if (Key::equals(inner_record.key, *key)) {
                // * The record’s value is greater than or equal to primaryKey
                if (!Key::greater_than_or_equal(inner_record.value, *primary_key))
                    return false;
            }
            // * Else:
            else {
                // * The record’s key is greater than key.
                if (!Key::greater_than(inner_record.key, *key))
                    return false;
            }
        }

        // * If position is defined and source is an object store:
        if (position && source.has<GC::Ref<ObjectStore>>()) {
            auto const& inner_record = record.get<ObjectStoreRecord>();

            // * The record’s key is greater than position.
            if (!Key::greater_than(inner_record.key, *position))
                return false;
        }

        // * If position is defined and source is an index:
        if (position && source.has<GC::Ref<Index>>()) {
            auto const& inner_record = record.get<IndexRecord>();