Commit bfaa6ef7 authored by Jungshik Shin's avatar Jungshik Shin Committed by Commit Bot

Avoid a double encoding conversion

BUG=None
TEST=test262/intl402/NumberFormat/* , intl/number-format/*

Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: I4fed7c749db1aee390675003d7dfdfea7bb94c7c
Reviewed-on: https://chromium-review.googlesource.com/760042Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Jungshik Shin <jshin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49333}
parent 91497ff8
......@@ -46,12 +46,8 @@
#include "unicode/uloc.h"
#include "unicode/unistr.h"
#include "unicode/unum.h"
#include "unicode/uvernum.h"
#include "unicode/uversion.h"
#if U_ICU_VERSION_MAJOR_NUM >= 59
#include "unicode/char16ptr.h"
#endif
namespace v8 {
namespace internal {
......@@ -481,21 +477,12 @@ RUNTIME_FUNCTION(Runtime_CurrencyDigits) {
CONVERT_ARG_HANDLE_CHECKED(String, currency, 0);
// TODO(littledan): Avoid transcoding the string twice
v8::String::Utf8Value currency_string(v8_isolate,
v8::Utils::ToLocal(currency));
icu::UnicodeString currency_icu =
icu::UnicodeString::fromUTF8(*currency_string);
v8::String::Value currency_string(v8_isolate, v8::Utils::ToLocal(currency));
DisallowHeapAllocation no_gc;
UErrorCode status = U_ZERO_ERROR;
#if U_ICU_VERSION_MAJOR_NUM >= 59
uint32_t fraction_digits = ucurr_getDefaultFractionDigits(
icu::toUCharPtr(currency_icu.getTerminatedBuffer()), &status);
#else
uint32_t fraction_digits = ucurr_getDefaultFractionDigits(
currency_icu.getTerminatedBuffer(), &status);
#endif
reinterpret_cast<const UChar*>(*currency_string), &status);
// For missing currency codes, default to the most common, 2
if (!U_SUCCESS(status)) fraction_digits = 2;
return Smi::FromInt(fraction_digits);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment