Bug 1344629 - Part 4: Cleanup: make string tuples not think in terms of "substring". r=dbaron
In the next patch, tuples will work on nsTStringRepr rather than nsTSubstring, so the notions of TO_SUBSTRING and substring_type are not quite right. MozReview-Commit-ID: LpUwmGQAWVO
This commit is contained in:
@@ -17,10 +17,10 @@ nsTSubstringTuple_CharT::Length() const
|
||||
if (mHead) {
|
||||
len = mHead->Length();
|
||||
} else {
|
||||
len = TO_SUBSTRING(mFragA).Length();
|
||||
len = mFragA->Length();
|
||||
}
|
||||
|
||||
len += TO_SUBSTRING(mFragB).Length();
|
||||
len += mFragB->Length();
|
||||
MOZ_RELEASE_ASSERT(len.isValid(), "Substring tuple length is invalid");
|
||||
return len.value();
|
||||
}
|
||||
@@ -35,41 +35,16 @@ nsTSubstringTuple_CharT::Length() const
|
||||
void
|
||||
nsTSubstringTuple_CharT::WriteTo(char_type* aBuf, uint32_t aBufLen) const
|
||||
{
|
||||
const substring_type& b = TO_SUBSTRING(mFragB);
|
||||
|
||||
MOZ_RELEASE_ASSERT(aBufLen >= b.Length(), "buffer too small");
|
||||
uint32_t headLen = aBufLen - b.Length();
|
||||
MOZ_RELEASE_ASSERT(aBufLen >= mFragB->Length(), "buffer too small");
|
||||
uint32_t headLen = aBufLen - mFragB->Length();
|
||||
if (mHead) {
|
||||
mHead->WriteTo(aBuf, headLen);
|
||||
} else {
|
||||
const substring_type& a = TO_SUBSTRING(mFragA);
|
||||
|
||||
MOZ_RELEASE_ASSERT(a.Length() == headLen, "buffer incorrectly sized");
|
||||
char_traits::copy(aBuf, a.Data(), a.Length());
|
||||
MOZ_RELEASE_ASSERT(mFragA->Length() == headLen, "buffer incorrectly sized");
|
||||
char_traits::copy(aBuf, mFragA->Data(), mFragA->Length());
|
||||
}
|
||||
|
||||
char_traits::copy(aBuf + headLen, b.Data(), b.Length());
|
||||
|
||||
#if 0
|
||||
// we need to write out data into |aBuf|, ending at |aBuf + aBufLen|. So our
|
||||
// data needs to precede |aBuf + aBufLen| exactly. We trust that the buffer
|
||||
// was properly sized!
|
||||
|
||||
const substring_type& b = TO_SUBSTRING(mFragB);
|
||||
|
||||
NS_ASSERTION(aBufLen >= b.Length(), "buffer is too small");
|
||||
char_traits::copy(aBuf + aBufLen - b.Length(), b.Data(), b.Length());
|
||||
|
||||
aBufLen -= b.Length();
|
||||
|
||||
if (mHead) {
|
||||
mHead->WriteTo(aBuf, aBufLen);
|
||||
} else {
|
||||
const substring_type& a = TO_SUBSTRING(mFragA);
|
||||
NS_ASSERTION(aBufLen == a.Length(), "buffer is too small");
|
||||
char_traits::copy(aBuf, a.Data(), a.Length());
|
||||
}
|
||||
#endif
|
||||
char_traits::copy(aBuf + headLen, mFragB->Data(), mFragB->Length());
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +59,7 @@ nsTSubstringTuple_CharT::IsDependentOn(const char_type* aStart,
|
||||
{
|
||||
// we aStart with the right-most fragment since it is faster to check.
|
||||
|
||||
if (TO_SUBSTRING(mFragB).IsDependentOn(aStart, aEnd)) {
|
||||
if (mFragB->IsDependentOn(aStart, aEnd)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -92,5 +67,5 @@ nsTSubstringTuple_CharT::IsDependentOn(const char_type* aStart,
|
||||
return mHead->IsDependentOn(aStart, aEnd);
|
||||
}
|
||||
|
||||
return TO_SUBSTRING(mFragA).IsDependentOn(aStart, aEnd);
|
||||
return mFragA->IsDependentOn(aStart, aEnd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user