Skip to content

Commit cdc7238

Browse files
committed
Avoid copying string in parseNumberLiteral()
1 parent 1f96296 commit cdc7238

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: icu4c/source/i18n/messageformat2_function_registry.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,10 @@ static double parseNumberLiteral(const FormattedPlaceholder& input, UErrorCode&
453453
using namespace double_conversion;
454454
int processedCharactersCount = 0;
455455
StringToDoubleConverter converter(0, 0, 0, "", "");
456-
LocalArray<char> target(new char(len + 1));
457-
int32_t bufferLen = inputStr.extract(0, len, target.getAlias());
458-
U_ASSERT(bufferLen == len);
459-
double result = converter.StringToDouble(target.getAlias(),
460-
bufferLen,
461-
&processedCharactersCount);
456+
double result =
457+
converter.StringToDouble(reinterpret_cast<const uint16_t*>(inputStr.getBuffer()),
458+
len,
459+
&processedCharactersCount);
462460
if (processedCharactersCount != len) {
463461
errorCode = U_MF_OPERAND_MISMATCH_ERROR;
464462
}

0 commit comments

Comments
 (0)