-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: enforce a few minor optimization in code #302
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks! |
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
if
statement to determine if the queue is overflowing in worker_loop_queue.go. I think it can use themodulo
operator to make it cleaner.before
after
And 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.go
worker_stack.go
Last, I think it can reuse the
isEmpty()
method to evaluate the condition below.before
after
3. 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