Skip to content

Performance Refactors#37

Merged
Casperento merged 4 commits intomainfrom
refactorings
Sep 18, 2025
Merged

Performance Refactors#37
Casperento merged 4 commits intomainfrom
refactorings

Conversation

@Casperento
Copy link
Copy Markdown
Collaborator

Closes #34

This pull request refactors the PathExpr representation to improve performance, clarity, and maintainability. The core change replaces the std::variant and std::shared_ptr-based implementation with a simpler, custom pointer-based PathExpr class.

This new approach simplifies the data structure, reduces dynamic memory management overhead, and makes the path expression logic more explicit.

Major Changes

  • Refactored PathExpr to a Custom Class: Replaced the std::variant-based PathExpr with a single, pointer-based class. This new class uses an enum for type dispatching instead of std::visit, eliminating dynamic polymorphism and simplifying memory management. All related creation and manipulation methods (createEdgeExpr, mergePaths, etc.) have been updated.

    • (Files: include/PHIGateAnalyzer.h, lib/PHIGateAnalyzer.cpp)
  • Improved Performance and Determinism:

    • Optimization: Predicates are now computed only once per analyzed function, avoiding redundant work.
    • Determinism: Replaced the non-deterministic (random number-based) naming for outlined functions with a stable, sequential counter.

API Updates and Cleanup

  • API Changes: Updated the ProgramSlice constructor and outline method signatures to reflect the new PathExpr interface.
    • (File: include/ProgramSlice.h)
  • Code Simplification: Removed now-unnecessary helper structs and std::visit patterns. All traversal, collection, and printing logic has been consolidated into the new PathExpr class.
    • (Files: include/PHIGateAnalyzer.h, lib/PHIGateAnalyzer.cpp)

@Casperento Casperento self-assigned this Sep 18, 2025
@Casperento Casperento merged commit 77666d3 into main Sep 18, 2025
1 check passed
@Casperento Casperento deleted the refactorings branch September 18, 2025 18:27
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.

Refactor: Improve PHIGateAnalyzer performance

1 participant