mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 23:30:46 +00:00
Bug 1648391 - Use rhs-first optimization from IsDependentOn in IsDependentOnWithLength. r=froydnj
Depends on D81054 Differential Revision: https://phabricator.services.mozilla.com/D81055
This commit is contained in:
parent
bebf92b951
commit
7b417b5ef3
@ -53,7 +53,7 @@ void nsTSubstringTuple<T>::WriteTo(char_type* aBuf, uint32_t aBufLen) const {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
bool nsTSubstringTuple<T>::IsDependentOn(const char_type* aStart,
|
bool nsTSubstringTuple<T>::IsDependentOn(const char_type* aStart,
|
||||||
const char_type* aEnd) const {
|
const char_type* aEnd) const {
|
||||||
// we aStart with the right-most fragment since it is faster to check.
|
// we start with the right-most fragment since it is faster to check.
|
||||||
|
|
||||||
if (mFragB->IsDependentOn(aStart, aEnd)) {
|
if (mFragB->IsDependentOn(aStart, aEnd)) {
|
||||||
return true;
|
return true;
|
||||||
@ -70,6 +70,14 @@ template <typename T>
|
|||||||
auto nsTSubstringTuple<T>::IsDependentOnWithLength(const char_type* aStart,
|
auto nsTSubstringTuple<T>::IsDependentOnWithLength(const char_type* aStart,
|
||||||
const char_type* aEnd) const
|
const char_type* aEnd) const
|
||||||
-> std::pair<bool, size_type> {
|
-> std::pair<bool, size_type> {
|
||||||
|
// we start with the right-most fragment since it is faster to check for
|
||||||
|
// dependency.
|
||||||
|
const bool rightDependentOn = mFragB->IsDependentOn(aStart, aEnd);
|
||||||
|
|
||||||
|
if (rightDependentOn) {
|
||||||
|
return {true, Length()};
|
||||||
|
}
|
||||||
|
|
||||||
const auto [leftDependentOn, leftLen] =
|
const auto [leftDependentOn, leftLen] =
|
||||||
mHead ? mHead->IsDependentOnWithLength(aStart, aEnd)
|
mHead ? mHead->IsDependentOnWithLength(aStart, aEnd)
|
||||||
: std::pair{mFragA->IsDependentOn(aStart, aEnd), mFragA->Length()};
|
: std::pair{mFragA->IsDependentOn(aStart, aEnd), mFragA->Length()};
|
||||||
@ -77,8 +85,7 @@ auto nsTSubstringTuple<T>::IsDependentOnWithLength(const char_type* aStart,
|
|||||||
const auto checkedLen =
|
const auto checkedLen =
|
||||||
mozilla::CheckedInt<size_type>{leftLen} + mFragB->Length();
|
mozilla::CheckedInt<size_type>{leftLen} + mFragB->Length();
|
||||||
MOZ_RELEASE_ASSERT(checkedLen.isValid(), "Substring tuple length is invalid");
|
MOZ_RELEASE_ASSERT(checkedLen.isValid(), "Substring tuple length is invalid");
|
||||||
return {leftDependentOn || mFragB->IsDependentOn(aStart, aEnd),
|
return {leftDependentOn, checkedLen.value()};
|
||||||
checkedLen.value()};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template class nsTSubstringTuple<char>;
|
template class nsTSubstringTuple<char>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user