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 Bug 1403959, part 3 - Manually fix some xpcom/ eslint failures and enable it. r=froydnj 2017-09-28 16:12:52 -07:00
README.html
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 Bug 1412119 - Re-fix mode lines in xpcom. r=erahm 2017-10-26 14:39:00 -04:00
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 Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
nsDependentString.h Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
nsDependentSubstring.cpp Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
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 Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
nsPrintfCString.h Bug 1386103 (part 2, attempt 3) - Convert nsFixed[C]String uses to nsAuto[C]String. r=erahm. 2017-08-09 20:41:40 +10:00
nsPromiseFlatString.cpp Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
nsPromiseFlatString.h Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
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 Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
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 Bug 1410276 - Add a canary field to nsStringBuffer r=bz 2017-11-09 15:17:35 +11:00
nsStringComparator.cpp Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
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 Bug 1403083 - Part 1: Properly disable string functions for invalid char types. r=froydnj 2017-10-03 12:44:44 -07:00
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 Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
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 Bug 1403083 - Part 1: Properly disable string functions for invalid char types. r=froydnj 2017-10-03 12:44:44 -07:00
nsTLiteralString.h Bug 1377351 - Part 5: Add a workaround for gcc 4.9 compiler bug, r=froydnj 2017-10-18 13:00:22 -04:00
nsTPromiseFlatString.cpp Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
nsTPromiseFlatString.h Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
nsTString.cpp Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
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 Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
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 Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink 2017-08-14 14:22:50 -07:00
nsTSubstringTuple.h Bug 1434689 - Part 3: Annotate nsTSubstringTuple as MOZ_TEMPORARY_CLASS. r=froydnj 2018-01-31 15:45:04 -08:00
nsTextFormatter.cpp Bug 1435916 - use a const array in nsTextFormatter::dosprintf; r=tromey 2018-02-14 12:01:36 -05:00
nsTextFormatter.h Bug 1423773 - Part 1: Remove usage of nsStringGlue.h. r=glandium 2017-12-06 16:52:51 -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 Bug 1403506 - Remove nsTFixedString<T>. r=erahm. 2017-09-27 20:19:33 +10:00

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>