From 2b124f9e34265c4d1f0618aba5a3292506a1c659 Mon Sep 17 00:00:00 2001 From: pancakes Date: Mon, 6 Jan 2025 11:45:32 +1000 Subject: [PATCH] [frontend/mfm] Use double.TryParse instead of try/catch --- Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs b/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs index 0f75a3a2..1e10d860 100644 --- a/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs +++ b/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs @@ -536,14 +536,7 @@ public static partial class MfmRenderer if (childText == null) return el; double timestamp; - try - { - timestamp = double.Parse(childText); - } - catch - { - return el; - } + if (!double.TryParse(childText, out timestamp)) return el; var date = DateTime.UnixEpoch.AddSeconds(timestamp); el.SetAttribute("datetime", date.ToLocalTime().ToString("O"));