╭ changed ────────────╮ │src/ui/Home/Users.zig│ ╰─────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │30 │ │31 // the users ordered by creation time (oldest first); absent until the first │ │32 // user exists. keyed by [timestamp][event-id], value = event-id. │ │33 - const timestamp_to_user_id_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "timestamp->user-id")) orelse │ │33 + const created_ts_to_user_id_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "created-ts->user-id")) orelse│ │34 return .{ .users = &.{}, .after = after, .next_after = null }; │ │35 - const timestamp_to_user_id = try DB.SortedMap(.read_only).init(timestamp_to_user_id_cursor); │ │36 - const count = try timestamp_to_user_id.count(); │ │35 + const created_ts_to_user_id = try DB.SortedMap(.read_only).init(created_ts_to_user_id_cursor); │ │36 + const count = try created_ts_to_user_id.count(); │ │37 │ │38 const event_id_to_user_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "event-id->user")) orelse │ │39 return .{ .users = &.{}, .after = after, .next_after = null }; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │40 const event_id_to_user = try DB.HashMap(.read_only).init(event_id_to_user_cursor); │ │41 │ │42 - // read the window [after, after+page_size) by index — a direct O(log n) seek │ │43 - // per entry, never scanning the whole table. deletes remove their entry (no │ │44 - // tombstones), so the window is dense. │ │42 + // read the window [after, after+page_size) with one seek to the start rank, │ │43 + // then a sequential walk │ │44 const end = @min(after + page_size, count); │ │45 + var iter = try created_ts_to_user_id.iteratorFromIndex(after); │ │46 var i = after; │ │47 while (i < end) : (i += 1) { │ │48 - const id_kv = try timestamp_to_user_id.getIndexKeyValuePair(@intCast(i)) orelse continue; │ │48 + var id_cursor = (try iter.next()) orelse break; │ │49 + const id_kv = try id_cursor.readKeyValuePair(); │ │50 var event_id: [evt.event_id_size]u8 = undefined; │ │51 _ = try id_kv.value_cursor.readBytes(&event_id); │ │52 const user_cursor = try event_id_to_user.getCursor(hash.hashInt(hash_kind, &event_id)) orelse continue;│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯