Repository navigation
refactor: enforce a few minor optimization in code - #302
Merged
Merged
Conversation
… directly below p.Cap().
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #302 +/- ##
==========================================
+ Coverage 94.08% 94.43% +0.35%
==========================================
Files 9 9
Lines 744 737 -7
==========================================
- Hits 700 696 -4
+ Misses 32 30 -2
+ Partials 12 11 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
panjf2000
reviewed
Oct 18, 2023
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
name: Pull request
about: Propose changes to the code
title: 'make the code cleaner in worker_loop_queue.go and worker_stack.go'
labels: ''
assignees: ''
1. Are you opening this pull request for bug-fixs, optimizations or new feature?
refactor
2. Please describe how these code changes achieve your intention.
I noticed that the original code uses the
ifstatement to determine if the queue is overflowing in worker_loop_queue.go. I think it can use themodulooperator to make it cleaner.beforeafterAnd there are two different calculation methods for binary search of the mid variable in worker_loop_queue.go & worker_stack.go.
I think
l + ((r - l) >> 1)is a better way.worker_loop_queue.goworker_stack.goLast, I think it can reuse the
isEmpty()method to evaluate the condition below.beforeafter3. Please link to the relevant issues (if any).
No
4. Which documentation changes (if any) need to be made/updated because of this PR?
No
4. Checklist