-
Notifications
You must be signed in to change notification settings - Fork 683
Remove unnecessary variable length arrays. #851
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
Remove unnecessary variable length arrays. #851
Conversation
The What about factoring the clones out into a helper function and using: const uint32_t nums_with_ascending_length[] = { ... };
const uint32_t max_uint32_len = sizeof(nums_with_ascending_length) / sizeof(uint32_t); This would avoid multiplication. BTW, while we are at the refactoring of these functions: the switch/case in BTW2, the implementation of the |
e8c60b5
to
1f0ed97
Compare
Thanks the comments, I've updated this PR. |
1f0ed97
to
c2b3be4
Compare
@@ -1286,6 +1286,42 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma- | |||
} /* ecma_compare_ecma_strings_relational */ | |||
|
|||
/** | |||
* Lengths for numeric string values | |||
*/ | |||
const uint32_t nums_with_ascending_length[] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be static
c2b3be4
to
7daabb3
Compare
Thanks again, I've fixed this based on your suggestions. |
* @return size in bytes | ||
*/ | ||
static ecma_length_t | ||
ecma_string_get_number_in_desc_size (const uint32_t uint32_number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment on argument.
moreover, I'd swap the order of these two new helper functions to get this one closer to the data it uses (nums_with_ascending_length
and max_uint32_len
).
7daabb3
to
0faaaa8
Compare
Fixed. |
LGTM (informally) |
@robertsipka, Could you measure this patch on RPi2 or at least on your own PC? @bzsolt, can you help with the measurement on RPi2? We have to be careful when refactoring these functions, because they are called really often. |
The RPi2 results with run-perf-test.sh
|
Could you try how the performance change if you make the |
Of course, the results are here:
|
@bzsolt, looks better. |
0faaaa8
to
fbcda55
Compare
@bzsolt @LaszloLango : thanks, fixed. |
LGTM |
@robertsipka, precommit failed. Please fix it. |
… array. VLAs cannot be initialized by any form of initialization syntax with C99 standard. Also did some refactor around 'ecma_string_get_length' and 'ecma_string_get_size'. JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
fbcda55
to
88d7f2f
Compare
@LaszloLango : There is no error with gcc 4.9.2. I checked with gcc 4.8.4, and the fail was occurred. I've fixed it, thanks! |
VLAs cannot be initialized by any form of initialization syntax with C99 standard.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com