-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Issue 1455 pre generate strings for months #1456
Issue 1455 pre generate strings for months #1456
Conversation
On reviewing the code I was focussed on I figured I could add a couple of slices and then simplify some the code around getting month name abbreviations. At this point I thought I'd get some input, in case you want to go a different way? Or, if you like this approach if you want to implement for all languages I could go ahead and do that. Either way, it seemed worth getting some feedback before going any further.
There were finctions where we do not need to convert to rune and then to string. Removing these casts prevents things escaping to the heap
@xuri I spotted some commented out code I'd left behind. I tidied this up in the most recent push. Hopefully this is looking good now, let me know what you think |
Codecov Report
@@ Coverage Diff @@
## master #1456 +/- ##
=======================================
Coverage 98.61% 98.61%
=======================================
Files 31 31
Lines 24015 24026 +11
=======================================
+ Hits 23682 23693 +11
Misses 220 220
Partials 113 113
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. This is a good way to improve performance, I think we can implement it for all languages.
…ormat (qax-os#1456) - Reducing string concatenation and string conversion between rune string data types Co-authored-by: Nathan Davies <[email protected]>
…ormat (qax-os#1456) - Reducing string concatenation and string conversion between rune string data types Co-authored-by: Nathan Davies <[email protected]>
On reviewing the code I was focussed on I figured I could add a couple of slices and then simplify some the code around getting month name abbreviations. At this point I thought I'd get some input, in case you want to go a different way? Or, if you like this approach if you want to implement for all languages I could go ahead and do that.
I have also removed some of the unnecessary
string([]rune(...
casts that were in place. Doing this prevents these tings from escaping to the heapEither way, it seemed worth getting some feedback before going any further.
Description
As an example of the proposed change I've introduced a couple of month abbreviation slices and shown how these could be used to simplify their corresponding functions. The existing tests already cover this code and continue to pass.
Related Issue
issue-1455
Motivation and Context
This is an attempt to reduce the memory needed by these language functions that have string concatenation involved.
How Has This Been Tested
The existing tests cover this code and they continue to pass. I do not think extra tests are needed here. Since adding these changes I can see, via
go build -gcflags="-m -l"
, that there is less that escapes to the heap.Types of changes
Checklist