-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: use shared, static observables to reduce allocations #1289
Conversation
@@ -72,6 +72,7 @@ | |||
<Compile Include="MessageBus.cs" /> | |||
<Compile Include="SuspensionHost.cs" /> | |||
<Compile Include="ObservableAsPropertyHelper.cs" /> | |||
<Compile Include="Observables.cs" /> |
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.
This saddens me (the fact that we need to do it everywhere :()
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.
Totally! Bring on VS17.
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.
It's doable with shared projects now...probably not worth the faff of doing it twice though!
src/ReactiveUI/Observables.cs
Outdated
/// <summary> | ||
/// Provides commonly required, statically-allocated, pre-canned observables. | ||
/// </summary> | ||
public static class Observables |
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.
Should this be internal (like the Observable<T>
class)?
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.
It should! Thanks - I copied this from Genesis.Observables and forgot to change both.
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// This observable is equivalent to <c>Observable<bool>.Default</c>, but is provided for convenience. |
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.
Is there a reason to Default
rather than Observable.Return(false)
don't think it really matters, but it seems a little odd that it's different for the true/false cases.
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.
Probably a completely pointless optimization. That is, if it's Observable.Return(false)
then someone access Observable<bool>.Default
, then we've cached two instead of one. For the sake of readability, I will change this.
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.
That does make sense, hadn't quite spotted that!
Thanks for the review @olevett! |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Performance improvement.
What is the current behavior? (You can also link to an open issue here)
#1156
Does this PR introduce a breaking change?
No.
Please check if the PR fulfills these requirements
Other information:
Let's allocate less!