From d38e5593427f63e513ca3be11c3fdccb07b88ce1 Mon Sep 17 00:00:00 2001 From: Sai Rohith <33945347+sairohith2605@users.noreply.github.com> Date: Mon, 24 Jun 2024 01:03:16 +0530 Subject: [PATCH] Removes the redundant external condition (#102883) Since we're anyway verifying only for isCancelled, there's no reason why we're checking for `isCompleted` externally, especially given that it's an OR. --- .../Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs index 949200f22d849..9cbe0e7ba8d80 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs @@ -118,12 +118,9 @@ private async Task SerializeAsync( } FlushResult result = await pipeWriter.FlushAsync(cancellationToken).ConfigureAwait(false); - if (result.IsCanceled || result.IsCompleted) + if (result.IsCanceled) { - if (result.IsCanceled) - { - ThrowHelper.ThrowOperationCanceledException_PipeWriteCanceled(); - } + ThrowHelper.ThrowOperationCanceledException_PipeWriteCanceled(); } } finally