-
Notifications
You must be signed in to change notification settings - Fork 0
fix: stopCode lookup added #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -789,7 +789,10 @@ impl GTFSService { | |||||||||||||||||||||||
| .insert(stop.cluster.clone().unwrap(), cluster_stop_res); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| stop_data.stops.insert(stop_code.to_string(), stop_res); | ||||||||||||||||||||||||
| stop_data.stops.insert(stop_code.to_string(), stop_res.clone()); | ||||||||||||||||||||||||
| if stop.code != stop_code && !stop.code.is_empty() { | ||||||||||||||||||||||||
| stop_data.stops.insert(stop.code.clone(), stop_res); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| stop_data.stops.insert(stop.code.clone(), stop_res); | |
| match stop_data.stops.entry(stop.code.clone()) { | |
| std::collections::hash_map::Entry::Vacant(entry) => { | |
| entry.insert(stop_res); | |
| } | |
| std::collections::hash_map::Entry::Occupied(entry) => { | |
| if entry.get().id != stop_res.id { | |
| // Preserve the first alias mapping and skip conflicting stop.code collisions. | |
| } | |
| } | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stop_resis cloned unconditionally to insert understop_code, even when the alternatestop.codekey is not inserted. This adds extra allocations per stop (potentially significant for large feeds). Consider insertingstop_resby move for the common case and only cloning when the alternate key is actually needed (e.g., branch on the condition and choose which insert gets the moved value).