-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix the bugs of manual_memcpy
, simplify the suggestion and refactor it
#5536
Conversation
Thanks for splitting up the commits as they are, that makes reviewing significantly more easy 👍 I'll try and review this by the end of the day. |
For your question about the tests: You already have them in the PR description, why not just throw them in the test file, with the short comments you wrote, what they are supposed to test? :) |
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.
changes LGTM but the 2 tests would indeed be nice to have.
Thanks you for your reviews. I've added the 2 tests. |
@bors r+ |
📌 Commit 461f4a3 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
While I’m working on the long procrastinated work to expand
manual_memcpy
(#1670), I found a few minor bugs and probably unidiomatic or old coding style. There is a brief explanation of changes to the behaviour this PR will make below. And, I have a questoin: do I need to add tests for the first and second fixed bugs? I thought it might be too rare cases to include the tests for those. I added for the last one though.Bug fix
It negates resulted offsets (
src/dst_offset
) whenoffset
is subtraction by 0. This PR will remove any subtraction by 0 as a part of minification.It prints
RangeTo
orRangeFull
when both ofend
andoffset
are 0, which have different meaning. This PR will print 0. I could reject the casesend
is 0, but I thought I won’t catch other casesreverse_range_loop
will trigger, and it’s over to catch every such cases.it prints four dots when
end
isNone
. This PR will ignore anyfor
loops withoutend
because afor
loop that takesRangeFrom
as its argument and contains indexing without the statements or the expressions that end loops such asbreak
will definitely panic, andmanual_memcpy
should ignore the loops with such control flow.Simplification of the suggestion
start
orend
andoffset
are same (from Simplify manual_memcpy suggestion in some cases #3323). This PR will useRangeTo
changelog: fixed the bugs of
manual_memcpy
and also simplify the suggestion.