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

refactor distinct #95

Merged
merged 3 commits into from
Oct 7, 2019
Merged

refactor distinct #95

merged 3 commits into from
Oct 7, 2019

Conversation

rivy
Copy link
Contributor

@rivy rivy commented Sep 17, 2019

  • refactor distinct sub-command into externally usable function, distinct_colors()

During testing, I ran into 32/64-bit differences in outcome and modified the tests to compensate.

I re-implemented the changes based on your fixed color implementation. (I had been using invariant_colors as the name when I was experimenting and left that in as a single commit ... easy to remove if you prefer fixed_colors).

To facilitate testing, I also went down the AppVeyor CI rabbit-hole for a couple of days and emerged with a generally flexible and functional configuration (including 32-bit and 64-bit, as well as, MSVC and GNU compilation).

I modified the Travis CI to include 32-bit compilation. I also saw that Windows compilation was now being included, but I marked them as possible failure and left the AppVeyor configuration commit since the Travis implementation is in "preview".

I also ended up adding an EditorConfig file as a commit, just to stop my IDE from grumbling.

Let me know what you think. I'm happy to modify or drop any of the commits.

@sharkdp
Copy link
Owner

sharkdp commented Sep 21, 2019

Thank you for your contribution.

I'm sorry, but this PR is too much. There are so many unrelated things going on and there are definitely some things which I do not want to include (.editorconfig) and some modifications which I would not accept (the deployment part in .travis.yml is completely disabled).

@rivy
Copy link
Contributor Author

rivy commented Sep 21, 2019 via email

@rivy rivy force-pushed the rf.distinct branch 3 times, most recently from b273b5a to 0cc918e Compare September 21, 2019 17:02
@rivy
Copy link
Contributor Author

rivy commented Sep 21, 2019

Forgot to re-enable the Travis deployment section ... that's fixed.
Dropped EditorConfig commit.

Everything is packaged in separate commits to drop CI, renaming, etc. as you wish.

@joshhansen
Copy link

@sharkdp Do you have any remaining issues with this PR? I'd be happy to address them.

@rivy
Copy link
Contributor Author

rivy commented Sep 30, 2019

This is the minimal change, everything else stripped out.

Box::new(|stats: &IterationStatistics| {
let stderr = io::stderr();
let brush_stderr = Brush::from_environment(Stream::Stderr);
Copy link
Owner

Choose a reason for hiding this comment

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

why have these lines been moved into the closure? This way we lock stderr and create a new brush for every callback iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm somewhat new to rust and I think that's a good question about what may be an incorrect solution on my part, but where would you put the lock for the output?

I though that here, nearest the output was the most correct. I may be incorrect in my understanding but I imagine handing the lock to the callback from elsewhere would lead to deadlocks.

I'd love to be shown a better, more idiomatic way...

Copy link
Owner

Choose a reason for hiding this comment

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

We are not running the callback concurrently. If we were, I guess we would actually introduce a potential synchronization overhead if we lock stderr on each iteration. But there is no deadlock scenario here. I modified your PR slightly to lock stderr only once (I didn't really look closely. My original code actually locked stderr multiple times as well, so sorry for that).

@sharkdp
Copy link
Owner

sharkdp commented Oct 6, 2019

Thank you very much. The changes look great. I only have a minor comment.

Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you very much!

@joshhansen
Copy link

Looks great, I'm looking forward to using this!

@sharkdp sharkdp merged commit b366456 into sharkdp:master Oct 7, 2019
@rivy
Copy link
Contributor Author

rivy commented Oct 8, 2019

👍

@rivy rivy deleted the rf.distinct branch October 8, 2019 03:03
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.

3 participants