Skip to content

Commit

Permalink
Refactor condition checks using skipFinder function
Browse files Browse the repository at this point in the history
Replaced direct temp value checks in 'pool.go' file's two code blocks with a newly created 'skipFinder' function. The 'skipFinder' function encapsulates the conditions, making the code easier to read and maintain. This function checks whether the tweet finder should be skipped based on temperature criteria.
  • Loading branch information
lueurxax committed Dec 23, 2023
1 parent a7afee8 commit 1db380f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/tweetfinder/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (p *pool) IsHot() bool {
hotCounter := 0

for _, temp := range p.finderTemp {
if temp == 0 {
if skipFinder(temp) {
hotCounter++
}
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func (p *pool) getFinderIndex(ctx context.Context) (int, bool) {
}

for i, d := range p.finderTemp {
if d == 0 || d > 6 {
if skipFinder(d) {
continue
}

Expand All @@ -175,6 +175,10 @@ func (p *pool) getFinderIndex(ctx context.Context) (int, bool) {
return index, minimal != 0
}

func skipFinder(d float64) bool {
return d == 0 || d > 6
}

func (p *pool) releaseFinder(i int) {
p.mu.Lock()
p.finderDelays[i] = p.finders[i].CurrentDelay()
Expand Down

0 comments on commit 1db380f

Please sign in to comment.