Remove dead code from C++ engine and bindings (-254 lines)#308
Merged
Conversation
Remove C++ functions and Python bindings that are never called through the public API or internal wrapper paths: traffi.cpp (-127 lines): - Vehicle::log_state_str() - wrapper converts states in Python - Vehicle::log_link_names() - wrapper converts link IDs in Python - Vehicle::build_log_t_link() - wrapper uses build_full_log_np instead - World::get_vehicle(name) - wrapper uses get_vehicle_by_index - World::get_link_by_id(id) - wrapper uses get_link(name) - World::get_vehicles_by_state(state) - never called from wrapper - World::get_vehicle_states_by_index() - never called from wrapper bindings.cpp (-107 lines): - build_full_log string version (build_full_log_np is used instead) - get_log_state_strings lambda (wrapper does conversion in Python) - get_log_t_link_data lambda (wrapper does conversion in Python) - Node generation_queue property (not exposed through wrapper) - Link vehicles list property (wrapper uses its own deque) traffi.h (-20 lines): - Declarations for removed functions All 185 C++ mode tests pass without modification. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes C++ engine helper methods and nanobind bindings that are not used by UXsim’s Python wrapper paths, reducing the C++ surface area and maintenance burden in the cpp=True backend.
Changes:
- Removed unused
Vehiclelog string/label helpers andWorldlookup/filter helpers from the C++ engine. - Removed unused nanobind-exposed methods/properties (e.g., legacy per-vehicle string log builders,
Node.generation_queue,Link.vehicles, and severalWorldquery helpers). - Kept the wrapper-preferred fast-path APIs (notably
build_full_log_np, batched log building, and index-based lookups).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
uxsim/trafficpp/traffi.h |
Removes declarations for unused helper methods so headers match the trimmed implementation/bindings. |
uxsim/trafficpp/traffi.cpp |
Deletes implementations of dead helper functions (string conversions, name/id lookup helpers, state filtering helpers). |
uxsim/trafficpp/bindings.cpp |
Drops nanobind exports for the removed helpers/properties to keep the Python extension API aligned with the wrapper’s actual usage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove 254 lines of C++ functions and Python bindings that are never called through the public API or internal wrapper paths.
Removed functions
traffi.cpp (-127 lines):
Vehicle::log_state_str()Vehicle::log_link_names()Vehicle::build_log_t_link()build_full_log_npinsteadWorld::get_vehicle(name)get_vehicle_by_indexWorld::get_link_by_id(id)get_link(name)World::get_vehicles_by_state()World::get_vehicle_states_by_index()bindings.cpp (-107 lines):
build_full_log(string version)build_full_log_npis used insteadget_log_state_stringsget_log_t_link_datageneration_queuepropertyvehicleslist propertytraffi.h (-20 lines): Corresponding declarations.
Verification method
Each function was confirmed dead by:
Test plan
--reruns 5)Part of #297
🤖 Generated with Claude Code