Skip to content

Commit

Permalink
refactor: remove unnessary func wrap in for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Nov 25, 2023
1 parent 51c351a commit ea48223
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
7 changes: 2 additions & 5 deletions pkg/node/onetomany.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ func (n *OneToManyNode) forward(proc *process.Process) {
}
errStream := n.errPort.Open(proc)

for func() bool {
for {
inPck, ok := <-inStream.Receive()
if !ok {
return false
return
}

if outPcks, errPck := n.action(proc, inPck); errPck != nil {
Expand Down Expand Up @@ -175,9 +175,6 @@ func (n *OneToManyNode) forward(proc *process.Process) {
} else {
proc.Stack().Clear(inPck.ID())
}

return true
}() {
}
}

Expand Down
14 changes: 4 additions & 10 deletions pkg/node/onetoone.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ func (n *OneToOneNode) forward(proc *process.Process, inStream *port.Stream, out

errStream := n.errPort.Open(proc)

for func() bool {
for {
inPck, ok := <-inStream.Receive()
if !ok {
return false
return
}

if outPck, errPck := n.action(proc, inPck); errPck != nil {
Expand Down Expand Up @@ -165,9 +165,6 @@ func (n *OneToOneNode) forward(proc *process.Process, inStream *port.Stream, out
} else {
proc.Stack().Clear(inPck.ID())
}

return true
}() {
}
}

Expand All @@ -178,10 +175,10 @@ func (n *OneToOneNode) backward(proc *process.Process, outStream *port.Stream) {
var ioStream *port.Stream
var inStream *port.Stream

for func() bool {
for {
backPck, ok := <-outStream.Receive()
if !ok {
return false
return
}

if ioStream == nil {
Expand All @@ -196,8 +193,5 @@ func (n *OneToOneNode) backward(proc *process.Process, outStream *port.Stream) {
} else if _, ok := proc.Stack().Pop(backPck.ID(), inStream.ID()); ok {
inStream.Send(backPck)
}

return true
}() {
}
}

0 comments on commit ea48223

Please sign in to comment.