From 8eaf94f634f12f00ccfcac04dc909281d09db4c1 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Tue, 17 Sep 2024 19:54:35 +0200 Subject: [PATCH] optimise splitting code for short logs --- EliteBGS/DiscordLogGenerator.cs | 6 +++++- EliteBGS/OneLineDiscordLog.cs | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/EliteBGS/DiscordLogGenerator.cs b/EliteBGS/DiscordLogGenerator.cs index d9e649d..6764622 100644 --- a/EliteBGS/DiscordLogGenerator.cs +++ b/EliteBGS/DiscordLogGenerator.cs @@ -207,7 +207,11 @@ public class DiscordLogGenerator { string[] lines = log.Split("\n"); List chunks = new(); string chunk = string.Empty; - bool done = false; + + // Optimisation + if (log.Length <= maxcount) { + return new string[] { log }; + } // First split the log into its headers // skip first bot header line diff --git a/EliteBGS/OneLineDiscordLog.cs b/EliteBGS/OneLineDiscordLog.cs index d3bebb3..9a27d3e 100644 --- a/EliteBGS/OneLineDiscordLog.cs +++ b/EliteBGS/OneLineDiscordLog.cs @@ -33,6 +33,11 @@ public class OneLineDiscordLog : DiscordLogGenerator { List chunks = new(); string chunk = string.Empty; + // Optimisation + if (log.Length <= maxcount) { + return new string[] { log }; + } + for (int i = 0; i < lines.Length; i++) { string line = lines[i]; if ((chunk.Length + line.Length) > maxcount || i == lines.Length - 1) {