Skip to content

[perf]: a couple more micro optimizations #334

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

Merged
merged 1 commit into from
Apr 7, 2025
Merged

Conversation

jamieQ
Copy link
Contributor

@jamieQ jamieQ commented Apr 4, 2025

small changes to:

  1. avoid an unnecessary buffer copy during render() when updating event pipes
  2. allow our 'session' id generation to wrap so it doesn't need to perform bounds checks (it functionally cannot overflow so they are unneeded)


/// Set all event pipes to `pending`.
eventPipes.forEach { $0.setPending() }
for eventPipe in eventPipes {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really a functional change here, but we use for-in everywhere else in this method so we might as well be consistent

previousSinks = context.sinkStore.usedSinks

/// Capture all the pipes to be enabled after render completes.
eventPipes = context.eventPipes
eventPipes.append(contentsOf: context.sinkStore.eventPipes)
for (_, sink) in context.sinkStore.usedSinks {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously this was going through a call to map which created an intermediate buffer of the mapped elements. we don't need them to be stored separately so we can just do the iteration inline to avoid that

@jamieQ jamieQ marked this pull request as ready for review April 4, 2025 16:35
@jamieQ jamieQ requested a review from a team as a code owner April 4, 2025 16:35
@jamieQ jamieQ merged commit e875533 into main Apr 7, 2025
7 checks passed
@jamieQ jamieQ deleted the jquadri/cow-stuff branch April 7, 2025 16:16
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.

2 participants