Skip to content

Conversation

@dilijev
Copy link
Owner

@dilijev dilijev commented Sep 23, 2017

No description provided.

@dilijev
Copy link
Owner Author

dilijev commented Sep 23, 2017

Copy link

@jackhorton jackhorton left a 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()

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?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good point.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done

}

cleanup:
delete[] inputLangTagUtf8;

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?

Copy link
Owner Author

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.

Copy link
Owner Author

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

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.

Copy link
Owner Author

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.

Copy link
Owner Author

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;

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.

Copy link
Owner Author

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.

Copy link
Owner Author

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;

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?

Copy link
Owner Author

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.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done

jackhorton and others added 22 commits September 25, 2017 15:35
@dilijev dilijev force-pushed the intl-numfmt branch 6 times, most recently from 6853614 to ff11be2 Compare September 26, 2017 00:17
@dilijev dilijev force-pushed the intl-numfmt branch 8 times, most recently from 9b72065 to 5d00291 Compare September 26, 2017 07:10
@dilijev
Copy link
Owner Author

dilijev commented Sep 26, 2017

See chakra-core#3809

@dilijev dilijev closed this Sep 26, 2017
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