Skip to content

Conversation

@2dubu
Copy link
Contributor

@2dubu 2dubu commented Jul 18, 2025

Description

This change optimizes the EquatableMacro.expansion function by refactoring the stored property extraction logic to a single-pass AST traversal with early exit conditions. It also removes an unnecessary isStoredProperty check that duplicated an existing condition.

These changes improve code clarity and offer minor compile-time performance improvements when expanding macros, without altering runtime behavior or output.

  1. Refactored property extraction loop for single-pass AST traversal
    (remove SwiftLint disable for cyclomatic_complexity)
  2. Removed redundant isStoredProperty check
  3. No functional behavior change; focused on performance and code clarity

How Has This Been Tested?

  • Existing unit tests have been relied upon to validate that macro behavior remains unchanged
  • Manually inspected that generated Equatable and Hashable conformances continue to match expectations
  • Confirmed that diagnostics for unsupported closures are still emitted correctly

Minimal checklist:

  • I have performed a self-review of my own code
  • I have added DocC code-level documentation for any public interfaces exported by the package
  • I have added unit and/or integration tests that prove my fix is effective or that my feature works

2dubu and others added 2 commits July 18, 2025 11:44
- Refactored property extraction loop for single-pass AST traversal
- Removed redundant isStoredProperty check
- No functional behavior change; focused on performance and code clarity
@codecov
Copy link

codecov bot commented Jul 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.97%. Comparing base (c279c4b) to head (fd358c5).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
+ Coverage   95.76%   96.97%   +1.21%     
==========================================
  Files           8       11       +3     
  Lines        1013     1122     +109     
==========================================
+ Hits          970     1088     +118     
+ Misses         43       34       -9     
Files with missing lines Coverage Δ
Sources/EquatableMacros/EquatableMacro.swift 97.14% <100.00%> (+4.55%) ⬆️
Files with missing lines Coverage Δ
Sources/EquatableMacros/EquatableMacro.swift 97.14% <100.00%> (+4.55%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9d85b0...fd358c5. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hassila hassila requested a review from Copilot July 19, 2025 21:51
Copy link

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 optimizes the AST traversal logic in EquatableMacro.expansion by refactoring the stored property extraction from a functional compactMap approach to an imperative loop with early exits. The changes aim to improve compile-time performance and code clarity while maintaining identical runtime behavior.

  • Replaced compactMap with a for-loop and continue statements for early exits
  • Consolidated closure detection logic into a single boolean expression
  • Removed redundant isStoredProperty check that duplicated existing conditions
Comments suppressed due to low confidence (1)

Sources/EquatableMacros/EquatableMacro.swift:140

  • [nitpick] The function name isClosure should be isClosure(type:) to match Swift naming conventions for functions that take parameters.
            let isClosureProperty = (binding.typeAnnotation?.type).map(isClosure) == true ||

@2dubu
Copy link
Contributor Author

2dubu commented Jul 21, 2025

Sorry for the repeated lint failures. I’ll make sure to run lint locally next time 🥲

Copy link
Collaborator

@supersonicbyte supersonicbyte left a comment

Choose a reason for hiding this comment

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

awesome, thanks!

@supersonicbyte supersonicbyte merged commit 31e351e into ordo-one:main Jul 22, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants