mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-05-26 15:02:46 +00:00
partly import changes from tenfourfox:
- #565: implement nsASCIIMask from M1358297 (41b1fc937) - #565: M1358297 parts 3 and 4 (3fd15a87a) - #632: M1424915 M1354233 M1324114 M1343008 M1236277(just backbugs) M1328955 (d87db7e16) - #632: M1362498 M1397686 M136178 M1320252 M1355875 (82cb3b59e) - #632: M241788 M1271955 M1249352(p1) + additional local optimizations (438bdb726) - #632: M1249352 part 2 (2c61821e4) - #632: M1249352(remaining) M1358297(backbugs) M1369317(pp1,3,4) M1426996 (1eab6170b)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
* 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/. */
|
||||
|
||||
#include "nsASCIIMask.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/double-conversion.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
@@ -852,7 +853,8 @@ nsTSubstring_CharT::FindChar(char_type aChar, index_type aOffset) const
|
||||
void
|
||||
nsTSubstring_CharT::StripChar(char_type aChar, int32_t aOffset)
|
||||
{
|
||||
if (mLength == 0 || aOffset >= int32_t(mLength)) {
|
||||
// Note that this implicitly guarantees mLength > 0
|
||||
if (aOffset >= int32_t(mLength)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -879,6 +881,7 @@ nsTSubstring_CharT::StripChar(char_type aChar, int32_t aOffset)
|
||||
void
|
||||
nsTSubstring_CharT::StripChars(const char_type* aChars, uint32_t aOffset)
|
||||
{
|
||||
// Note that this implicitly guarantees mLength > 0
|
||||
if (aOffset >= uint32_t(mLength)) {
|
||||
return;
|
||||
}
|
||||
@@ -908,6 +911,45 @@ nsTSubstring_CharT::StripChars(const char_type* aChars, uint32_t aOffset)
|
||||
mLength = to - mData;
|
||||
}
|
||||
|
||||
void
|
||||
nsTSubstring_CharT::StripTaggedASCII(const ASCIIMaskArray& aToStrip,
|
||||
uint32_t aOffset)
|
||||
{
|
||||
// Note that this implicitly guarantees mLength > 0
|
||||
if (aOffset >= uint32_t(mLength)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EnsureMutable()) {
|
||||
AllocFailed(mLength);
|
||||
}
|
||||
|
||||
char_type* to = mData + aOffset;
|
||||
char_type* from = mData + aOffset;
|
||||
char_type* end = mData + mLength;
|
||||
|
||||
while (from < end) {
|
||||
uint32_t theChar = (uint32_t)*from++;
|
||||
// Replacing this with a call to ASCIIMask::IsMasked
|
||||
// regresses performance somewhat, so leaving it inlined.
|
||||
if (!mozilla::ASCIIMask::IsMasked(aToStrip, theChar)) {
|
||||
// Not stripped, copy this char.
|
||||
*to++ = (char_type)theChar;
|
||||
}
|
||||
}
|
||||
*to = char_type(0); // add the null
|
||||
mLength = to - mData;
|
||||
}
|
||||
|
||||
void
|
||||
nsTSubstring_CharT::StripCRLF(uint32_t aOffset)
|
||||
{
|
||||
// Expanding this call to copy the code from StripTaggedASCII
|
||||
// instead of just calling it does somewhat help with performance
|
||||
// but it is not worth it given the duplicated code.
|
||||
StripTaggedASCII(mozilla::ASCIIMask::MaskCRLF(), aOffset);
|
||||
}
|
||||
|
||||
int
|
||||
nsTSubstring_CharT::AppendFunc(void* aArg, const char* aStr, uint32_t aLen)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user