Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util-varexport: only traverse methods once #25

Open
youknowjack opened this issue May 18, 2020 · 0 comments
Open

util-varexport: only traverse methods once #25

youknowjack opened this issue May 18, 2020 · 0 comments

Comments

@youknowjack
Copy link
Contributor

Copied from an Indeed internal improvement request:

VarExporter.export traverses and exports @Export-annotated methods more than once in some scenarios. Make it stop doing that.

In particular, this code collects a set of all superinterfaces and calls getMethods on each of them (if declaredFieldsOnly is false). That results in O(NumberOfInterfaces) export attempts per method in the worst case:

        Set<Class<?>> classAndInterfaces = Sets.newHashSet();
        getAllInterfaces(c, classAndInterfaces);
        classAndInterfaces.add(c);
        for (Class<?> cls : classAndInterfaces) {
            for (final Method method : (declaredFieldsOnly ? cls.getDeclaredMethods() : cls.getMethods())) {
                Export export = method.getAnnotation(Export.class);
                if (Modifier.isStatic(method.getModifiers())) {
                    loadMemberVariable(method, export, c, true, prefix, null);
                } else {
                    loadMemberVariable(method, export, obj, true, prefix, null);
                }
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant