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

perf(shareReplay): use correct default paramter #4130

Merged
merged 2 commits into from
Sep 11, 2018
Merged

perf(shareReplay): use correct default paramter #4130

merged 2 commits into from
Sep 11, 2018

Conversation

nename0
Copy link
Contributor

@nename0 nename0 commented Sep 11, 2018

Description:
shareReplay() uses a wrong default value for windowTime parameter since #3872. To disable the time function of the internal ReplaySubject the windowTime must be Number.POSITIVE_INFINITY and not Number.MAX_VALUE.
This makes shareReplay() faster because the ReplaySubject will not call scheduler.now(), when it is not needed.

This PR also adds a test, whichs checks if the ReplaySubject is in _infiniteTimeWindow mode, when no windowTime is given to shareReplay().

This will need merging with #4059 whatever comes first.

@coveralls
Copy link

coveralls commented Sep 11, 2018

Coverage Status

Coverage remained the same at 96.798% when pulling 063a4a5 on nename0:fix-sharereplay into 6a475cc on ReactiveX:master.

Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

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

LGTM.

sinon is used throughout the test suite. Could you use it to spy on now instead of the explicit function assignment?

const spy = sinon.spy(rxTestScheduler, 'now');
// ...
spy.restore();
expect(spy.called, 'ReplaySubject should not call ...').to.be.false;

@nename0
Copy link
Contributor Author

nename0 commented Sep 11, 2018

I also added a test to ReplaySubject to get coverage back up.

@cartant
Copy link
Collaborator

cartant commented Sep 11, 2018

Thanks for changing the test to use sinon. However, something appears to have happened to the alignment of the other marble diagrams in spec/operators/shareReplay-spec.ts. Do you have some sort of automated formatting enabled?

Regarding the coverage, it won't have been anything you did. The coverage seems to move around +/- 0.2% seemingly on a whim.

I think I'll have to look at the additional test when I'm less tired. I can't get my head around it, at the moment.

Thanks again for the PR.

@nename0
Copy link
Contributor Author

nename0 commented Sep 11, 2018

Thanks for the fast reponse!

It's not automated just a habit of pressing the format document shorcut every once in a while, which I should not do in a foreign project.
About the coverage: This line only gets run when both bufferSize and windowTime are used. Previously there was no test with both paramters, so I added one.
But still a few more test should not hurt.
Also shareReplay-spec.ts doesn't test the windowTime param at all. This is still true in #4059

@benlesh benlesh merged commit 114e771 into ReactiveX:master Sep 11, 2018
@nename0 nename0 deleted the fix-sharereplay branch September 11, 2018 20:46
@lock lock bot locked as resolved and limited conversation to collaborators Oct 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants