mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +02:00
LibWeb/IDB: Implement storing of index records
This commit is contained in:
committed by
Jelle Raaijmakers
parent
c73b8d1fa0
commit
46ecf239c4
Notes:
github-actions[bot]
2025-05-14 15:18:57 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/46ecf239c4e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4727 Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/shannonbooth
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/QuickSort.h>
|
||||
#include <LibWeb/IndexedDB/Internal/Index.h>
|
||||
#include <LibWeb/IndexedDB/Internal/ObjectStore.h>
|
||||
|
||||
@@ -107,4 +108,18 @@ u64 Index::count_records_in_range(GC::Ref<IDBKeyRange> range)
|
||||
return count;
|
||||
}
|
||||
|
||||
void Index::store_a_record(IndexRecord const& record)
|
||||
{
|
||||
m_records.append(record);
|
||||
|
||||
// NOTE: The record is stored in index’s list of records such that the list is sorted primarily on the records keys, and secondarily on the records values, in ascending order.
|
||||
AK::quick_sort(m_records, [](auto const& a, auto const& b) {
|
||||
auto key_comparison = Key::compare_two_keys(a.key, b.key);
|
||||
if (key_comparison != 0)
|
||||
return key_comparison < 0;
|
||||
|
||||
return Key::compare_two_keys(a.value, b.value) < 0;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user