-
Notifications
You must be signed in to change notification settings - Fork 687
Implement TrimStart TrimEnd and aliases #4102
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
Conversation
jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.inc.h
Outdated
Show resolved
Hide resolved
7c925fd to
c183a90
Compare
jerry-core/ecma/base/ecma-helpers.h
Outdated
| ECMA_TRIM_STRING_START = (1u << 0), /**< Trim only from the start */ | ||
| ECMA_TRIM_STRING_END = (1u << 1), /**< Trim only from the end */ | ||
| ECMA_TRIM_STRING_STARTEND = (1u << 2), /**< Trim from both start and end */ | ||
| } ecma_string_trim_flags_t; |
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.
No need for these, just call ecma_string_trim_front/ecma_string_trim_back where necessary, and change ecma_string_trim_helper to call both, and be always inline.
7706e95 to
bb4cf69
Compare
jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.inc.h
Outdated
Show resolved
Hide resolved
0765ed3 to
6e4415b
Compare
rerobika
left a comment
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.
LGTM
| * - ecma_builtin_global_object_parse_int | ||
| * - ecma_builtin_global_object_parse_float |
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.
parseInt and parseFloat should only use trimStart by spec
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.
This is a nice catch i did not look into. Although roughly looking at them this should not alter as the code checks for digits when iterating and in the end, the ecma_utf8_string_to_number call the whole trim in itself as well. I'm looking into our test suites to check for fails if i modify this.
Based on: https://tc39.es/ecma262/#sec-string.prototype.trim JerryScript-DCO-1.0-Signed-off-by: Bela Toth [email protected]
dbatyai
left a comment
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.
LGTM
Based on: https://tc39.es/ecma262/#sec-string.prototype.trim
JerryScript-DCO-1.0-Signed-off-by: Bela Toth [email protected]