From 3706aa7e4c9e6aa9ccd9d32ea924468f0d2e638b Mon Sep 17 00:00:00 2001 From: supersaiyansubtlety Date: Wed, 24 Jul 2024 15:36:40 -0700 Subject: [PATCH] use one regex instead of two (no functional changes) --- .../lint/FindDuplicateMappingFilesTask.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/buildSrc/src/main/java/quilt/internal/tasks/lint/FindDuplicateMappingFilesTask.java b/buildSrc/src/main/java/quilt/internal/tasks/lint/FindDuplicateMappingFilesTask.java index 0d7df2d03b..9665916181 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/lint/FindDuplicateMappingFilesTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/lint/FindDuplicateMappingFilesTask.java @@ -21,8 +21,8 @@ public abstract class FindDuplicateMappingFilesTask extends DefaultTask { public static final String TASK_NAME = "findDuplicateMappingFiles"; private static final Logger LOGGER = Logging.getLogger(FindDuplicateMappingFilesTask.class); - private static final Pattern MINECRAFT_CLASS = Pattern.compile("^CLASS net/minecraft/(?:\\w+/)*\\w+(?= )"); - private static final Pattern BLAZE_CLASS = Pattern.compile("^CLASS com/mojang/blaze3d/(?:\\w+/)*\\w+(?= )"); + private static final Pattern EXPECTED_CLASS = + Pattern.compile("^CLASS (?:net/minecraft|com/mojang/blaze3d)/(?:\\w+/)*\\w+(?= )"); @InputDirectory public abstract DirectoryProperty getMappingDirectory(); @@ -146,16 +146,9 @@ public void run() { } private static Optional getClassMatch(String firstLine) { - final var minecraftClassMatcher = MINECRAFT_CLASS.matcher(firstLine); - if (minecraftClassMatcher.find()) { - return Optional.of(minecraftClassMatcher.group(0)); - } else { - final var blazeClassMatcher = BLAZE_CLASS.matcher(firstLine); - if (blazeClassMatcher.find()) { - return Optional.of(blazeClassMatcher.group(0)); - } else { - return Optional.empty(); - } - } + final var expectedClassMatcher = EXPECTED_CLASS.matcher(firstLine); + return expectedClassMatcher.find() ? + Optional.of(expectedClassMatcher.group(0)) : + Optional.empty(); } }