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

[REFACTOR] Player Property by lazy #90

Merged
merged 3 commits into from
Jun 8, 2024

Conversation

eshc123
Copy link
Owner

@eshc123 eshc123 commented Jun 6, 2024

Description

Player Data class 개선

Content

  1. 기존 getAge() 의 경우 호출 때마다 getYearAndMonthAndDateLocalDate 와 Period.between() 연산을 하고 있으므로 일반적인 호출보다 비용이 더 크므로 by lazy 를 사용하여 개선하였습니다.
  • 지연 초기화를 통해 사용하여 실제 사용할 때 값을 초기화하도록 하였습니다.
  • 또한 lazy를 통해 캐싱된 값을 사용하여 초기화시에만 필요한 연산을 하도록 하였습니다.
  • 초기화 블록이 단순하고 동기화를 생각하지 않아도 되기 때문에 가장 오버헤드가 적은 LazyThreadSafetyMode.NONE 를 mode로 사용하였습니다.
  1. displayName도 동일하게 지연 초기화와 캐싱된 초기화 값을 사용하기 위해 수정하였습니다.

ref) https://kotlinlang.org/docs/delegated-properties.html#lazy-properties

Comment

이번 PR과 같이 개선할 점이나 새롭게 익힌 부분이 있으면 양이 적더라도 바로 적용해보는 것도 좋을 듯 싶습니다!

@eshc123 eshc123 requested a review from KanuKim97 June 6, 2024 01:37
@eshc123 eshc123 self-assigned this Jun 6, 2024
@eshc123 eshc123 temporarily deployed to Android CI/CD June 6, 2024 01:37 — with GitHub Actions Inactive
Copy link
Collaborator

@KanuKim97 KanuKim97 left a comment

Choose a reason for hiding this comment

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

👍

@KanuKim97 KanuKim97 merged commit 98e6650 into dev Jun 8, 2024
1 check passed
@eshc123 eshc123 deleted the refactor/refac-data-class-get-method branch June 10, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants