From 983e636635104cddd9773a5d2112f35be16f2066 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 8 Aug 2023 12:41:12 +0100 Subject: [PATCH] perf: structure query get a bit better --- OliverBooth/Pages/Blog/Index.cshtml.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/OliverBooth/Pages/Blog/Index.cshtml.cs b/OliverBooth/Pages/Blog/Index.cshtml.cs index c04685c..0ea63c7 100644 --- a/OliverBooth/Pages/Blog/Index.cshtml.cs +++ b/OliverBooth/Pages/Blog/Index.cshtml.cs @@ -39,22 +39,12 @@ public class Index : PageModel public IActionResult OnGet([FromQuery(Name = "pid")] int? postId = null, [FromQuery(Name = "p")] int? wpPostId = null) { - if (!(postId.HasValue ^ wpPostId.HasValue)) + if (postId.HasValue == wpPostId.HasValue) { return Page(); } - if (wpPostId.HasValue) - { - return HandleWordPressRoute(wpPostId.Value); - } - - if (postId.HasValue) - { - return HandleNewRoute(postId.Value); - } - - throw new UnreachableException(); + return postId.HasValue ? HandleNewRoute(postId.Value) : HandleWordPressRoute(wpPostId!.Value); } private IActionResult HandleNewRoute(int postId)