optimise splitting code for short logs
This commit is contained in:
parent
20adf93d39
commit
8eaf94f634
@ -207,7 +207,11 @@ public class DiscordLogGenerator {
|
|||||||
string[] lines = log.Split("\n");
|
string[] lines = log.Split("\n");
|
||||||
List<string> chunks = new();
|
List<string> chunks = new();
|
||||||
string chunk = string.Empty;
|
string chunk = string.Empty;
|
||||||
bool done = false;
|
|
||||||
|
// Optimisation
|
||||||
|
if (log.Length <= maxcount) {
|
||||||
|
return new string[] { log };
|
||||||
|
}
|
||||||
|
|
||||||
// First split the log into its headers
|
// First split the log into its headers
|
||||||
// skip first bot header line
|
// skip first bot header line
|
||||||
|
@ -33,6 +33,11 @@ public class OneLineDiscordLog : DiscordLogGenerator {
|
|||||||
List<string> chunks = new();
|
List<string> chunks = new();
|
||||||
string chunk = string.Empty;
|
string chunk = string.Empty;
|
||||||
|
|
||||||
|
// Optimisation
|
||||||
|
if (log.Length <= maxcount) {
|
||||||
|
return new string[] { log };
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < lines.Length; i++) {
|
for (int i = 0; i < lines.Length; i++) {
|
||||||
string line = lines[i];
|
string line = lines[i];
|
||||||
if ((chunk.Length + line.Length) > maxcount || i == lines.Length - 1) {
|
if ((chunk.Length + line.Length) > maxcount || i == lines.Length - 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user