Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions Workflow/Sources/SubtreeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,19 @@ extension WorkflowNode {
childWorkflows = context.usedChildWorkflows
sideEffectLifetimes = context.usedSideEffectLifetimes

/// Captured the reusable sinks from this render pass.
/// Capture the reusable sinks from this render pass.
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

eventPipes.append(sink.eventPipe)
}

/// 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

eventPipe.setPending()
}

/// Return the rendered result
return rendering
Expand Down Expand Up @@ -288,12 +292,6 @@ extension WorkflowNode.SubtreeManager {

extension WorkflowNode.SubtreeManager {
fileprivate struct SinkStore {
var eventPipes: [EventPipe] {
usedSinks.values.map { reusableSink -> EventPipe in
reusableSink.eventPipe
}
}

private var previousSinks: [ObjectIdentifier: AnyReusableSink]
private(set) var usedSinks: [ObjectIdentifier: AnyReusableSink]

Expand Down
2 changes: 1 addition & 1 deletion Workflow/Sources/WorkflowObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public struct WorkflowSession {
private static var _nextRawID: UInt64 = 0
private static func _makeNextSessionID() -> UInt64 {
let nextID = _nextRawID
_nextRawID += 1
_nextRawID &+= 1
return nextID
}

Expand Down
Loading