Skip to content

Share SubClauses across many Subs #112

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hasezoey
Copy link
Contributor

ISSUE NUMBER - PULL_REQUEST_TITLE

None

Description

I had noticed that for popups (and likely some other cases) it is quite common to have something along the lines of no_popups_mounted_clause for a bunch of global events, but each will need their own memory allocation, even though their content is the same. (Real example code)
This PR allows to share SubClauses by putting them in a Arc (as subs are never modified, only dropped) to lessen memory usage.
This still allows the old way of passing in SubClauses to Sub::new directly, so this is not a breaking change.
(it is also not a breaking change due to SubClause's fields not being public).

I know this will likely not have much memory or speed, but it is still some and it is a easy change.

Additionally also derive Clone on SubClause as it is possible due to all involved types supporting it.

Alternative

As a alternative, it could also be possible to modify Sub / Subscription to have a Vec of EventClause, though that would require a bit more code changes than this PR.

Type of change

Please select relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the contribution guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I formatted the code with cargo fmt
  • I checked my code using cargo clippy and reports no warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have introduced no new C-bindings
  • The changes I've made are Windows, MacOS, UNIX, Linux compatible (or I've handled them using cfg target_os)
  • I increased or maintained the code coverage for the project, compared to the previous commit

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.

1 participant