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

Experiment memory allocation #186

Merged
merged 4 commits into from
Dec 17, 2023
Merged

Experiment memory allocation #186

merged 4 commits into from
Dec 17, 2023

Conversation

adospace
Copy link
Owner

Add a new component declaration pattern that pools MauiReactor objects to reduce memory allocations, it could be useful in ReenderItem methods in collection views.

Instead of:

public override VisualNode Render()
  {
      return new ContentPage("Counter Sample")
      {
          new VStack(spacing: 10)
          {
              new Label($"Counter: {State.Counter}")
                  .VCenter()
                  .HCenter(),

              new Button("Click To Increment", () =>
                  SetState(s => s.Counter++))
          }
          .VCenter()
          .HCenter()
      };
  }

this:

public override VisualNode Render()
{
    return ContentPage(
    [
        VStack(
        [
            Label($"Counter: {State.Counter}")
                .VCenter()
                .HCenter(),

            Button("Click To Increment", () =>
                SetState(s => s.Counter++))
        ])
        .Spacing(10)
        .VCenter()
        .HCenter()
    ])
    .Title("Counter Sample");
}

@adospace adospace merged commit cfc204f into main Dec 17, 2023
1 check failed
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