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

perf(ivy): apply static styles/classes directly to an element's style/className properties #33364

Closed
wants to merge 3 commits into from

Conversation

matsko
Copy link
Contributor

@matsko matsko commented Oct 23, 2019

No description provided.

@@ -1853,6 +1854,12 @@ export function textBindingInternal(lView: LView, index: number, value: string):
* style and class entries to the element.
*/
export function renderInitialStyling(renderer: Renderer3, native: RElement, tNode: TNode) {
renderStylingMap(renderer, native, tNode.classes, true);
renderStylingMap(renderer, native, tNode.styles, false);
if (tNode.classes) {

Choose a reason for hiding this comment

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

Could we add a more strict check here? I presume it would be along the line of tNode.classes !== null?

const classes = getInitialStylingValue(tNode.classes);
writeStylingValueDirectly(renderer, native, classes, true, null);
}
if (tNode.styles) {

Choose a reason for hiding this comment

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

Could we add a more strict check here? I presume it would be along the line of tNode. styles !== null?


function objectToClassName(obj: {[key: string]: any} | null): string {
let str = '';
if (obj) {

Choose a reason for hiding this comment

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

Could we move this check to the caller (preferred) or, as the very minimum, make it more explicit (test for !== null)

@@ -888,6 +921,26 @@ export const setClass: ApplyStylingFn =
}
};

export const setClassName = (renderer: Renderer3 | null, native: RElement, className: string) => {
if (renderer !== null) {

Choose a reason for hiding this comment

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

I'm surprised that we are testing for the renderer's presence here. Under what condition it can get null?

@mhevery mhevery added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Oct 24, 2019
@matsko
Copy link
Contributor Author

matsko commented Oct 25, 2019

@matsko matsko marked this pull request as ready for review October 25, 2019 00:57
@matsko matsko requested a review from a team as a code owner October 25, 2019 00:57
@matsko matsko added the target: major This PR is targeted for the next major release label Oct 25, 2019
@matsko
Copy link
Contributor Author

matsko commented Oct 25, 2019

[MASTER]

Benchmark: class binding: create:
 [class]="CLASSES_1": 144.483 ns(0%)
 [class]="CLASSES_2": 166.832 ns(-15%)
 [class]="CLASSES_10": 171.155 ns(-18%)
 class="A B": 194.452 ns(-35%)
 class="A B" [class]="CLASSES_1": 203.504 ns(-41%)
 class="A B" [class]="CLASSES_10": 186.334 ns(-29%)
 class="A B" [class]="CLASSES_1" [class.foo]="exp": 185.586 ns(-28%)
 class="A B" [class]="CLASSES_10" [class.foo]="exp": 186.868 ns(-29%)
 [className]="CLASSES_10": 157.359 ns(-9%)

[THIS PR]

Benchmark: class binding: create:
 [class]="CLASSES_1": 143.299 ns(0%)
 [class]="CLASSES_2": 163.884 ns(-14%)
 [class]="CLASSES_10": 158.020 ns(-10%)
 class="A B": 172.633 ns(-20%)
 class="A B" [class]="CLASSES_1": 170.446 ns(-19%)
 class="A B" [class]="CLASSES_10": 176.444 ns(-23%)
 class="A B" [class]="CLASSES_1" [class.foo]="exp": 174.218 ns(-22%)
 class="A B" [class]="CLASSES_10" [class.foo]="exp": 176.737 ns(-23%)
 [className]="CLASSES_10": 153.887 ns(-7%)

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@mhevery
Copy link
Contributor

mhevery commented Oct 25, 2019

presubmit
presubmit ivy

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@matsko matsko added cla: yes and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews cla: no labels Oct 25, 2019
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@ngbot ngbot bot added this to the needsTriage milestone Oct 25, 2019
@matsko matsko added the action: merge The PR is ready for merge by the caretaker label Oct 25, 2019
@ngbot
Copy link

ngbot bot commented Oct 25, 2019

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "google3" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants