Skip to content

Commit

Permalink
Remove conditional error handling in profilers
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Hodges <[email protected]>
  • Loading branch information
hodgesds committed Oct 31, 2021
1 parent 278b807 commit 67e329d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
8 changes: 2 additions & 6 deletions cache_profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func (p *cacheProfiler) Profile(cacheProfile *CacheProfile) error {
cacheProfile.Reset()
p.profilersMu.RLock()
for profilerType, profiler := range p.profilers {
profileVal := profileValuePool.Get().(*ProfileValue)
profileVal := ProfileValuePool.Get().(*ProfileValue)
err2 := profiler.Profile(profileVal)
err = multierr.Append(err, err2)
if err2 == nil {
Expand Down Expand Up @@ -470,9 +470,5 @@ func (p *cacheProfiler) Profile(cacheProfile *CacheProfile) error {
}
}
p.profilersMu.RUnlock()
if len(multierr.Errors(err)) == len(p.profilers) {
return err
}

return nil
return err
}
8 changes: 2 additions & 6 deletions hardware_profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (p *hardwareProfiler) Profile(hwProfile *HardwareProfile) error {
hwProfile.Reset()
p.profilersMu.RLock()
for profilerType, profiler := range p.profilers {
profileVal := profileValuePool.Get().(*ProfileValue)
profileVal := ProfileValuePool.Get().(*ProfileValue)
err2 := profiler.Profile(profileVal)
err = multierr.Append(err, err2)
if err2 == nil {
Expand Down Expand Up @@ -238,10 +238,6 @@ func (p *hardwareProfiler) Profile(hwProfile *HardwareProfile) error {
}
}
}
if len(multierr.Errors(err)) == len(p.profilers) {
return err
}
p.profilersMu.RUnlock()

return nil
return err
}
6 changes: 1 addition & 5 deletions software_profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (p *softwareProfiler) Profile(swProfile *SoftwareProfile) error {
swProfile.Reset()
p.profilersMu.RLock()
for profilerType, profiler := range p.profilers {
profileVal := profileValuePool.Get().(*ProfileValue)
profileVal := ProfileValuePool.Get().(*ProfileValue)
err2 := profiler.Profile(profileVal)
err = multierr.Append(err, err2)
if err2 == nil {
Expand Down Expand Up @@ -217,9 +217,5 @@ func (p *softwareProfiler) Profile(swProfile *SoftwareProfile) error {
}
}
p.profilersMu.RUnlock()
if len(multierr.Errors(err)) == len(p.profilers) {
return err
}

return nil
}

0 comments on commit 67e329d

Please sign in to comment.