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

Avoid creating unused node features #4574

Merged
merged 1 commit into from Sep 3, 2018
Merged

Conversation

Legioth
Copy link
Member

@Legioth Legioth commented Aug 31, 2018

Many node feature types are only used in some very specific situations,
e.g. only if an element has virtual children. Reduce memory overhead by
not allocating such instances until some data will actually be saved in
them.

Reduces BasicElementView memory use from 219100 to 149909 bytes and the
memory use in BeverageBuddy with an edit dialog open from 170041 to
151733 bytes.


This change is Reviewable

Many node feature types are only used in some very specific situations,
e.g. only if an element has virtual children. Reduce memory overhead by
not allocating such instances until some data will actually be saved in
them.

Reduces BasicElementView memory use from 219100 to 149909 bytes and the
memory use in BeverageBuddy with an edit dialog open from 170041 to
151733 bytes.
}

@Override
public void removeAttribute(StateNode node, String attribute) {
assert attribute != null;
assert attribute.equals(attribute.toLowerCase(Locale.ENGLISH));

getAttributeFeature(node).remove(attribute);
getAttributeFeatureIfInitialized(node)
.map(feature -> feature.remove(attribute));
Copy link
Collaborator

Choose a reason for hiding this comment

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

MAJOR The return value of "map" must be used. rule

@vaadin-bot
Copy link
Collaborator

SonarQube analysis reported 5 issues

  • MAJOR 3 major
  • INFO 2 info

Watch the comments in this conversation to review them.

4 extra issues

Note: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:

  1. MAJOR Element.java#L1346: Make this anonymous inner class a lambda rule
  2. MAJOR Element.java#L1379: Make this anonymous inner class a lambda rule
  3. INFO Element.java#L121: Do not forget to remove this deprecated code someday. rule
  4. INFO Element.java#L544: Do not forget to remove this deprecated code someday. rule

@SomeoneToIgnore SomeoneToIgnore self-assigned this Sep 3, 2018
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 12 of 12 files at r1.
Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained, and 1 stale


flow-server/src/main/java/com/vaadin/flow/dom/impl/BasicElementStateProvider.java, line 212 at r1 (raw file):

Previously, vaadin-bot (Vaadin Bot) wrote…

MAJOR The return value of "map" must be used. rule

ifPresent might be less confusing indeed, but it's too minor to deal with it.

Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Dismissed @vaadin-bot from a discussion.
Reviewable status: :shipit: complete! all discussions resolved, 1 of 1 LGTMs obtained

@SomeoneToIgnore SomeoneToIgnore merged commit a85227b into master Sep 3, 2018
@SomeoneToIgnore SomeoneToIgnore deleted the lazyFeatureCreation branch September 3, 2018 07:42
@pekam pekam added this to the 1.1.0.beta3 milestone Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants