Skip to content
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

refactor!(core): make dimension an argument of sew/link methods #253

Merged
merged 7 commits into from
Dec 13, 2024

Conversation

imrn99
Copy link
Collaborator

@imrn99 imrn99 commented Dec 12, 2024

Description

Scope: core with lots of side effects

Type of change: refactor

Content description:

  • added new sew and link methods taking dimension as a const argument
  • old sew and links methods are now private

With assertions and match on a const generic, the indirection layer has no cost (with optimization enabled). Small example with compiler explorer:

https://godbolt.org/z/857KTob9T

Additional information

  • Breaking change

Change example

The new link is implemented as:

    pub fn link<const I: u8>(
        &self,
        trans: &mut Transaction,
        lhs_dart_id: DartIdType,
        rhs_dart_id: DartIdType,
    ) -> StmResult<()> {
        // these assertions + match on a const are optimized away
        assert!(I < 3);
        assert_ne!(I, 0);
        match I {
            1 => self.one_link(trans, lhs_dart_id, rhs_dart_id),
            2 => self.two_link(trans, lhs_dart_id, rhs_dart_id),
            _ => unreachable!(),
        }
    }

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 71.18156% with 100 lines in your changes missing coverage. Please review.

Project coverage is 77.13%. Comparing base (2b7e7fc) to head (5f6835d).

Files with missing lines Patch % Lines
honeycomb-core/src/cmap/dim2/sews/mod.rs 23.52% 52 Missing ⚠️
honeycomb-core/src/cmap/dim2/links/mod.rs 39.02% 25 Missing ⚠️
honeycomb-kernels/src/triangulation/fan.rs 50.00% 7 Missing ⚠️
honeycomb-core/src/cmap/dim2/links/one.rs 25.00% 6 Missing ⚠️
honeycomb-core/src/cmap/dim2/links/two.rs 25.00% 6 Missing ⚠️
honeycomb-core/src/cmap/dim2/sews/one.rs 80.00% 2 Missing ⚠️
honeycomb-core/src/cmap/dim2/sews/two.rs 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #253      +/-   ##
==========================================
- Coverage   77.98%   77.13%   -0.85%     
==========================================
  Files          47       49       +2     
  Lines        6676     6801     +125     
==========================================
+ Hits         5206     5246      +40     
- Misses       1470     1555      +85     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@imrn99 imrn99 marked this pull request as ready for review December 12, 2024 10:42
Copy link
Member

@cedricchevalier19 cedricchevalier19 left a comment

Choose a reason for hiding this comment

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

I like this syntax

@imrn99 imrn99 merged commit f40f105 into master Dec 13, 2024
13 checks passed
@imrn99 imrn99 deleted the merge-sews branch December 13, 2024 10:58
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