mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
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:
parent
46e20138db
commit
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
|
||||
|
Loading…
Reference in New Issue
Block a user