Skip to content

Commit b6414c7

Browse files
authored
Optimise parsing bootstrap-shim.list (#7)
1 parent 399e5ec commit b6414c7

File tree

1 file changed

+16
-6
lines changed
  • bs-shim/src/main/java/net/minecraftforge/bootstrap/shim

1 file changed

+16
-6
lines changed

bs-shim/src/main/java/net/minecraftforge/bootstrap/shim/Main.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ public static void main(String[] args) throws Exception {
4646
System.out.println("Loading classpath: ");
4747
String line = reader.readLine();
4848
while (line != null) {
49-
ListEntry entry = ListEntry.from(line);
50-
//System.out.println(entry);
51-
File target = new File("libraries/"+ entry.path);
49+
String entryPath = ListEntry.getPathFrom(line);
50+
// if (DEBUG) {
51+
// ListEntry entry = ListEntry.from(line);
52+
// entryPath = entry.path;
53+
// System.out.println(entry);
54+
// }
55+
File target = new File("libraries/"+ entryPath);
5256
if (!target.exists()) {
53-
System.out.println("Missing required library: " + entry.path);
57+
System.out.println("Missing required library: " + entryPath);
5458
failed = true;
5559
}
5660
classpath.append(File.pathSeparator).append(target.getAbsolutePath());
@@ -128,8 +132,14 @@ private static final class ListEntry {
128132
private final String path;
129133

130134
private static ListEntry from(String line) {
131-
String[] parts = line.split("\t", 3);
132-
return new ListEntry(parts[0], parts[1], parts[2]);
135+
String sha256 = line.substring(0, 64);
136+
if (line.charAt(65) != '\t') throw new IllegalArgumentException("Invalid bootstrap config line: " + line);
137+
String[] parts = line.substring(65).split("\t", 2);
138+
return new ListEntry(sha256, parts[0], parts[1]);
139+
}
140+
141+
private static String getPathFrom(String line) {
142+
return line.substring(65).split("\t", 2)[1];
133143
}
134144

135145
private ListEntry(String sha256, String id, String path) {

0 commit comments

Comments
 (0)