Storing Number as UInt32 in ecma-string if the Number may be represented as UInt32. Calculating length for Number-represented ecma-strings in ecma-string constructor. loop_arithmetics_1kk.js: 2.9112 -> 2.8536.
This commit is contained in:
@@ -57,23 +57,29 @@ ecma_zt_string_to_number (const ecma_char_t *str_p) /**< zero-terminated string
|
||||
|
||||
/**
|
||||
* ECMA-defined conversion of UInt32 to String (zero-terminated).
|
||||
*
|
||||
* @return number of bytes copied to buffer
|
||||
*/
|
||||
void
|
||||
ecma_length_t
|
||||
ecma_uint32_to_string (uint32_t value, /**< value to convert */
|
||||
ecma_char_t *out_buffer_p, /**< buffer for zero-terminated string */
|
||||
size_t buffer_size) /**< size of buffer */
|
||||
ssize_t buffer_size) /**< size of buffer */
|
||||
{
|
||||
FIXME (Implement according to ECMA);
|
||||
|
||||
ecma_char_t *p = (ecma_char_t*) ((uint8_t*) out_buffer_p + buffer_size) - 1;
|
||||
*p-- = '\0';
|
||||
|
||||
ecma_length_t bytes_copied = 1;
|
||||
|
||||
do
|
||||
{
|
||||
JERRY_ASSERT (p != out_buffer_p);
|
||||
|
||||
*p-- = (ecma_char_t) ("0123456789"[value % 10]);
|
||||
value /= 10;
|
||||
|
||||
bytes_copied++;
|
||||
}
|
||||
while (value != 0);
|
||||
|
||||
@@ -82,6 +88,8 @@ ecma_uint32_to_string (uint32_t value, /**< value to convert */
|
||||
ssize_t bytes_to_move = ((uint8_t*) out_buffer_p + buffer_size) - (uint8_t*) p;
|
||||
__memmove (out_buffer_p, p, (size_t) bytes_to_move);
|
||||
}
|
||||
|
||||
return bytes_copied;
|
||||
} /* ecma_uint32_to_string */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user