vue icon indicating copy to clipboard operation
vue copied to clipboard

perf(server-renderer):normalizeValue function prioritizes the judgmen…

Open LockingReal opened this issue 1 year ago • 11 comments

…t of values equal to 0, thereby improving performance

What kind of change does this PR introduce? (check at least one)

  • [ ] Bugfix
  • [ ] Feature
  • [ ] Code style update
  • [ ] Refactor
  • [ ] Build-related changes
  • [√] Other, please describe:

Does this PR introduce a breaking change? (check one) When the value is equal to 0, it avoids two typeof judgments and one js object attribute value, which improves performance

  • [ ] Yes
  • [√] No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • [ ] It's submitted to the main branch for v2.x (or to a previous version branch)
  • [ ] When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • [ ] All tests are passing: https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#development-setup
  • [ ] New/updated tests are included

If adding a new feature, the PR's description includes:

  • [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

LockingReal avatar Jul 22 '23 14:07 LockingReal

I have already run the npm run test command locally and passed all of it

LockingReal avatar Jul 22 '23 14:07 LockingReal

@sxzz @antfu @sodatea Can you help me check it ~~🥰

LockingReal avatar Jul 22 '23 14:07 LockingReal

Not now.

While I appreciate your contribution to the project, please don't @ me unless it's urgent. Just like you shouldn't call your colleague to review a small refactor on a Sunday morning. It's insensitive and impolite, to say the least.

haoqunjiang avatar Jul 23 '23 04:07 haoqunjiang

Not now.

While I appreciate your contribution to the project, please don't @ me unless it's urgent. Just like you shouldn't call your colleague to review a small refactor on a Sunday morning. It's insensitive and impolite, to say the least.

I think this is an open source project, and people will not treat it like work. The pressure in this area should not be too great, and I really didn't think too much. I'm very sorry 😢😣🤕

LockingReal avatar Jul 23 '23 04:07 LockingReal

@Justineo I see in the PR list that you have participated in some Code review work in some items on the first page of PR. Can you help check it?thanks~❤️

LockingReal avatar Jul 24 '23 13:07 LockingReal

I don’t get it how is this improving performance?

P.S. Don’t tag people like this unless it’s urgent. It is impolite as soda pointed out to you.

Justineo avatar Jul 24 '23 14:07 Justineo

I don’t get it how is this improving performance?

P.S. Don’t tag people like this unless it’s urgent. It is impolite as soda pointed out to you.

With the current modification, when value is equal to 0, an unnecessary typeof value=='string 'judgment will be skipped, and a typeof value==='number'&&noUnitNumericStyleProps [key] judgment will be skipped to directly enter the subsequent logic.

from the perspective of performance, using the === operator for equality comparison is faster than using the typeof operator for type checking.

the === operator only needs to compare if two values are exactly equal, while the typeof operator needs to check the type of the value, which may require more operations. Additionally, typeof also needs to perform string comparisons, which can lead to more time consumption.

LockingReal avatar Jul 24 '23 14:07 LockingReal

I don’t get it how is this improving performance?

P.S. Don’t tag people like this unless it’s urgent. It is impolite as soda pointed out to you.

In fact, I don't know how to find someone to review. Do we have a similar schedule? Do we regularly check them(pr)? I don't have much experience in cooperating with our project 🤕

LockingReal avatar Jul 24 '23 14:07 LockingReal

It’s faster only when value is 0.

Justineo avatar Jul 24 '23 14:07 Justineo

In fact, I don't know how to find someone to review. Do we have a similar schedule? Do we regularly check them(pr)? I don't have much experience in cooperating with our project 🤕

You don’t need to actively find someone to review a minor refactor. Project members may review PRs anytime they feel comfortable with.

Justineo avatar Jul 24 '23 14:07 Justineo

其实我也不知道怎么找人审稿。我们有类似的时间表吗?我们定期检查它们吗(pr)?我没有太多合作我们项目的经验🤕

你不需要主动找人来审查一个小的重构。项目成员可以在他们觉得舒服的时候随时审查 PR。

Haha, actually I used to do that in other projects, nothing happen...but I current understand. Thank you for your guidance~🥰

LockingReal avatar Jul 24 '23 14:07 LockingReal