Skip to content

Replace slice-based aircraft tracking with map[string]bool#14

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/simplify-tracking-logic
Draft

Replace slice-based aircraft tracking with map[string]bool#14
Copilot wants to merge 1 commit intomainfrom
copilot/simplify-tracking-logic

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 14, 2026

The spotted-aircraft state was managed as a []Aircraft slice, requiring four helper functions (containsAircraft, newlySpotted, updateSpottedAircraft, validateAircraft) and awkward pointer-to-slice threading across the call stack to implement what is fundamentally a set membership check.

Changes

  • geebee.go: Removed the four slice-management helpers. HandleAircraft now accepts a map[string]bool (keyed by ICAO) and inlines the logic — O(1) lookup/insert for new sightings, a single range+delete pass to evict aircraft that left range.
  • main.go: Replaced *[]geebee.Aircraft with map[string]bool{} — no pointer indirection needed since maps are reference types.
// Before: 4 functions + *[]Aircraft threading
func HandleAircraft(alreadySpottedAircraft *[]Aircraft) ([]AircraftOutput, error)

// After: map passed directly, logic inlined
func HandleAircraft(spotted map[string]bool) ([]AircraftOutput, error)

Net: −48 lines, +21 lines, identical behaviour.

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