зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1305422 - part 7 - simplify nsXMLContentSerializer::SerializeAttr; r=smaug
The implementation of SerializeAttr, with its multiply-nested loops, dates from the time when string iterators could be fragmented into multiple pieces. We no longer have such iterators, so we can write SerializeAttr much more straightforwardly.
This commit is contained in:
Родитель
46e20138db
Коммит
3fb4b33af7
|
@ -658,26 +658,24 @@ nsXMLContentSerializer::SerializeAttr(const nsAString& aPrefix,
|
|||
bool bIncludesSingle = false;
|
||||
bool bIncludesDouble = false;
|
||||
nsAString::const_iterator iCurr, iEnd;
|
||||
uint32_t uiSize, i;
|
||||
aValue.BeginReading(iCurr);
|
||||
aValue.EndReading(iEnd);
|
||||
for ( ; iCurr != iEnd; iCurr.advance(uiSize) ) {
|
||||
const char16_t * buf = iCurr.get();
|
||||
uiSize = iCurr.size_forward();
|
||||
for ( i = 0; i < uiSize; i++, buf++ ) {
|
||||
if ( *buf == char16_t('\'') )
|
||||
{
|
||||
bIncludesSingle = true;
|
||||
if ( bIncludesDouble ) break;
|
||||
for ( ; iCurr != iEnd; ++iCurr) {
|
||||
if (*iCurr == char16_t('\'')) {
|
||||
bIncludesSingle = true;
|
||||
if (bIncludesDouble) {
|
||||
break;
|
||||
}
|
||||
else if ( *buf == char16_t('"') )
|
||||
{
|
||||
bIncludesDouble = true;
|
||||
if ( bIncludesSingle ) break;
|
||||
} else if (*iCurr == char16_t('"')) {
|
||||
bIncludesDouble = true;
|
||||
if (bIncludesSingle) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if both have been found we don't need to search further
|
||||
if ( bIncludesDouble && bIncludesSingle ) break;
|
||||
if (bIncludesDouble && bIncludesSingle) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Delimiter and escaping is according to the following table
|
||||
|
|
Загрузка…
Ссылка в новой задаче