From 45e10ca3770568908a1c980ec4aecc3a4e9fe071 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 14 Nov 2019 21:09:31 -0600 Subject: [PATCH] SP-265 use 'is' instead of explicit cast to IPNLCellData (the cast should work; this is defensive) --- .../spark/Modules/Trading/PNL/VM/PNLRowComparer.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/client/spark/Modules/Trading/PNL/VM/PNLRowComparer.cs b/src/client/spark/Modules/Trading/PNL/VM/PNLRowComparer.cs index 0932b01db..9d88699da 100644 --- a/src/client/spark/Modules/Trading/PNL/VM/PNLRowComparer.cs +++ b/src/client/spark/Modules/Trading/PNL/VM/PNLRowComparer.cs @@ -90,12 +90,11 @@ namespace bts.shell.pnl { } int? _try_compare_groups(CollectionViewGroup x, CollectionViewGroup y) { - if (x == null || y == null) - return null; - var xcell = (IPNLCellData)x.Name; - var ycell = (IPNLCellData)y.Name; - var comp = _get_column_comparer(xcell.column); - return comp.value_comparer.Compare(xcell.value, ycell.value); + if (x?.Name is IPNLCellData xcell && y?.Name is IPNLCellData ycell) { + var comp = _get_column_comparer(xcell.column); + return comp.value_comparer.Compare(xcell.value, ycell.value); + } + return null; } } -} \ No newline at end of file +}