Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix #867: perf shadow #898

Merged
merged 2 commits into from
Oct 31, 2016
Merged

Fix #867: perf shadow #898

merged 2 commits into from
Oct 31, 2016

Conversation

danglotb
Copy link
Member

No description provided.

@danglotb danglotb force-pushed the fix-perf-shadow branch 3 times, most recently from b06e104 to 2a06d46 Compare October 17, 2016 15:00
return new JavaReflectionTreeBuilder(createFactory()).scan((Class<T>) cl);
final CtType<T> shadowClass = (CtType<T>) this.shadowCache.get(cl);
if (shadowClass == null) {
final CtType<T> newShadowClass = new JavaReflectionTreeBuilder(createFactory()).scan((Class<T>) cl);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract:
shadowCtClass.getFactory().get(shadowCtClass.getActualClass()) == shadowCtClass

if (super.matches(element)) {
element.setFactory(factory);
}
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify by

element.setFactory(factory);
return false; // create an empty list

if (shadowClass == null) {
final CtType<T> newShadowClass = new JavaReflectionTreeBuilder(createFactory()).scan((Class<T>) cl);
newShadowClass.setFactory(factory);
newShadowClass.getElements(new TypeFilter<CtElement>(CtElement.class) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use accept instead of getElements

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants