Commit Graph
1603 Commits
Author SHA1 Message Date
Sylvestre Ledru a3ea006705 Bug 1519636 - Reformat recent changes to the Google coding style r=emilio,necko-reviewers,geckoview-reviewers,application-update-reviewers,media-playback-reviewers,devtools-reviewers,anti-tracking-reviewers,profiler-reviewers,win-reviewers,migration-reviewers,padenot,mconley,nchevobbe,kershaw,gstoll,mstange,bytesized,m_kato
This new version of clang 17 also slightly changed the formatting.

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D215914
2024-07-17 11:15:31 +00:00
whale 55a9e5c0d4 Bug 1768758 - Add Windows-specific function getW() for getting wchar_t r=xpcom-reviewers,win-reviewers,gstoll,nika
`char16_t` and `wchar_t` are functionally the same on Windows. But logging statements do not handle `char16_t` very well, resulting in the need to static cast to `wchar_t`. For more info, see [[ https://bugzilla.mozilla.org/show_bug.cgi?id=1768758 | bug task ]]:

This diff introduces a Windows-specific function for getting strings as `wchar_t` and replaces previous workaround usages.

Differential Revision: https://phabricator.services.mozilla.com/D215869
2024-07-10 22:10:56 +00:00
Jan de Mooij 231af49bcf Bug 1903037 part 3 - Replace DOMStringExternalString with JS strings that use StringBuffer directly. r=emilio,sfink
Because the JS engine now increments the refcount itself, we can also simplify
the code a bit.

This patch removes `DOMString::RelinquishBufferOwnership` and `nsTSubstring::ForgetSharedBuffer`
because it's hard to make that optimization work with the new system.

Differential Revision: https://phabricator.services.mozilla.com/D213970
2024-06-26 11:03:17 +00:00
Stanca Serban f7e1083c9c Backed out 4 changesets (bug 1903037) for causing build bustages. CLOSED TREE
Backed out changeset 0d0174720ea5 (bug 1903037)
Backed out changeset 83b91e964b76 (bug 1903037)
Backed out changeset 2bce31088d18 (bug 1903037)
Backed out changeset cef762ba8c2c (bug 1903037)
2024-06-25 18:33:38 +03:00
Jan de Mooij 1f44e633fc Bug 1903037 part 3 - Replace DOMStringExternalString with JS strings that use StringBuffer directly. r=emilio,sfink
Because the JS engine now increments the refcount itself, we can also simplify
the code a bit.

This patch removes `DOMString::RelinquishBufferOwnership` and `nsTSubstring::ForgetSharedBuffer`
because it's hard to make that optimization work with the new system.

Differential Revision: https://phabricator.services.mozilla.com/D213970
2024-06-25 11:37:04 +00:00
Emilio Cobos Álvarez 681fce82c2 Bug 1897607 - Inline StringBuffer assignment. r=smaug
I wrote this while investigating bug 1896729. It seems it didn't help
with those, but helps with other micro-benchmarks (plus it's not a lot
of code so seems worth inlining):

https://treeherder.mozilla.org/perfherder/comparesubtest?originalProject=try&newProject=try&newRevision=27ba5b2ad99b0e7dc5af443ee21f0f227f9a7589&originalSignature=4765498&newSignature=4765498&framework=1&application=firefox&originalRevision=63f02a17fab2cf51723bc45088c76a5ecde37af9&page=1&showOnlyImportant=1

Differential Revision: https://phabricator.services.mozilla.com/D210876
2024-05-18 17:33:20 +00:00
Emilio Cobos Álvarez 2808374848 Bug 1892257 - Move nsStringBuffer to mfbt. r=nika,xpcom-reviewers,glandium
Inline Create() and Realloc() so that we don't get negative leaks, since
were that code end up in mozglue, it wouldn't have access to the logging
machinery.

Differential Revision: https://phabricator.services.mozilla.com/D209663
2024-05-14 14:24:26 +00:00
Emilio Cobos Álvarez 85ab2ab799 Bug 1893683 - Remove ns{A,C}String and other xpcom dependencies from nsStringBuffer. r=smaug,media-playback-reviewers,karlt
* nsStringBuffer::FromString -> nsTSubString::GetStringBuffer
 * nsStringBuffer::ToString -> nsTSubString::Assign(nsStringBuffer*, len)
 * Move refcounting inline but refcount-logging and other XPCOM-related
   things out-of-line.

Differential Revision: https://phabricator.services.mozilla.com/D208771
2024-05-09 08:34:35 +00:00
Emilio Cobos Álvarez 2cbcf465b5 Bug 1895346 - Drop nsStringStats. r=nika,xpcom-reviewers
As per the discussion in D208771, they don't bring much value so seems
worth doing this first.

Differential Revision: https://phabricator.services.mozilla.com/D209580
2024-05-07 07:44:15 +00:00
Jeff Muizelaar c4f837226d Bug 1894077 - Fix subsystem id parsing. r=xpcom-reviewers,emilio
Previously if the we got a subsystem id like 87731043 we would
fail to parse it because it's too big to fit in int32_t.

This adds a ToUnsignedInteger helper that lets us parse
the large subsystem ids.

Differential Revision: https://phabricator.services.mozilla.com/D208931
2024-04-30 16:29:55 +00:00
Emilio Cobos Álvarez 7c72f3b30c Bug 1893668 - Make string stats more obviously debug-only. r=xpcom-reviewers,mccr8
Also, make them relaxed atomic. Sequentially consistent atomics might
help paper concurrency issues in debug builds, and there's really no
good reason these counts need to be sequentially consistent.

Differential Revision: https://phabricator.services.mozilla.com/D208759
2024-04-26 17:25:51 +00:00
Ray Kraesig 286effabaf Bug 1891541 - [2/2] enforce that MozPromise only accepts static strings r=xpcom-reviewers,media-playback-reviewers,padenot,emilio
All present uses of the call-site arguments to MozPromise's methods
supply static strings. However, this is nowhere enforced. Do so.

Additionally, since this is the third or fourth time the present author
alone has personally implemented such an enforcement mechanism, create a
helper class to simplify doing so.

No functional changes.

Differential Revision: https://phabricator.services.mozilla.com/D207462
2024-04-24 17:02:49 +00:00
Chris Peterson 60c018c1c7 Bug 1880008 - Add char8_t string overloads to MFBT string functions when compiling with -std=c++20. r=xpcom-reviewers,emilio
When compiled with -std=c++17, u8"" string literals have type `const char[]`. When compiled with -std=c++20, u8"" string literals have type `const char8_t[]`. This patch adds the minimum char8_t overloads needed to compile Firefox with -std=c++20. If we want to use char8_t in more code or replace `Utf8Unit` with char8_t, that will require an extensive redesign of MFBT's and xpcom's string classes after we update from -std=c++17 to c++20.

Differential Revision: https://phabricator.services.mozilla.com/D201672
2024-02-14 01:33:31 +00:00
Emilio Cobos Álvarez 9321e08b29 Bug 1878108 - Replace custom MOZ_LIFETIME_BOUND with built-in. r=nika,glandium
The built-in version is better as it also allows annotating particular
parameters (it not only applies to method declarations).

Differential Revision: https://phabricator.services.mozilla.com/D200432
2024-02-06 13:00:39 +00:00
pstanciu 96b629a0ed Backed out 2 changesets (bug 1878108) for causing sm bustages in Attributes.h. CLOSED TREE
Backed out changeset 05e2d2bc1260 (bug 1878108)
Backed out changeset bb356c39c0e2 (bug 1878108)
2024-02-06 13:11:26 +02:00
Emilio Cobos Álvarez 2e9c76fa56 Bug 1878108 - Replace custom MOZ_LIFETIME_BOUND with built-in. r=nika,glandium
The built-in version is better as it also allows annotating particular
parameters (it not only applies to method declarations).

Differential Revision: https://phabricator.services.mozilla.com/D200432
2024-02-06 08:51:50 +00:00
Daniel Holbert e6e94fd050 Bug 1876233: Mark nsTPromiseFlatString as a stack-only class. r=nika
No functional change.  This class is only meant to be instantiated as a
temporary object, and this annotation helps enforce that.

Differential Revision: https://phabricator.services.mozilla.com/D199561
2024-01-25 06:54:09 +00:00
Daniel Holbert 327ffb65fe Bug 1876233: Delete nsTPromiseFlatString's copy-constructor, to avoid clang -Wdeprecated-copy warning. r=nika
Reasons:
- The copy-constructor is never actually used.
- We already explicitly delete the reassignment operator for this class, which
  suggests this class is not really designed to be copied.
- There's not really any good reason for us to make copies of instances of this
  class, since this class is just meant to be a lightweight temporary wrapper
  to be used only-when-needed, and only at API boundaries to external or legacy
  functions.
- When the copy-constructor was used, it triggered a clang
  `-Wdeprecated-copy` build warning, for using the default copy constructor
  when the reassignment operator was non-default (explicitly deleted).

Differential Revision: https://phabricator.services.mozilla.com/D199383
2024-01-25 06:54:09 +00:00
Antoine 6033ed639a Bug 1857751 - nsTSubstring.cpp: Do not use 'else' after 'return'. r=sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D191019
2023-10-15 21:26:26 +00:00
Jan Varga 272327b326 Bug 1855134 - Move existing MOZ_TRY macros to a dedicated header file; r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D189226
2023-09-28 20:46:07 +00:00
Emilio Cobos Álvarez 87502f6d28 Bug 1854446 - Make dynamic atoms store an nsStringBuffer. r=smaug,xpcom-reviewers,nika
Performance results pending, but this shouldn't hurt utf-8 atomization
at all, and it should also make utf-16 atomization potentially cheaper.

So sending for review under the assumption that perf numbers will look
good.

Differential Revision: https://phabricator.services.mozilla.com/D189021
2023-09-27 09:06:06 +00:00
Natalia Csoregi 41db90ff0d Backed out changeset 65f49a810f52 (bug 1854446) for causing multiple failures e.g. 368504-4.html. CLOSED TREE 2023-09-27 03:26:28 +03:00
Emilio Cobos Álvarez ec22dc8416 Bug 1854446 - Make dynamic atoms store an nsStringBuffer. r=smaug,xpcom-reviewers,nika
Performance results pending, but this shouldn't hurt utf-8 atomization
at all, and it should also make utf-16 atomization potentially cheaper.

So sending for review under the assumption that perf numbers will look
good.

Differential Revision: https://phabricator.services.mozilla.com/D189021
2023-09-26 23:14:14 +00:00
Andrew McCreight f7109d8ff1 Bug 1840959 - Log destruction before it is freed in ReleaseData. r=emilio
We don't dereference aData, so this is safe in some sense, but
GCC 12 complains about a use-after-free here. In theory, some other
thread could reallocate an object at the same address before
the MOZ_LOG_DTOR call and confuse the leak logging if it is set
to track individual objects, but I don't think that's a realistic
issue.

Differential Revision: https://phabricator.services.mozilla.com/D183508
2023-07-13 15:04:00 +00:00
serge-sans-paille 809ac27333 Bug 1834279 - Make nsTLiteralString copy constructor explicit r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D178626
2023-05-29 08:27:54 +00:00
Mark Banner b61a6a6502 Bug 1826063 - Automatic fixes for enabling Prettier on production xhtml and html files. r=mossop,webdriver-reviewers,webcompat-reviewers,geckoview-reviewers,extension-reviewers,settings-reviewers,application-update-reviewers,credential-management-reviewers,fxview-reviewers,sgalich,nalexander,devtools-reviewers,sclements,denschub,robwu,owlish
Differential Revision: https://phabricator.services.mozilla.com/D177938
2023-05-20 12:26:56 +00:00
Andi-Bogdan Postelnicu fccbbc6b44 Bug 1660405 - Move away from mozilla::IsFinite in favor of std::isfinite. r=sergesanspaille
Differential Revision: https://phabricator.services.mozilla.com/D173036
2023-03-22 11:35:33 +00:00
Stanca Serban 98c675ed3f Backed out 7 changesets (bug 1660405) for causing bustages on Linux x64 opt. CLOSED TREE
Backed out changeset ad1a5f59214f (bug 1660405)
Backed out changeset a39e95f0aafe (bug 1660405)
Backed out changeset 48629ee0d70d (bug 1660405)
Backed out changeset 8419b99aab60 (bug 1660405)
Backed out changeset 535cc12c8bed (bug 1660405)
Backed out changeset e27052da4927 (bug 1660405)
Backed out changeset 11b0f9cf8091 (bug 1660405)
2023-03-22 13:05:53 +02:00
Andi-Bogdan Postelnicu 2e64d79ba8 Bug 1660405 - Move away from mozilla::IsFinite in favor of std::isfinite. r=sergesanspaille
Differential Revision: https://phabricator.services.mozilla.com/D173036
2023-03-22 09:27:57 +00:00
ISHIKAWA, Chiaki e02bf0b25f Bug 1732008 - Avoid MOZ_ASSERT in nsTextFormatter.cpp r=xpcom-reviewers,barret
Differential Revision: https://phabricator.services.mozilla.com/D169207
2023-02-08 23:47:23 +00:00
Emilio Cobos Álvarez c2a2db7a69 Bug 1815558 - Downgrade nsDependentString assert. r=smaug
I saw this in the nightly profile. This makes us go into the string
which in most cases is not necessary because the lengths are different.

Depends on D169143

Differential Revision: https://phabricator.services.mozilla.com/D169144
2023-02-08 00:55:19 +00:00
Olli Pettay 6aa07947ce Bug 1813344, don't allocate unnecessarily in nsTSubstring<T>::StripTaggedASCII, r=nika
Differential Revision: https://phabricator.services.mozilla.com/D168210
2023-01-30 17:09:30 +00:00
Nika Layzell 605a423c5c Bug 840706 - Part 2: Make ToDouble and ToFloat more spec-compliant, r=smaug,xpcom-reviewers,barret
The main use of this method appears to be when parsing attributes with floating
point values in HTML. By changing from PR_strtod, this change does have some
semantic differences around edge-cases, though I've tried to keep it compliant
with the wording in the standard.

Here are some of the edge-cases I investigated:

1. We appear to build nspr with INFNAN_CHECK undefined, meaning that we did not
   parse strings like "inf", "infinity" and "nan" both before and after this
   change.
2. PR_strtod already ignored locale (built with USE_LOCALE undefined), so
   locale behaviour shouldn't have changed.
3. Neither PR_strtod nor the spec support hex floats, so I didn't enable them
   in double-conversion.
4. Leading whitespace is skipped by both PR_strtod and in the spec, so is
   skipped after this change.
5. Numbers too large to fit in a double (e.g. 2E308) were previously returned
   as inf or -inf by PR_strtod. The spec specifies that these values should return
   an error instead, so they have been changed to produce an error with this
   change.
   This is a web-visible change (<progress value=2E308 max=10> is indeterminate
   in Chromium and complete in Firefox before this change, it will be
   indeterminate for both after the change).
6. Parsing for floats & doubles are now handled seperately due to
   differences in the maximum and minimum representable values.

Differential Revision: https://phabricator.services.mozilla.com/D148305
2022-12-06 20:27:49 +00:00
Nika Layzell a940fdcd2d Bug 1794001 - Part 3: Combine RustRegex::Flags and RustRegexOptions, r=xpcom-reviewers,kmag
This will make customizing flags on the regex type less error-prone, as passing
a flag (e.g. `RustRegex::FLAG_CASEI`) will not implicitly disable the default
`UNICODE` flag.

Names and comments were taken from the original `RegexBuilder` type in the
`regex` crate which this type is inspired by, and the type was changed to be
cheaply copyable and support method chaining, so that it can be used more
ergonomically.

Differential Revision: https://phabricator.services.mozilla.com/D159083
2022-10-13 21:46:55 +00:00
Nika Layzell 4cfa92886e Bug 1794001 - Part 2: Add a c++ wrapper for the rust regex (rure) API, r=xpcom-reviewers,kmag
This makes the API more ergonomic to use from our c++ code, managing things
like lifecycles automatically.

Documentation comments are copied from the `rure.h` header, and modified
slightly to reflect the C++ types.

Differential Revision: https://phabricator.services.mozilla.com/D158874
2022-10-13 21:46:55 +00:00
Cristian Tuns 8d27a1d79c Backed out 15 changesets (bug 1794001, bug 1793995, bug 1693271) for causing build bustages CLOSED TREE
Backed out changeset 5d4b0c23342f (bug 1793995)
Backed out changeset 79a5023e7822 (bug 1793995)
Backed out changeset 4330821df43f (bug 1793995)
Backed out changeset a653699a5cef (bug 1793995)
Backed out changeset 264a0154514e (bug 1793995)
Backed out changeset 6773cada61a8 (bug 1793995)
Backed out changeset d55a78f3627a (bug 1793995)
Backed out changeset 16299839e25e (bug 1793995)
Backed out changeset 10c5cf69b3f0 (bug 1693271)
Backed out changeset 84e7bf515c94 (bug 1693271)
Backed out changeset b8dbabe61a9a (bug 1794001)
Backed out changeset 3cfe4087793d (bug 1794001)
Backed out changeset dd03b0396eb9 (bug 1794001)
Backed out changeset d4f9b4a3029a (bug 1794001)
Backed out changeset 148d136ce549 (bug 1794001)
2022-10-12 22:12:26 -04:00
Nika Layzell bdc773db9f Bug 1794001 - Part 3: Combine RustRegex::Flags and RustRegexOptions, r=xpcom-reviewers,kmag
This will make customizing flags on the regex type less error-prone, as passing
a flag (e.g. `RustRegex::FLAG_CASEI`) will not implicitly disable the default
`UNICODE` flag.

Names and comments were taken from the original `RegexBuilder` type in the
`regex` crate which this type is inspired by, and the type was changed to be
cheaply copyable and support method chaining, so that it can be used more
ergonomically.

Differential Revision: https://phabricator.services.mozilla.com/D159083
2022-10-12 23:57:20 +00:00
Nika Layzell 94817b89f6 Bug 1794001 - Part 2: Add a c++ wrapper for the rust regex (rure) API, r=xpcom-reviewers,kmag
This makes the API more ergonomic to use from our c++ code, managing things
like lifecycles automatically.

Documentation comments are copied from the `rure.h` header, and modified
slightly to reflect the C++ types.

Differential Revision: https://phabricator.services.mozilla.com/D158874
2022-10-12 23:57:20 +00:00
Cristian Tuns d6fbf59d81 Backed out 15 changesets (bug 1794001, bug 1693271, bug 1793995) for causing build bustages on RustRegex.h CLOSED TREE
Backed out changeset 93fa076646e1 (bug 1793995)
Backed out changeset 3deec78af656 (bug 1793995)
Backed out changeset 61d74f2cf5cf (bug 1793995)
Backed out changeset 8484584cc787 (bug 1793995)
Backed out changeset f7d78fffc836 (bug 1793995)
Backed out changeset 37ccdfa60f9a (bug 1793995)
Backed out changeset 06d7d4823419 (bug 1793995)
Backed out changeset 5cb4daddadb9 (bug 1793995)
Backed out changeset 8b71c15f24c7 (bug 1693271)
Backed out changeset 77c06db920fe (bug 1693271)
Backed out changeset e286fb05d64f (bug 1794001)
Backed out changeset ea8ba9ce54c8 (bug 1794001)
Backed out changeset 27715593ce6f (bug 1794001)
Backed out changeset d1030c02b560 (bug 1794001)
Backed out changeset 80b01e63ca54 (bug 1794001)
2022-10-12 12:57:05 -04:00
Nika Layzell 85b4202a87 Bug 1794001 - Part 3: Combine RustRegex::Flags and RustRegexOptions, r=xpcom-reviewers,kmag
This will make customizing flags on the regex type less error-prone, as passing
a flag (e.g. `RustRegex::FLAG_CASEI`) will not implicitly disable the default
`UNICODE` flag.

Names and comments were taken from the original `RegexBuilder` type in the
`regex` crate which this type is inspired by, and the type was changed to be
cheaply copyable and support method chaining, so that it can be used more
ergonomically.

Depends on D158874

Differential Revision: https://phabricator.services.mozilla.com/D159083
2022-10-12 15:39:51 +00:00
Nika Layzell 615f84162b Bug 1794001 - Part 2: Add a c++ wrapper for the rust regex (rure) API, r=xpcom-reviewers,kmag
This makes the API more ergonomic to use from our c++ code, managing things
like lifecycles automatically.

Documentation comments are copied from the `rure.h` header, and modified
slightly to reflect the C++ types.

Differential Revision: https://phabricator.services.mozilla.com/D158874
2022-10-12 15:39:51 +00:00
Andrew McCreight 291afe14f4 Bug 1792574, part 3 - Don't include nsMemory where it isn't needed. r=xpcom-reviewers,necko-reviewers,valentin,nika
There are only 3 places where nsMemory.h is still needed (image/RasterImage.cpp,
gfx/thebes/gfxFT2FontList.cpp, and nsMemory.cpp). Remove the rest.

Differential Revision: https://phabricator.services.mozilla.com/D158213
2022-09-28 15:17:46 +00:00
Nika Layzell 51c14166ec Bug 1772006 - Part 8: Allow building xpcom/string without unified builds, r=xpcom-reviewers,barret
The last remaining things requiring unified builds in this directory are the
explicit specializations. As each class' methods are now confined to a single
file, these can now be moved to the appropriate .cpp files.

Differential Revision: https://phabricator.services.mozilla.com/D148303
2022-07-30 00:12:49 +00:00
Nika Layzell 085d4c95eb Bug 1772006 - Part 7: Remove unnecessary files from the string implementation, r=xpcom-reviewers,barret
These files exist only due to the history of how strings were previously
declared using macros, and aren't necessary anymore. The header files were not
removed, as they may be depended on from outside of the module. Cleaning up the
header situation is something which should probably happen in a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D148302
2022-07-30 00:12:49 +00:00
Nika Layzell bea3f71955 Bug 1772006 - Part 6: Simplify and move the find+replace methods from ns[T]StringObsolete, r=xpcom-reviewers,barret
The remaining methods in ns[T]StringObsolete are all find+replace methods for
nsTSubstring. These were migrated in a similar way to the find methods, and
partially updated to avoid using methods from nsStringObsolete.cpp.

This change removes the ns[T]StringObsolete.cpp files completely, as they are
no longer necessary.

Differential Revision: https://phabricator.services.mozilla.com/D148301
2022-07-30 00:12:49 +00:00
Nika Layzell 63a28ee824 Bug 1772006 - Part 5: Simplify and move the string searching APIs from ns[T]StringObsolete, r=xpcom-reviewers,necko-reviewers,eeejay,dragana,barret
The biggest set of APIs from ns[T]StringObsolete which are still heavily used
are the string searching APIs. It appears the intention was for these to be
replaced by the `FindInReadable` APIs, however that doesn't appear to have
happened.

In addition, the APIs have some quirks around their handling of mixed character
widths. These APIs generally supported both narrow strings and the native
string type, probably because char16_t string literals weren't available until
c++11. Finally they also used easy-to-confuse unlabeled boolean and integer
optional arguments to control behaviour.

These patches do the following major changes to the searching APIs:

1. The ASCII case-insensitive search method was split out as
   LowerCaseFindASCII, rather than using a boolean. This should be less
   error-prone and more explicit, and allows the method to continue to use
   narrow string literals for all string types (as only ASCII is supported).
2. The other [R]Find methods were restricted to only support arguments with
   matching character types. I considered adding a FindASCII method which would
   use narrow string literals for both wide and narrow strings but it would've
   been the same amount of work as changing all of the literals to unicode
   literals.
   This ends up being the bulk of the changes in the patch.
3. All find methods were re-implemented using std::basic_string_view's find
   algorithm or stl algorithms to reduce code complexity, and avoid the need to
   carry around the logic from nsStringObsolete.cpp.
4. The implementations were moved to nsTStringRepr.cpp.
5. An overload of Find was added to try to catch callers which previously
   called `Find(..., false)` or `Find(..., true)` to set case-sensitivity, due
   to booleans normally implicitly coercing to `index_type`. This should
   probably be removed at some point, but may be useful during the transition.

Differential Revision: https://phabricator.services.mozilla.com/D148300
2022-07-30 00:12:48 +00:00
Nika Layzell b14d1318e0 Bug 1772006 - Part 4: Simplify and move the string comparison APIs from ns[T]StringObsolete, r=xpcom-reviewers,necko-reviewers,dragana,barret
This patch moves EqualsIgnoreCase to ns[T]StringObsolete, and removes
the aCount argument, instead migrating callers to use `StringBeginsWith`
with a case-insensitive comparator.

In addition, nsTStringRepr::Compare was removed and replaced with either
calls to methods like `StringBeginsWith` or the global `Compare` method.

These changes required some modifications at call-sites but should make
the behaviour less surprising and more consistent.

Differential Revision: https://phabricator.services.mozilla.com/D148299
2022-07-30 00:12:48 +00:00
Nika Layzell 86f2e82c25 Bug 1772006 - Part 3: Move basic string APIs to more appropriate .cpp files, r=xpcom-reviewers,barret
Due to the history of how nsString was implemented, many APIs ended up being
implemented in inappropriate files. This change moves simple definitions which
won't require any changes for each type to happen within that type's .cpp file.

This is necessary to eventually enable the directory to be built without
unified builds.

Differential Revision: https://phabricator.services.mozilla.com/D148298
2022-07-30 00:12:47 +00:00
Nika Layzell 0e091b93ad Bug 1772006 - Part 2: Support converting nsTStringRepr<T> to std::basic_string_view<T>, r=xpcom-reviewers,barret
This type was introduced in c++17, and can be used as a convenient standard
medium for passing around borrowed substring references. It can be implicitly
converted to from string literals and `const char_type*`, meaning that after
this change it can be used as a convenient catch-all type to replace seperate
overloads for `const self_type&`, `const char_type*` and `const
char_type(&)[N]`.

std::basic_string_view also provides standard implementations of some
algorithms which will be convenient for code cleanup in later parts of this
bug.

Differential Revision: https://phabricator.services.mozilla.com/D148297
2022-07-30 00:12:47 +00:00
Nika Layzell a0354a90ac Bug 1772006 - Part 1: Split nsSubstring.cpp into relevant files, r=xpcom-reviewers,barret
This file only exists as a wrapper around nsTSubstring.cpp, with some methods
left in it due to how the string types were defined before they were turned
into templates.

Differential Revision: https://phabricator.services.mozilla.com/D148296
2022-07-30 00:12:46 +00:00