Skip to content

Refactored code to remove unnecessary checks #2425

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

Merged
merged 1 commit into from Jul 31, 2019
Merged

Refactored code to remove unnecessary checks #2425

merged 1 commit into from Jul 31, 2019

Conversation

ghost
Copy link

@ghost ghost commented Jul 20, 2019

When creating an immutable funnel, the code checks the value of "hasLengthByte" twice if it ends up being true. Checking for it once is all that is needed, as another branch can check for the other boolean statement in the if statement previously on line 1483. Differentiating the branches allows less redundant checks and does not introduce any side effects.

@ghost
Copy link
Author

ghost commented Jul 20, 2019

@swift-ci please test linux

@ghost
Copy link
Author

ghost commented Jul 20, 2019

@swift-ci please test

@ghost
Copy link
Author

ghost commented Jul 20, 2019

Fixed the mistake. Everything should be good!

@ghost
Copy link
Author

ghost commented Jul 20, 2019

@swift-ci please test linux

@ghost
Copy link
Author

ghost commented Jul 20, 2019

cc @gregomni

@xwu
Copy link
Contributor

xwu commented Jul 21, 2019

@pi1024e Could you please squash this into one commit?

@xwu
Copy link
Contributor

xwu commented Jul 21, 2019

@swift-ci Please test Linux

@ghost
Copy link
Author

ghost commented Jul 21, 2019

@swift-ci Please test linux

1 similar comment
@millenomi
Copy link
Contributor

@swift-ci Please test linux

@ghost
Copy link
Author

ghost commented Jul 23, 2019

Made those changes!

Copy link
Contributor

@drodriguez drodriguez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pi1024e: instead of a lot of small changes, why don't we focus in the original change. I don't think anyone has any problem with the code as it is now, and we can figure out the other changes one by one.

Can you maybe rewrite this patch to only be those changes, squash, and then submit the other changes in different PRs?

Thanks.

@ghost
Copy link
Author

ghost commented Jul 27, 2019

Made those changes. Thank you!

@ghost
Copy link
Author

ghost commented Jul 27, 2019

Fixed!

@drodriguez
Copy link
Contributor

@pi1024e: I don't know what your expertise level is, but I'm going to explain this as best as I can.

The only commit that we are currently interested is the first one, and also the fix from the first feedback. It seems that you are using the master branch for working, I would recommend the following procedure (the lines that start in # are comments by me, the lines that start with $ will have to be typed in the command line).

# Let's save all your work into a local branch
$ git branch cleanup-save
# Let's reset your master branch to the first commit
$ git reset --hard 8611fd80328d30e7fce86ba529152f4240a5aa41
# At this point edit the file CFString.c to move the line size += 1 to the bottom branch. Save your edit and don't modify anything else.
# I will be good to verify that only those changes are being sent.
$ git diff
# After checking that the changes are only the ones we want (the move of the line size += 1), we can continue.
$ git add CoreFoundation/String.subproj/CFString.c
# Let's rewrite the commit to have the fix.
$ git commit --amend --no-edit
# And finally update the remote to that version. I imagine your remote might be called origin, but replace <your remote name> in the line below by the name of your remote.
$ git push -f <your remote name>

That should get us only the initial changes, clean of every other commit. All your other changes are in a local branch called cleanup-save, and we can discuss about then in different PRs.

Thanks!

@ghost
Copy link
Author

ghost commented Jul 27, 2019

Thank you so much! Now I know what to do and how to properly contribute. Thank you!

Copy link
Contributor

@xwu xwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost. You should try to follow @drodriguez’s instructions as exactly as possible; you’re still introducing new whitespace changes with every commit, possibly unintentionally.

@ghost
Copy link
Author

ghost commented Jul 28, 2019

Clang-format automatically made the whitespace changes. I thought I had to run that before committing to ensure no formatting changes would be done. Guess I was wrong.

@xwu
Copy link
Contributor

xwu commented Jul 28, 2019

It can be helpful to clang-format your own contributions, but you should not format existing code.

There are now pervasive changes in whitespace which cannot be taken as part of this PR. Again, please try to follow @drodriguez’s instructions as exactly as possible and make no other changes.

@ghost
Copy link
Author

ghost commented Jul 29, 2019

Everything is fixed!

@xwu
Copy link
Contributor

xwu commented Jul 29, 2019

This looks good. As the final step, please squash your commits into one commit.

Here is a tutorial that explains how:
https://thoughtbot.com/blog/git-interactive-rebase-squash-amend-rewriting-history

@ghost
Copy link
Author

ghost commented Jul 30, 2019

Squashed those commits!

@spevans
Copy link
Contributor

spevans commented Jul 30, 2019

@swift-ci test

@xwu xwu changed the title Refactored code to remove unneccesary checks Refactored code to remove unnecessary checks Jul 30, 2019
@ghost
Copy link
Author

ghost commented Jul 30, 2019

Are these changes ok?

@xwu
Copy link
Contributor

xwu commented Jul 30, 2019

This looks good to me, but others still have to approve.

@xwu
Copy link
Contributor

xwu commented Jul 30, 2019

@swift-ci Please test

@ghost
Copy link
Author

ghost commented Jul 30, 2019

@swift-ci please test

@ghost
Copy link
Author

ghost commented Jul 30, 2019

Fixed!

@xwu
Copy link
Contributor

xwu commented Jul 30, 2019

Good, now if you squash the commit, this PR looks to be in better shape.

@ghost
Copy link
Author

ghost commented Jul 30, 2019

Fixed!

@ghost
Copy link
Author

ghost commented Jul 30, 2019

@swift-ci please test

Copy link
Contributor

@xwu xwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what happened, but you've introduced additional changes again?

@ghost
Copy link
Author

ghost commented Jul 30, 2019

Done!

@ghost
Copy link
Author

ghost commented Jul 30, 2019

Okay. All changes done! Let us get this over with!

@ghost
Copy link
Author

ghost commented Jul 30, 2019

@swift-ci Please test

@xwu xwu requested a review from drodriguez July 30, 2019 20:12
@xwu
Copy link
Contributor

xwu commented Jul 30, 2019

You need permissions to trigger testing. It's helpful if you've made sure that your changes compile and pass all tests locally.

@swift-ci Please test

@xwu
Copy link
Contributor

xwu commented Jul 30, 2019

@swift-ci Please test

@xwu
Copy link
Contributor

xwu commented Jul 30, 2019

@swift-ci Please test Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants