Skip to content
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

Refactored declaring multiple variables on a single line #550

Conversation

JeanPhilippeKernel
Copy link
Contributor

@JeanPhilippeKernel JeanPhilippeKernel commented Feb 26, 2020

Description

Fixes #522.

Checklist

Be sure you've read README.md and understand the scope of this repo.

If you're unsure about a box, leave it unchecked. A maintainer will help you.

  • Identifiers in product code changes are properly _Ugly as per
    https://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
  • The STL builds successfully and all tests have passed (must be manually
    verified by an STL maintainer before automated testing is enabled on GitHub,
    leave this unchecked for initial submission).
  • These changes introduce no known ABI breaks (adding members, renaming
    members, adding virtual functions, changing whether a type is an aggregate
    or trivially copyable, etc.).
  • These changes were written from scratch using only this repository,
    the C++ Working Draft (including any cited standards), other WG21 papers
    (excluding reference implementations outside of proposed standard wording),
    and LWG issues as reference material. If they were derived from a project
    that's already listed in NOTICE.txt, that's fine, but please mention it.
    If they were derived from any other project (including Boost and libc++,
    which are not yet listed in NOTICE.txt), you must mention it here,
    so we can determine whether the license is compatible and what else needs
    to be done.

@JeanPhilippeKernel JeanPhilippeKernel requested a review from a team as a code owner February 26, 2020 19:03
@JeanPhilippeKernel JeanPhilippeKernel changed the title Fix avoid declaring multiple var Refactored declaring multiple variables on a single line Feb 26, 2020
@BillyONeal
Copy link
Member

Are the llvm-project bits changes intentional?

@JeanPhilippeKernel
Copy link
Contributor Author

Oop nope:( ! I think It changed when I pulled from STL/master to mine

@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Feb 26, 2020
Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

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

Looks good, thank you! I observe that the /* const */ comments in ymath.h are being dropped, but that's fine (those variables should be const, but we can't do that because of binary compatibility; in vNext the entire area needs to be completely overhauled so we don't need additional reminders).

I'll go ahead and port this to the Microsoft-internal repo so we can merge it.

One comment about your PRs - if you look at the PR history, it shows a long sequence of commits (17 in this case), with your previous fixes and merges from master. Working in a long-lived branch is fine, but when you submit a new PR, I recommend creating a fresh branch, based on top of the current origin/master, containing one or more commits that are purely for that specific PR. (Usually one squashed commit is best for your initial PR, but it can be structured as a sequence of commits if your changes are unusually complicated; that is, commits in a PR should be arranged for clarity to reviewers, and not as a literal record of history.)

git experts can probably explain better techniques for squashing commits, but what I do is git rebase -i master when that works. When it doesn't (e.g. due to complicated merge history), what I do is:

S:\GitHub\STL>git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

S:\GitHub\STL>git pull
Already up to date.

S:\GitHub\STL>git checkout fix-avoid-declaring-multiple-var
Switched to a new branch 'fix-avoid-declaring-multiple-var'
Branch 'fix-avoid-declaring-multiple-var' set up to track remote branch 'fix-avoid-declaring-multiple-var' from 'jeanphilippekernel'.

S:\GitHub\STL>git merge master
Merge made by the 'recursive' strategy.
 llvm-project                                       |   2 +-
 stl/inc/future                                     |  11 +--
[... more output ...]
 35 files changed, 341 insertions(+), 214 deletions(-)

S:\GitHub\STL>git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

S:\GitHub\STL>git checkout -b GH-550
Switched to a new branch 'GH-550'

S:\GitHub\STL>git diff master fix-avoid-declaring-multiple-var > C:\Temp\GH-550.patch

S:\GitHub\STL>git apply C:\Temp\GH-550.patch

S:\GitHub\STL>git add --all

S:\GitHub\STL>git commit -m "GH-550 Refactored declaring multiple variables on a single line"
[GH-550 bf5a8a4] GH-550 Refactored declaring multiple variables on a single line
 11 files changed, 86 insertions(+), 38 deletions(-)

This is part of my process for porting changes from GitHub to Microsoft-internal git, but it can also be used to create PRs with simplified history.

@StephanTLavavej StephanTLavavej self-assigned this Feb 29, 2020
@JeanPhilippeKernel
Copy link
Contributor Author

Oh great !! Thank you so much for the technique !!!
I was looking for a way to do something like that !

@StephanTLavavej StephanTLavavej merged commit 5249900 into microsoft:master Feb 29, 2020
@BillyONeal
Copy link
Member

BillyONeal commented Feb 29, 2020

If you aren't transferring between repos the diff/apply step can be reduced to reset, assuming you are already on your branch that you're trying to submit:

    git fetch
    git merge origin/master
    git submodule update
    git reset origin/master
    git commit -am "GH-550 Refactored declaring multiple variables on a single line"

@StephanTLavavej
Copy link
Member

@JeanPhilippeKernel - thanks for improving the codebase yet again. :-)

@BillyONeal - oh, that makes even more sense, thanks for teaching us.

@JeanPhilippeKernel
Copy link
Contributor Author

It's my pleasure and I feel so honored to work with y'all :)
you're an amazing team !! I learn a lot !

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

Successfully merging this pull request may close these issues.

STL: Avoid declaring multiple variables on a single line
3 participants