Skip to content

feat: Convert Carbon Object To Pointer #278

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

Merged
merged 3 commits into from
Feb 26, 2025

Conversation

ahmed3mar
Copy link

As per this issue #249 makes bundle size large because each call creates a new Carbon object

This pull request includes changes to the Carbon package to modify methods and tests to use pointer receivers instead of value receivers. This change ensures that any modifications within these methods directly affect the original Carbon instance, improving performance and consistency.

Changes to method signatures:

  • Updated boundary.go to change method receivers from value to pointer for methods like StartOfCentury, EndOfCentury, StartOfDecade, EndOfDecade, StartOfYear, EndOfYear, StartOfQuarter, EndOfQuarter, StartOfMonth, EndOfMonth, StartOfWeek, EndOfWeek, StartOfDay, EndOfDay, StartOfHour, EndOfHour, StartOfMinute, EndOfMinute, StartOfSecond, and EndOfSecond. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

Changes to unit tests:

  • Updated boundary_unit_test.go to change the carbon field in test structs from value to pointer for test functions like TestCarbon_StartOfCentury, TestCarbon_EndOfCentury, TestCarbon_StartOfDecade, TestCarbon_EndOfDecade, TestCarbon_StartOfYear, TestCarbon_EndOfYear, TestCarbon_StartOfQuarter, TestCarbon_EndOfQuarter, TestCarbon_StartOfMonth, TestCarbon_EndOfMonth, TestCarbon_StartOfWeek, TestCarbon_EndOfWeek, TestCarbon_StartOfDay, TestCarbon_EndOfDay, TestCarbon_StartOfHour, TestCarbon_EndOfHour, TestCarbon_StartOfMinute, TestCarbon_EndOfMinute, TestCarbon_StartOfSecond, and TestCarbon_EndOfSecond. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

Changes to calendar.go:

  • Updated methods in calendar.go to use pointer receivers for Lunar, Julian, and Persian conversions, and changed the return type of CreateFromLunar and CreateFromJulian to pointers. [1] [2]

@kuafuRace
Copy link
Collaborator

Destructive changes can only be made in version v3

@ahmed3mar
Copy link
Author

@gouguoyin no problem feel free to update or create new version with it

@kuafuRace kuafuRace changed the base branch from master to v2.6.x February 26, 2025 18:51
@kuafuRace kuafuRace deleted the branch dromara:v2.6.x February 26, 2025 19:00
@kuafuRace kuafuRace closed this Feb 26, 2025
@kuafuRace kuafuRace reopened this Feb 26, 2025
@kuafuRace kuafuRace merged commit a7c2a12 into dromara:v2.6.x Feb 26, 2025
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.

2 participants