-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove some regex. decreases startup time by 2-3 seconds in an empty …
…forge instance
- Loading branch information
1 parent
6c55ef0
commit 629ca36
Showing
6 changed files
with
166 additions
and
1 deletion.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/com/falsepattern/gasstation/mixins/Helper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.falsepattern.gasstation.mixins; | ||
|
||
public class Helper { | ||
public static boolean zipJarRegex(String toMatch) { | ||
return toMatch.endsWith(".jar") || toMatch.endsWith(".zip"); | ||
} | ||
|
||
public static boolean classFileRegex(String toMatch) { | ||
return toMatch.endsWith(".class") && !toMatch.startsWith("$") && !toMatch.endsWith("$.class"); | ||
} | ||
|
||
public static boolean modClassRegex(String toMatch) { | ||
String shortName = toMatch.substring(toMatch.lastIndexOf('.') + 1); | ||
return shortName.startsWith("mod_") && !shortName.contains("$"); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/falsepattern/gasstation/mixins/mixin/regex/DirectoryDiscovererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.falsepattern.gasstation.mixins.mixin.regex; | ||
|
||
import com.falsepattern.gasstation.mixins.Helper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import cpw.mods.fml.common.discovery.DirectoryDiscoverer; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
@Mixin(value = DirectoryDiscoverer.class, | ||
remap = false) | ||
public abstract class DirectoryDiscovererMixin { | ||
private String fileName; | ||
|
||
@Redirect(method = "exploreFileSystem", | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/util/regex/Pattern;matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;"), | ||
require = 1) | ||
private Matcher noMatcher(Pattern instance, CharSequence charSequence) { | ||
fileName = charSequence.toString(); | ||
return null; | ||
} | ||
|
||
@Redirect(method = "exploreFileSystem", | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/util/regex/Matcher;matches()Z"), | ||
require = 1) | ||
private boolean fastMatch(Matcher instance) { | ||
return Helper.classFileRegex(fileName); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/falsepattern/gasstation/mixins/mixin/regex/JarDiscovererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.falsepattern.gasstation.mixins.mixin.regex; | ||
|
||
import com.falsepattern.gasstation.mixins.Helper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import cpw.mods.fml.common.discovery.JarDiscoverer; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
@Mixin(value = JarDiscoverer.class, | ||
remap = false) | ||
public abstract class JarDiscovererMixin { | ||
private String fileName; | ||
|
||
@Redirect(method = "discover", | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/util/regex/Pattern;matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;"), | ||
require = 1) | ||
private Matcher noMatcher(Pattern instance, CharSequence charSequence) { | ||
fileName = charSequence.toString(); | ||
return null; | ||
} | ||
|
||
@Redirect(method = "discover", | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/util/regex/Matcher;matches()Z"), | ||
require = 1) | ||
private boolean fastMatch(Matcher instance) { | ||
return Helper.classFileRegex(fileName); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/falsepattern/gasstation/mixins/mixin/regex/ModContainerFactoryMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.falsepattern.gasstation.mixins.mixin.regex; | ||
|
||
import com.falsepattern.gasstation.mixins.Helper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import cpw.mods.fml.common.ModContainerFactory; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
@Mixin(value = ModContainerFactory.class, | ||
remap = false) | ||
public abstract class ModContainerFactoryMixin { | ||
private String fileName; | ||
|
||
@Redirect(method = "build", | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/util/regex/Pattern;matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;"), | ||
require = 1) | ||
private Matcher noMatcher(Pattern instance, CharSequence charSequence) { | ||
fileName = charSequence.toString(); | ||
return null; | ||
} | ||
|
||
|
||
@Redirect(method = "build", | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/util/regex/Matcher;find()Z"), | ||
require = 1) | ||
private boolean fastMatch(Matcher instance) { | ||
return Helper.modClassRegex(fileName); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/falsepattern/gasstation/mixins/mixin/regex/ModDiscovererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.falsepattern.gasstation.mixins.mixin.regex; | ||
|
||
import com.falsepattern.gasstation.mixins.Helper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import cpw.mods.fml.common.discovery.ModDiscoverer; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
@Mixin(value = ModDiscoverer.class, | ||
remap = false) | ||
public abstract class ModDiscovererMixin { | ||
private String fileName; | ||
|
||
@Redirect(method = "findModDirMods(Ljava/io/File;[Ljava/io/File;)V", | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/util/regex/Pattern;matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;"), | ||
require = 1) | ||
private Matcher noMatcher(Pattern instance, CharSequence charSequence) { | ||
fileName = charSequence.toString(); | ||
return null; | ||
} | ||
|
||
@Redirect(method = "findModDirMods(Ljava/io/File;[Ljava/io/File;)V", | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/util/regex/Matcher;matches()Z"), | ||
require = 1) | ||
private boolean fastMatch(Matcher instance) { | ||
return Helper.zipJarRegex(fileName); | ||
} | ||
|
||
@Redirect(method = "findModDirMods(Ljava/io/File;[Ljava/io/File;)V", | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/util/regex/Matcher;group(I)Ljava/lang/String;"), | ||
require = 1) | ||
private String noGroup(Matcher instance, int i) { | ||
return fileName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters