Skip to content

Commit

Permalink
[Tool] Deduplicate and reorder generated regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Sep 11, 2024
1 parent 8930484 commit 467a3c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/ReleaseTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,12 @@ private static void TagsToSplitterRegexes(string dialogueDir, bool readOnly = fa
File.WriteAllLines(dialogueFile, lines.Where(x => x.Length > 0));
}

File.WriteAllLines(Path.Combine(dialogueDir, "generated_regex.txt"), taggedLines);
File.WriteAllLines(Path.Combine(dialogueDir, "generated_regex.txt"),
// Deduplicate, then order regexes based on number of characters before first tag then by original text length for a small speedup at runtime
taggedLines.Distinct()
.GroupBy(x => x.Substring(0, x.IndexOf('='))).Select(x => x.First())
.OrderByDescending(x => x.IndexOf('(', StringComparison.Ordinal))
.ThenBy(x => x.IndexOf('=', StringComparison.Ordinal)));
}

private static readonly List<FileSystemInfo> _toCleanup = new List<FileSystemInfo>();
Expand Down

0 comments on commit 467a3c7

Please sign in to comment.