Closed Bug 1473337 Opened 6 years ago Closed 6 years ago

Omit ASCII-case length calculation for short strings when performing an encoding conversion that expands non-ASCII

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

Attachments

(1 file)

(Follow-up for bug 1402247.) For conversions like UTF-16 to UTF-8, which expand the number of code units in the non-ASCII case, avoid trying to size the buffer for the ASCII case when: 1) the target string is an autostring and the worst case fits within the inline buffer. 2) when the target string is not an autostring but the input string is 64 or fewer code units in length.
Assignee: nobody → hsivonen
Status: NEW → ASSIGNED
Comment on attachment 8990253 [details] Bug 1473337 - Omit ASCII-case length calculation for short strings when performing an encoding conversion that expands non-ASCII. https://reviewboard.mozilla.org/r/255290/#review264138 ::: servo/support/gecko/nsstring/src/conversions.rs:124 (Diff revision 1) > let mut handle = unsafe { > self.bulk_write(old_len.checked_add(needed).ok_or(())?, old_len, false)? > }; > let written = $convert(other, &mut handle.as_mut_slice()[old_len..]); > - Ok(handle.finish(old_len + written, true)) > + let new_len = old_len + written; > + Ok(handle.finish(new_len, new_len > 64)) is this "64" supposed to be the cache line? can we use a constant here? ::: servo/support/gecko/nsstring/src/conversions.rs:333 (Diff revision 1) > + None > + } > + } else { > + None > + }; > + let (filled, num_ascii, mut handle) = if worst_case_needed.is_none() && long_string_stars_with_basic_latin(other) { nit: long line this might actually be clearer with uninitialized let statements above, and assignments into them rather than the tuple return values...
Attachment #8990253 - Flags: review?(nika) → review+
Comment on attachment 8990253 [details] Bug 1473337 - Omit ASCII-case length calculation for short strings when performing an encoding conversion that expands non-ASCII. https://reviewboard.mozilla.org/r/255290/#review264138 Thanks! > is this "64" supposed to be the cache line? can we use a constant here? Used constant. > nit: long line > > this might actually be clearer with uninitialized let statements above, and assignments into them rather than the tuple return values... Wrapped.
Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1e0dffecbfb0 Omit ASCII-case length calculation for short strings when performing an encoding conversion that expands non-ASCII. r=Nika
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: