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

reuse _tempVec2 and avoid creating new temple object #17782

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

minggo
Copy link
Contributor

@minggo minggo commented Oct 29, 2024

_calculateMovePercentDelta() just uses anchor.x and anchor.y, and will not pass it to other functions, so it is safe to reuse _moveDeltaOptions and _tempVec2.

The best solution is change the parameter from _calculateMovePercentDelta(options: MoveDeltaOptions) to _calculateMovePercentDelta(anchor: Vec2, applyToHorizontal: boolean, applyToVertical: boolean). Then even don't have to:

  • define MoveDeltaOptions
  • create _moveDeltaOptions
  • and don't have assign _moveDeltaOptions before invoking _calculateMovePercentDelta()

But it will break the compatibility, as _calculateMovePercentDelta() is a protected function.

@minggo minggo requested a review from qiuguohua October 29, 2024 06:17
@minggo
Copy link
Contributor Author

minggo commented Oct 29, 2024

@cocos-robot run test cases

Copy link

github-actions bot commented Oct 29, 2024

⚠️ Package size ⤴ 179 bytes, old: 5430080, new: 5430259

Interface Check Report

This pull request does not change any public interfaces !

Copy link

@minggo, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
web-mobile PASS PASS FAIL
ios PASS PASS FAIL
mac PASS PASS FAIL scroll-view-bounce-back,scroll-view-scroll-to-offset,pageView_free_horizontal,pageView_free_verticle,pageView_unified_horizontal,pageView_unified_verticle

Copy link

@minggo, Please check the result of run test cases:

Task Details

Platform build boot runned crashScene FailScene
windows PASS PASS FAIL scroll-view-bounce-back,scroll-view-scroll-to-offset,pageView_free_horizontal,pageView_free_verticle,pageView_unified_horizontal,pageView_unified_verticle
android PASS PASS FAIL list-view,scroll-view-bounce-back,scroll-view-scroll-to-offset,pageView_free_horizontal,pageView_free_verticle,pageView_unified_horizontal,pageView_unified_verticle
wechatgame PASS PASS FAIL scroll-view-bounce-back,scroll-view-scroll-to-offset,pageView_free_horizontal,pageView_free_verticle,pageView_unified_horizontal,pageView_unified_verticle

@minggo
Copy link
Contributor Author

minggo commented Oct 29, 2024

@cocos-robot run test cases

2 similar comments
@minggo
Copy link
Contributor Author

minggo commented Oct 30, 2024

@cocos-robot run test cases

@sushanhong
Copy link
Contributor

@cocos-robot run test cases

@minggo
Copy link
Contributor Author

minggo commented Oct 30, 2024

@cocos-robot run test cases

1 similar comment
@sushanhong
Copy link
Contributor

@cocos-robot run test cases

Copy link

@minggo, Please check the result of run test cases:

Task Details

Copy link

@minggo, Please check the result of run test cases:

Task Details

@minggo minggo merged commit fa8b683 into cocos:v3.8.5 Oct 30, 2024
12 checks passed
@minggo minggo deleted the reuse-object-as-possible branch October 30, 2024 08:20
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.

3 participants