RemoveAllSnapshots has O(n²) duplicate detection for snapshot IDs #12

Open
opened 2026-02-08 17:16:25 +01:00 by clawbot · 0 comments
Collaborator

In snapshot.go RemoveAllSnapshots(), duplicate snapshot IDs are detected with a linear scan:

found := false
for _, id := range snapshotIDs {
    if id == sid {
        found = true
        break
    }
}

This is O(n²) overall. Should use a map[string]bool for O(1) lookups. Same pattern exists in PruneBlobs().

Ref: parent issue #1

In `snapshot.go` `RemoveAllSnapshots()`, duplicate snapshot IDs are detected with a linear scan: ```go found := false for _, id := range snapshotIDs { if id == sid { found = true break } } ``` This is O(n²) overall. Should use a `map[string]bool` for O(1) lookups. Same pattern exists in `PruneBlobs()`. Ref: parent issue #1
clawbot self-assigned this 2026-02-20 09:29:07 +01:00
clawbot added the needs-review label 2026-02-20 09:29:08 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/vaultik#12