-
Notifications
You must be signed in to change notification settings - Fork 1
WIP Intl numfmt #4
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
Conversation
jackhorton
left a comment
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.
Just some lazy sunday nitpicking
| set(PL_SOURCE_FILES ${PL_SOURCE_FILES} | ||
| Common/Intl.cpp | ||
| ) | ||
| endif() |
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.
Not that we use CMake on Windows, but is there any other reason for OS-guarding this?
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.
Good point.
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.
Done
| } | ||
|
|
||
| cleanup: | ||
| delete[] inputLangTagUtf8; |
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.
I saw that you had an auto string buffer class above, should this just be like a C++ unique_ptr generic class in our common data structures?
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.
Yes that's basically the point, and so we don't take a dependency on the standard library for that simple logic. It might make sense to do this here as well, although the logic here was designed to ensure we clean up on failure.
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.
Done.
| { | ||
| // Allocate memory for the UTF8 output buffer. Need 3 bytes for each (code point + null) to satisfy SAL. | ||
| const size_t inputLangTagUtf8SizeAllocated = AllocSizeMath::Mul(AllocSizeMath::Add(cch, 1), 3); | ||
| // REVIEW (doilij): not perf critical so I used HeapNewArrayZ to zero-out the allocated array |
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.
I remember looking at this code before and it did use HeapNewArrayZ, and while I imagine the change to new was to satisfy the operator new issues you were discussing, this comment and the following assert should probably change.
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.
Yes, this is because we're in a compilation unit that doesn't have knowledge of the various ChakraCore allocators, hence the switch to new/delete. I should probably make the effort to explicitly zero-out these arrays. I'll update the comments.
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.
Done.
| Output::Print(_u("EntryIntl_CurrencyDigits > returning (%d)\n"), minFracDigits); | ||
| #endif | ||
|
|
||
| return minFracDigits; |
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.
The ICU documentation doesn't say anything about deleting the return value of createCurrencyInstance explicitly, but I think http://userguide.icu-project.org/dev/codingguidelines suggests that all of the create* static methods require explicit delete calls.
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.
Yes, you're correct. Good catch.
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.
Done
| { | ||
| icu::UnicodeString result; | ||
|
|
||
| auto *formatterHolder = (PlatformAgnosticIntlObject<icu::NumberFormat> *)formatter; |
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.
It seems like the codebase generally favors reinterpret_cast?
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.
Not so much that it favors (it's also hard to grep for C-style casts) but it is better practice. I'll update.
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.
Done
6853614 to
ff11be2
Compare
9b72065 to
5d00291
Compare
5d00291 to
fee58b8
Compare
|
See chakra-core#3809 |
No description provided.