Skip to content

Modify the usage of ecma_string_to_utf8_string() #1119

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

Merged

Conversation

bzsolt
Copy link
Member

@bzsolt bzsolt commented Jun 2, 2016

Parts:

  • The functions return value mostly used in assertion, but this value
    is already checked by the function itself, therefore we can remove some
    local variables, which serves this purpose.
  • Remove the 'should use return value' requirement for this function
    and remove the attribute itself, because it became unused in the project.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com

@bzsolt bzsolt added enhancement An improvement style Related to coding style labels Jun 2, 2016
@@ -674,7 +671,7 @@ ecma_string_get_array_index (const ecma_string_t *str_p, /**< ecma-string */
*
* @return number of bytes, actually copied to the buffer.
*/
lit_utf8_size_t __attr_return_value_should_be_checked___
lit_utf8_size_t
Copy link
Member

Choose a reason for hiding this comment

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

Do we use the return value anywhere?

@bzsolt bzsolt force-pushed the modify-string-to-utf8-string branch from 6854ef8 to dcdf698 Compare June 8, 2016 13:21
@bzsolt
Copy link
Member Author

bzsolt commented Jun 8, 2016

Thanks for the reviews, I've updated the PR.

* (can be NULL if buffer_size == 0) */
lit_utf8_size_t buffer_size) /**< size of buffer */
{
JERRY_ASSERT (ecma_string_get_size (string_desc_p) == buffer_size);
Copy link
Member

Choose a reason for hiding this comment

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

I think this assert is unnecessary, since the <= is checked by ecma_string_copy_to_utf8_buffer and size == buffer_size checks the equality.

@zherczeg
Copy link
Member

zherczeg commented Jun 8, 2016

LGTM after that

@bzsolt bzsolt force-pushed the modify-string-to-utf8-string branch from dcdf698 to 4a2f9d5 Compare June 8, 2016 13:35
@zherczeg
Copy link
Member

LGTM

1 similar comment
@LaszloLango
Copy link
Contributor

LGTM

Parts:
 * Rename ecma_string_to_utf8_string() to ecma_string_copy_to_utf8_buffer.

 * Introduce ecma_string_to_utf8_bytes(), which wraps the usual 'function call-assertion' pair,
   and check strict equality of size of the string and the buffer.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
@bzsolt bzsolt force-pushed the modify-string-to-utf8-string branch from 4a2f9d5 to c557a0a Compare June 13, 2016 13:26
@bzsolt bzsolt merged commit c557a0a into jerryscript-project:master Jun 13, 2016
@bzsolt bzsolt deleted the modify-string-to-utf8-string branch June 14, 2016 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement style Related to coding style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants