mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-31 12:24:10 -08:00
Minor performance improvement
This commit is contained in:
parent
0ecafbe4b4
commit
cc0f7583b0
|
@ -40,7 +40,7 @@ import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
|
|
||||||
public class ServiceLoaderSupport extends AbstractDependencyListener implements Generator {
|
public class ServiceLoaderSupport extends AbstractDependencyListener implements Generator {
|
||||||
private Set<String> achievedClasses = new HashSet<>();
|
private Set<String> reachedClasses = new HashSet<>();
|
||||||
private Map<String, List<String>> serviceMap = new HashMap<>();
|
private Map<String, List<String>> serviceMap = new HashMap<>();
|
||||||
private DependencyNode allClassesNode;
|
private DependencyNode allClassesNode;
|
||||||
private ClassLoader classLoader;
|
private ClassLoader classLoader;
|
||||||
|
@ -92,7 +92,7 @@ public class ServiceLoaderSupport extends AbstractDependencyListener implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void classReached(DependencyAgent agent, String className, CallLocation location) {
|
public void classReached(DependencyAgent agent, String className, CallLocation location) {
|
||||||
if (!achievedClasses.add(className)) {
|
if (!reachedClasses.add(className)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.jso.impl;
|
package org.teavm.jso.impl;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.teavm.dependency.AbstractDependencyListener;
|
import org.teavm.dependency.AbstractDependencyListener;
|
||||||
import org.teavm.dependency.DependencyAgent;
|
import org.teavm.dependency.DependencyAgent;
|
||||||
|
@ -27,6 +28,8 @@ import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
class JSDependencyListener extends AbstractDependencyListener {
|
class JSDependencyListener extends AbstractDependencyListener {
|
||||||
private JSBodyRepository repository;
|
private JSBodyRepository repository;
|
||||||
|
private Set<String> reachedClasses = new HashSet<>();
|
||||||
|
private Set<MethodReference> reachedMethods = new HashSet<>();
|
||||||
|
|
||||||
JSDependencyListener(JSBodyRepository repository) {
|
JSDependencyListener(JSBodyRepository repository) {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
|
@ -35,6 +38,9 @@ class JSDependencyListener extends AbstractDependencyListener {
|
||||||
@Override
|
@Override
|
||||||
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||||
MethodReference ref = method.getReference();
|
MethodReference ref = method.getReference();
|
||||||
|
if (!reachedMethods.add(ref)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Set<MethodReference> callbackMethods = repository.callbackMethods.get(ref);
|
Set<MethodReference> callbackMethods = repository.callbackMethods.get(ref);
|
||||||
if (callbackMethods != null) {
|
if (callbackMethods != null) {
|
||||||
for (MethodReference callbackMethod : callbackMethods) {
|
for (MethodReference callbackMethod : callbackMethods) {
|
||||||
|
@ -45,6 +51,9 @@ class JSDependencyListener extends AbstractDependencyListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void classReached(DependencyAgent agent, String className, CallLocation location) {
|
public void classReached(DependencyAgent agent, String className, CallLocation location) {
|
||||||
|
if (!reachedClasses.add(className)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ClassReader cls = agent.getClassSource().get(className);
|
ClassReader cls = agent.getClassSource().get(className);
|
||||||
for (MethodReader method : cls.getMethods()) {
|
for (MethodReader method : cls.getMethods()) {
|
||||||
AnnotationReader exposeAnnot = method.getAnnotations().get(JSMethodToExpose.class.getName());
|
AnnotationReader exposeAnnot = method.getAnnotations().get(JSMethodToExpose.class.getName());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user