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

Get rid of unneeded static properties #112

Open
yo1995 opened this issue Jan 12, 2023 · 1 comment
Open

Get rid of unneeded static properties #112

yo1995 opened this issue Jan 12, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@yo1995
Copy link
Collaborator

yo1995 commented Jan 12, 2023

In 200.0.0-beta, because we used the StateObject-for-map pattern, many view properties are created as type property, or gets their default value from a static method. This is not a memory efficient approach as many static properties will stay in the memory longer than desired.

Instead, we can move the static methods into the traditional initialization process, and make the properties instance properties instead of type properties. Most often seen with graphics and graphics overlays.

See "Using Computed Variable" in the contribution guideline for more details.

@yo1995 yo1995 added the enhancement New feature or request label Jan 12, 2023
@yo1995
Copy link
Collaborator Author

yo1995 commented May 25, 2023

#182 (comment)

I would argue that static methods are sometimes essential to declutter the initializer. Compared to static properties, they shouldn't be a huge problem as the memory footprint can be pretty small, just a pointer to a method vs the static properties object size.

While we are examining all static and class keywords for type methods/properties, most of the time we only need to fix the properties in question.

Criteria

  • More than 256 bytes
  • can be converted to computed property or static factory method

@yo1995 yo1995 changed the title Get rid of unneeded static methods/properties Get rid of unneeded static properties May 25, 2023
@yo1995 yo1995 moved this from To Do to On Deck in SwiftUI Sample Viewer prototyping Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant