Skip to content

Commit 35c4ab4

Browse files
authored
Merge pull request #1085 from kerams/main
Improve null comparisons
2 parents 5fcd382 + 348c6b1 commit 35c4ab4

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/Fabulous/Cmd.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ module Cmd =
196196
fun (value: 'value) ->
197197
[ fun dispatch ->
198198
lock funLock (fun () ->
199-
if cts <> null then
199+
if not(isNull cts) then
200200
cts.Cancel()
201201
cts.Dispose()
202202

@@ -209,7 +209,7 @@ module Cmd =
209209
lock funLock (fun () ->
210210
dispatch(fn value)
211211

212-
if cts <> null then
212+
if not(isNull cts) then
213213
cts.Dispose()
214214
cts <- null)
215215
},

src/Fabulous/Component.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ type Component(componentDataKey: ScalarAttributeKey, treeContext: ViewTreeContex
304304
node
305305

306306
member private this.RenderInternal() =
307-
if _body = null then
307+
if isNull body then
308308
() // Component has been disposed
309309
else
310310
let prevRootWidget = _widget
@@ -322,10 +322,10 @@ type Component(componentDataKey: ScalarAttributeKey, treeContext: ViewTreeContex
322322
Reconciler.update treeContext.CanReuseView (ValueSome prevRootWidget) currRootWidget viewNode
323323

324324
member this.Dispose() =
325-
if _contextSubscription <> null then
325+
if not(isNull _contextSubscription) then
326326
_contextSubscription.Dispose()
327327

328-
if _context <> null then
328+
if not(isNull _context) then
329329
_context.Dispose()
330330

331331
_body <- null
@@ -338,7 +338,7 @@ type Component(componentDataKey: ScalarAttributeKey, treeContext: ViewTreeContex
338338
member this.Dispose() = this.Dispose()
339339

340340
member this.Render(_) =
341-
if _body = null then
341+
if isNull _body then
342342
() // Component has been disposed
343343
else
344344
treeContext.SyncAction(this.RenderInternal)

src/Fabulous/View.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module View =
3737
let fnWithBoxing (msg: obj) =
3838
let oldFn = unbox<obj -> obj> oldAttr.Value
3939

40-
if msg <> null && typeof<'newMsg>.IsAssignableFrom(msg.GetType()) then
40+
if not(isNull msg) && typeof<'newMsg>.IsAssignableFrom(msg.GetType()) then
4141
box msg
4242
else
4343
oldFn msg |> unbox<'oldMsg> |> fn |> box
@@ -46,7 +46,7 @@ module View =
4646

4747
let defaultWith () =
4848
let mappedFn (msg: obj) =
49-
if msg <> null && typeof<'newMsg>.IsAssignableFrom(msg.GetType()) then
49+
if not(isNull msg) && typeof<'newMsg>.IsAssignableFrom(msg.GetType()) then
5050
box msg
5151
else
5252
unbox<'oldMsg> msg |> fn |> box

src/Fabulous/ViewNode.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ type ViewNode =
155155
if this.targetRef.IsAlive then
156156
let comp = this.treeContext.GetComponent(this.targetRef.Target) :?> IDisposable
157157

158-
if comp <> null then
158+
if not(isNull comp) then
159159
comp.Dispose()
160160
this.treeContext.SetComponent null this.targetRef.Target
161161

0 commit comments

Comments
 (0)