gecko-dev/xpcom/string
Henri Sivonen 3edc601325 Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj.
Correctness improvements:

 * UTF errors are handled safely per spec instead of dangerously truncating
   strings.

 * There are fewer converter implementations.

Performance improvements:

 * The old code did exact buffer length math, which meant doing UTF math twice
   on each input string (once for length calculation and another time for
   conversion). Exact length math is more complicated when handling errors
   properly, which the old code didn't do. The new code does UTF math on the
   string content only once (when converting) but risks allocating more than
   once. There are heuristics in place to lower the probability of
   reallocation in cases where the double math avoidance isn't enough of a
   saving to absorb an allocation and memcpy.

 * Previously, in UTF-16 <-> UTF-8 conversions, an ASCII prefix was optimized
   but a single non-ASCII code point pessimized the rest of the string. The
   new code tries to get back on the fast ASCII path.

 * UTF-16 to Latin1 conversion guarantees less about handling of out-of-range
   input to eliminate an operation from the inner loop on x86/x86_64.

 * When assigning to a pre-existing string, the new code tries to reuse the
   old buffer instead of first releasing the old buffer and then allocating a
   new one.

 * When reallocating from the new code, the memcpy covers only the data that
   is part of the logical length of the old string instead of memcpying the
   whole capacity. (For old callers old excess memcpy behavior is preserved
   due to bogus callers. See bug 1472113.)

 * UTF-8 strings in XPConnect that are in the Latin1 range are passed to
   SpiderMonkey as Latin1.

New features:

 * Conversion between UTF-8 and Latin1 is added in order to enable faster
   future interop between Rust code (or otherwise UTF-8-using code) and text
   node and SpiderMonkey code that uses Latin1.

MozReview-Commit-ID: JaJuExfILM9
2018-08-14 14:43:42 +03:00
..
crashtests
moz.build Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj. 2018-08-14 14:43:42 +03:00
nsASCIIMask.cpp
nsASCIIMask.h Bug 1434710 - Replaced all instances of mozilla::IndexSequence, mozilla::MakeIndexSequence and mozilla::IndexSequenceFor with std::index_sequence, std::make_index_sequence and std::index_sequence_for and removed mfbt/IndexSequence.h. r=botond 2018-04-09 21:12:13 +10:00
nsAString.h Bug 1434789 - Part 2: Remove nsSubstringTuple aliases. r=froydnj 2018-01-31 16:45:34 -08:00
nsCharTraits.h Bug 1426898 - Stop including Char16.h everywhere. r=Waldo 2017-12-23 00:53:12 +09:00
nsDependentString.cpp
nsDependentString.h
nsDependentSubstring.cpp
nsDependentSubstring.h Bug 1435924 - Part 1: Switch from nsSubstring.h to nsAString.h. r=dbaron 2018-02-05 17:36:32 -08:00
nsLiteralString.h
nsPrintfCString.h
nsPromiseFlatString.cpp
nsPromiseFlatString.h
nsReadableUtils.cpp Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj. 2018-08-14 14:43:42 +03:00
nsReadableUtils.h Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj. 2018-08-14 14:43:42 +03:00
nsString.cpp
nsString.h Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj. 2018-08-14 14:43:42 +03:00
nsStringBuffer.h
nsStringComparator.cpp
nsStringFlags.h Bug 1448138 - Rename string DataFlags::SHARED to REFCOUNTED to make it clearer to those reading the code. r=erahm 2018-03-23 17:31:37 -07:00
nsStringFwd.h Bug 1399789 - nsSubstringSplitter/nsCSubstringSplitter is not defined anymore; r=erahm 2018-08-09 14:18:22 +02:00
nsStringIterator.h Bug 1453795 - XPCom/String - Initialize member fields in classes/ structures. r=froydnj 2018-06-14 13:57:45 +03:00
nsStringObsolete.cpp
nsSubstring.cpp Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj. 2018-08-14 14:43:42 +03:00
nsTDependentString.cpp
nsTDependentString.h Bug 1431261 - Add nsTDependentString copy constructor. r=dbaron 2018-01-18 14:16:19 -08:00
nsTDependentSubstring.cpp Bug 1426898 - Stop including Char16.h everywhere. r=Waldo 2017-12-23 00:53:12 +09:00
nsTDependentSubstring.h
nsTextFormatter.cpp Bug 1435916 - use a const array in nsTextFormatter::dosprintf; r=tromey 2018-02-14 12:01:36 -05:00
nsTextFormatter.h
nsTLiteralString.h
nsTPromiseFlatString.cpp
nsTPromiseFlatString.h
nsTString.cpp
nsTString.h Bug 1481097 - xpcom: Remove nsTString literal string workaround for gcc 4.9 bug. r=nika 2018-07-22 00:02:34 -07:00
nsTStringComparator.cpp
nsTStringObsolete.cpp Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj. 2018-08-14 14:43:42 +03:00
nsTStringRepr.h Bug 1481097 - xpcom: Remove nsTString literal string workaround for gcc 4.9 bug. r=nika 2018-07-22 00:02:34 -07:00
nsTSubstring.cpp Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj. 2018-08-14 14:43:42 +03:00
nsTSubstring.h Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj. 2018-08-14 14:43:42 +03:00
nsTSubstringTuple.cpp
nsTSubstringTuple.h Bug 1434689 - Part 3: Annotate nsTSubstringTuple as MOZ_TEMPORARY_CLASS. r=froydnj 2018-01-31 15:45:04 -08:00
nsUTF8Utils.h Bug 1402247 - Use encoding_rs for XPCOM string encoding conversions. r=Nika,erahm,froydnj. 2018-08-14 14:43:42 +03:00
precompiled_templates.cpp
README.html

<html>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<body>
  <h1><span class="LXRSHORTDESC">managing sequences of characters</span></h1>
<p>
  <span class="LXRLONGDESC"></span>
</p>
</body>
</html>