This makes sure that __FILE__ path separators are consistent regardless
of the build host, which allows us to remove some chromium
base/location.cc changes.
Add a literal type to make using the appropriate separator less awkward.
Document it as matching __FILE__ syntax, which is what it is.
Differential Revision: https://phabricator.services.mozilla.com/D297316
Make DOMString a regular nsAutoTString with some special methods for
performance in some hot getters. For that, we need to change a bit
nsTString:
* Support for unowned buffers: Owned buffers now are represented by
STRINGBUFFER|OWNED flags, rather than REFCOUNTED.
* Inlining of the destructor: It showed up in profiles, it's also just
a few instructions, so probably worth it. We could OOL the owned path
I guess, if we wanted to.
* Inlinling and reordering of NonVoidStringToJsval. Old code had
special DOMString path inline with [buffer, literal, copy] paths,
then out of line code with [literal, buffer, copy]. Instead,
consolidate everything in a [buffer, literal, copy] inline path.
Do the same for UTF8/Latin1 strings too for consistency.
Differential Revision: https://phabricator.services.mozilla.com/D288148
Add an unsigned 64-bit variant of ToInteger64.
This provides a helper for parsing uint64_t values from strings and completes
the existing set of integer conversion methods.
Differential Revision: https://phabricator.services.mozilla.com/D291416
This is a large number of largely mechanical changes. When possible, the code
was called to directly call `.get()` instead, performing the assertions
manually. In many places PromiseFlatCString() calls were added to dynamically
copy the strings into null terminated buffers if the string was not null
terminated.
Differential Revision: https://phabricator.services.mozilla.com/D286158
This was originally removed due to bug 1341513. Unfortunately this method can
still have occasional value in places which call use a macro which declares a
`nsLiteral[C]String`. This changes some of those callers over & re-adds the
`.get()`.
Differential Revision: https://phabricator.services.mozilla.com/D286157
u8"" strings have type const char[] in C++17, but type const char8_t[] in C++20. Since most Firefox code is written assuming char or char16_t strings, char8_t strings cause type mismatches that would require additional overloads or string conversions.
Because Firefox .cpp files are compiled as UTF-8, "" string literals are already UTF-8 encoded and the explicit u8 prefix is unnecessary.
By removing the u8"" string literals in the MFBT and xpcom tests, we can remove nsTStringRepr's Equals() overloads for char8_t. They are now unused and casting a char8_t* string pointer to a char* string pointer is UB.
Differential Revision: https://phabricator.services.mozilla.com/D270453
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
It is replaced by a standard-conforming cast to (void) which is
understood the same by the compiler.
In some cases this could be replaced by `[[maybe_unused]]` but for
expression whose value is ignored, this requires storing to a temporary
variable first, so not going that way.
One notable change is that marking an object of type already_AddRefed as
unused used to implicitly leak memory. This is now made explicit.
Most of the heavy lifting was done through:
$ git grep -l '\<Unused\> <<' | xargs sed -i -e 's/Unused << /(void)/g'
$ git grep -l mozilla/Unused.h | xargs sed -i -e '/mozilla\/Unused.h/ d'
Differential Revision: https://phabricator.services.mozilla.com/D268706
According to the doc of mfbt/Try.h, MOZ_TRY_VAR is obsolete. Yet it was
used a lot across the code base.
Solely relying on MOZ_TRY is both nicer to the eye and more generic, as
it allows setting variable that don't have a default constructor, and
event sometimes more efficient, if the default constructor is
non-trivial.
Differential Revision: https://phabricator.services.mozilla.com/D268466
- remove unused headers
- __builtin_bswap* is always available for supported compilers
- do not use union for type punning
Differential Revision: https://phabricator.services.mozilla.com/D267305
nsTLiteralString is contractually always associated to global storage,
so it's conceptually a MOZ_OWNER even if it's actually a view.
Differential Revision: https://phabricator.services.mozilla.com/D250724
The combination of [[gsl::Owner]], [[gsl::Pointer]] and
[[clang::lifetimebound]] attributes makes it possible for clang to
detect some basic form of lifetime issues.
Those are expressed in terms of MOZ_GSL_OWNER, MOZ_GSL_POINTER and
MOZ_LIFETIME_BOUND.
Differential Revision: https://phabricator.services.mozilla.com/D241077
This overload removes the need for an extra copy when concatenating
multiple `nsTSubstring`s together to pass to a fallible `Replace`
function.
This slightly reduces the quality of the allocation failure error
reporting, as the infallible variant may report the wrong size if the
failed allocation is the tuple-flattening allocation in the case where
the tuple is dependent on the mutating string buffer. I expect this is
an uncommon situation, and felt that the extra code complexity from
duplicating the codepaths was not worth the OOM failure size accuracy.
Differential Revision: https://phabricator.services.mozilla.com/D236273