Skip to content

Remove dead code from C++ engine and bindings (-254 lines)#308

Merged
toruseo merged 1 commit into
toruseo:mainfrom
toruseoagent:pr/dead-code-cleanup
Apr 3, 2026
Merged

Remove dead code from C++ engine and bindings (-254 lines)#308
toruseo merged 1 commit into
toruseo:mainfrom
toruseoagent:pr/dead-code-cleanup

Conversation

@toruseoagent
Copy link
Copy Markdown
Contributor

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):

Function Why dead
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() Never called from wrapper
World::get_vehicle_states_by_index() Never called from wrapper

bindings.cpp (-107 lines):

Binding Why dead
build_full_log (string version) build_full_log_np is used instead
get_log_state_strings Wrapper does conversion in Python
get_log_t_link_data 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): Corresponding declarations.

Verification method

Each function was confirmed dead by:

  1. grep across entire codebase (*.py, *.cpp, *.h) for all callers
  2. Tracing the wrapper's call chains to confirm no indirect usage
  3. All 185 existing C++ mode tests pass without modification

Test plan

  • All 185 C++ mode tests pass (--reruns 5)
  • All 8 test_cpp_build.py tests pass
  • No test changes required

Part of #297

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Vehicle log string/label helpers and World lookup/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 several World query 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.

@toruseo toruseo merged commit 336801d into toruseo:main Apr 3, 2026
17 checks passed
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.

3 participants