Closed
Bug 1447017
Opened 6 years ago
Closed 6 years ago
Resize char-vector to input string length for String.prototype.toLocale{Lower,Upper}Case
Categories
(Core :: JavaScript: Internationalization API, enhancement, P2)
Core
JavaScript: Internationalization API
Tracking
()
RESOLVED
FIXED
mozilla61
Tracking | Status | |
---|---|---|
firefox61 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
Details
Attachments
(1 file, 1 obsolete file)
3.67 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
To minimize calls to ICU, the chars-vector should be resized to |Max(vector-inline-capacity, string-length)| before calling u_strToLower/u_strToUpper.
Assignee | ||
Comment 1•6 years ago
|
||
The input string length is a better approximation for the final string length than the vector's inline capacity and it helps to reduce extra calls to ICU for large strings.
Attachment #8960184 -
Flags: review?(jwalden+bmo)
Comment 2•6 years ago
|
||
Comment on attachment 8960184 [details] [diff] [review] bug1447017.patch Review of attachment 8960184 [details] [diff] [review]: ----------------------------------------------------------------- It'd be nice eventually to have this not perform a copy if data exceeds on-stack length, a la StringBuffer::finishString, but good enough for now.
Attachment #8960184 -
Flags: review?(jwalden+bmo) → review+
Comment 3•6 years ago
|
||
Comment on attachment 8960184 [details] [diff] [review] bug1447017.patch Review of attachment 8960184 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/builtin/String.cpp @@ +1058,5 @@ > // Maximum case mapping length is three characters. > static_assert(JSString::MAX_LENGTH < INT32_MAX / 3, > "Case conversion doesn't overflow int32_t indices"); > > + static const size_t INLINE_CAPACITY = 32; Actually, use js::intl::INITIAL_CHAR_BUFFER_SIZE for this.
Updated•6 years ago
|
Priority: -- → P2
Assignee | ||
Comment 4•6 years ago
|
||
Updated to use js::intl::INITIAL_CHAR_BUFFER_SIZE per review comments. Carrying r+.
Attachment #8960184 -
Attachment is obsolete: true
Attachment #8960973 -
Flags: review+
Assignee | ||
Comment 5•6 years ago
|
||
(In reply to Jeff Walden [:Waldo] from comment #2) > Comment on attachment 8960184 [details] [diff] [review] > bug1447017.patch > > Review of attachment 8960184 [details] [diff] [review]: > ----------------------------------------------------------------- > > It'd be nice eventually to have this not perform a copy if data exceeds > on-stack length, a la StringBuffer::finishString, but good enough for now. Yes, there are unnecessary copies in both directions (when the input has two-byte, inline characters and when creating the output string). Maybe I'll take a look after ICU61 lands, because that'll include https://ssl.icu-project.org/trac/ticket/12647.
Assignee | ||
Comment 6•6 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=fda78b7e464578358e20764819cee47cb68ccdd7
Keywords: checkin-needed
Pushed by apavel@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/6d8ff008a2e6 Resize char-vector to input string length for String.prototype.toLocale{Lower,Upper}Case. r=Waldo
Keywords: checkin-needed
Comment 8•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/6d8ff008a2e6
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in
before you can comment on or make changes to this bug.
Description
•