Skip to content

feature: improve performance if the element of the Value of *Model does not implement the AfterFindable interface. #799

@seedeed

Description

@seedeed

Description

I found that the afterFind method of *Model would create a log of goroutines via *errgroup.Group.Go(...) even if the element of the Value of *Model does not implement the AfterFindable interface, which might cause a lot of unneeded CPU cost. To avoid this, I think we could move the AfterFindable interface checking out of the Go function. If this's really a problem, I think I could submit a PR to fix it.

pop/callbacks.go

Lines 32 to 43 in 17f09c0

for i := 0; i < rv.Len(); i++ {
func(i int) {
wg.Go(func() error {
y := rv.Index(i)
y = y.Addr()
if x, ok := y.Interface().(AfterFindable); ok {
return x.AfterFind(c)
}
return nil
})
}(i)
}

Additional Information

No response

Metadata

Metadata

Assignees

Labels

s: acceptedThis proposal was accepted. Someone can start working on it.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions