Skip to content

Comments

Optimize updateTabsOrder with bulk database operations#256

Closed
Copilot wants to merge 2 commits into7-implement-draggable-retryfrom
copilot/sub-pr-252
Closed

Optimize updateTabsOrder with bulk database operations#256
Copilot wants to merge 2 commits into7-implement-draggable-retryfrom
copilot/sub-pr-252

Conversation

Copy link

Copilot AI commented Feb 9, 2026

Addresses performance feedback on #252 suggesting bulk operations for tab reordering.

Changes

Performance optimization:

  • Replaced per-tab get + put loop with single getAll + putAll operations
  • Reduced database operations from 2N to 2 (constant time vs linear)
  • Added early return for empty list edge case

Before:

for (int i = 0; i < tabIds.length; i++) {
  final tab = await db.tabs.get(tabIds[i]);
  if (tab != null) {
    await db.tabs.put(tab.copyWith(order: i));
  }
}

After:

final tabs = await db.tabs.getAll(tabIds);
final updatedTabs = tabs
    .asMap()
    .entries
    .where((e) => e.value != null)
    .map((e) => e.value!.copyWith(order: e.key))
    .toList();
await db.tabs.putAll(updatedTabs);

Expected 10-40x speedup for typical tab counts (10-100 items).


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Addressing feedback on draggable retry implementation Optimize updateTabsOrder with bulk database operations Feb 9, 2026
Copilot AI requested a review from ZanderCowboy February 9, 2026 00:17
@ZanderCowboy ZanderCowboy marked this pull request as ready for review February 9, 2026 00:21
@ZanderCowboy
Copy link
Owner

This change will be overwritten here. #257.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants