Skip to content

Commit 25286eb

Browse files
vexx32iSazonov
authored andcommitted
Use more effective evaluation order in LanguagePrimitives.IsNullLike() (PowerShell#10781)
Refactor IsNullLike() to evaluate the most commonly-expected null-like values first.
1 parent 3bddfcb commit 25286eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/System.Management.Automation/engine/LanguagePrimitives.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ internal static bool IsTrue(IList objectArray)
10711071
/// </summary>
10721072
/// <param name="obj">The object to test.</param>
10731073
/// <returns>True if the object is null.</returns>
1074-
public static bool IsNullLike(object obj) => obj == DBNull.Value || obj == NullString.Value || IsNull(obj);
1074+
public static bool IsNullLike(object obj) => IsNull(obj) || obj == DBNull.Value || obj == NullString.Value;
10751075

10761076
/// <summary>
10771077
/// Auxiliary for the cases where we want a new PSObject or null.

0 commit comments

Comments
 (0)