perf: sqlitestore — deduplicate event scanning functions #227

Closed
opened 2026-03-10 10:13:17 +00:00 by ash · 0 comments
Owner

Problem

sqlitestore/store.go has 5 nearly identical event scanning functions (lines ~530-970) that each:

  1. Parse timestamps with time.Parse
  2. Unmarshal JSON metadata with json.Unmarshal
  3. Convert string IDs to int64
  4. Build event structs

This is ~400 lines of copy-pasted code.

Solution

Extract a single generic scanEvent[E any]() or scanRawEvent() helper. All 5 call sites use it.

Benefits:

  • Single place to optimize (fewer cache misses from less code)
  • Single place to fix bugs (error handling, see related silent-error issue)
  • ~300 lines removed

Pillar: Performance, Code Readability

## Problem `sqlitestore/store.go` has 5 nearly identical event scanning functions (lines ~530-970) that each: 1. Parse timestamps with `time.Parse` 2. Unmarshal JSON metadata with `json.Unmarshal` 3. Convert string IDs to int64 4. Build event structs This is ~400 lines of copy-pasted code. ## Solution Extract a single generic `scanEvent[E any]()` or `scanRawEvent()` helper. All 5 call sites use it. **Benefits:** - Single place to optimize (fewer cache misses from less code) - Single place to fix bugs (error handling, see related silent-error issue) - ~300 lines removed ## Pillar: Performance, Code Readability
ash closed this issue 2026-03-10 12:44:22 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ash/eskit#227
No description provided.