Kaydet (Commit) d6da9e49 authored tarafından Mohammed Abdul Azeem's avatar Mohammed Abdul Azeem

Using range-for instead of iterator loop:

It's much easier to write and looks cleaner. And
this doesn't affect performance, I think.

Change-Id: Ia946b068979b9cef04ac2479c9179a70b6775dea
Reviewed-on: https://gerrit.libreoffice.org/39370Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMohammed Abdul Azeem <azeemmysore@gmail.com>
üst 803a1753
......@@ -123,22 +123,27 @@ public:
return mnIdx != rhs.mnIdx;
}
sal_Int32 getToken()
const FastAttributeIter& operator*() const
{
return *this;
}
sal_Int32 getToken() const
{
assert(mnIdx < mrList.maAttributeTokens.size());
return mrList.maAttributeTokens[mnIdx];
}
bool isEmpty()
bool isEmpty() const
{
assert(mnIdx < mrList.maAttributeTokens.size());
return mrList.AttributeValueLength(mnIdx) < 1;
}
sal_Int32 toInt32()
sal_Int32 toInt32() const
{
assert(mnIdx < mrList.maAttributeTokens.size());
return rtl_str_toInt32(mrList.getFastAttributeValue(mnIdx), 10);
}
OUString toString()
OUString toString() const
{
assert(mnIdx < mrList.maAttributeTokens.size());
return OUString(mrList.getFastAttributeValue(mnIdx),
......@@ -146,12 +151,12 @@ public:
RTL_TEXTENCODING_UTF8);
}
const char* toCString()
const char* toCString() const
{
assert(mnIdx < mrList.maAttributeTokens.size());
return mrList.getFastAttributeValue(mnIdx);
}
bool isString(const char *str)
bool isString(const char *str) const
{
assert(mnIdx < mrList.maAttributeTokens.size());
return !strcmp(str, mrList.getFastAttributeValue(mnIdx));
......
......@@ -92,11 +92,10 @@ ScXMLBodyContext::ScXMLBodyContext( ScXMLImport& rImport,
if( !xAttrList.is() )
return;
sax_fastparser::FastAttributeList *pAttribList;
assert( dynamic_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() ) != nullptr );
pAttribList = static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
sax_fastparser::FastAttributeList *pAttribList =
static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
for ( auto it = pAttribList->begin(); it != pAttribList->end(); ++it)
for( auto &it : *pAttribList )
{
sal_Int32 nToken = it.getToken();
if( NAMESPACE_TOKEN( XML_NAMESPACE_TABLE ) == ( nToken & NMSP_MASK ) )
......
......@@ -159,11 +159,10 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
std::unique_ptr<OUString> xCurrencySymbol;
if( xAttrList.is() )
{
sax_fastparser::FastAttributeList *pAttribList;
assert( dynamic_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() ) != nullptr );
pAttribList = static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
sax_fastparser::FastAttributeList *pAttribList =
static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
for ( auto it = pAttribList->begin(); it != pAttribList->end(); ++it)
for( auto &it : *pAttribList )
{
switch ( it.getToken() )
{
......
......@@ -54,7 +54,7 @@ ScXMLExternalRefTabSourceContext::ScXMLExternalRefTabSourceContext(
{
sax_fastparser::FastAttributeList *pAttribList = static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
for ( auto it = pAttribList->begin(); it != pAttribList->end(); ++it)
for( auto &it : *pAttribList )
{
sal_Int32 nAttrToken = it.getToken();
if ( nAttrToken == XML_ELEMENT( XLINK, XML_HREF ) )
......@@ -169,7 +169,7 @@ ScXMLExternalRefRowContext::ScXMLExternalRefRowContext(
{
sax_fastparser::FastAttributeList *pAttribList = static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
for ( auto it = pAttribList->begin(); it != pAttribList->end(); ++it)
for( auto &it : *pAttribList )
{
switch ( rAttrTokenMap.Get( it.getToken() ) )
{
......@@ -248,7 +248,7 @@ ScXMLExternalRefCellContext::ScXMLExternalRefCellContext(
{
sax_fastparser::FastAttributeList *pAttribList = static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
for ( auto it = pAttribList->begin(); it != pAttribList->end(); ++it)
for( auto &it : *pAttribList )
{
switch ( rTokenMap.Get( it.getToken() ) )
{
......
......@@ -53,11 +53,10 @@ ScXMLTableRowContext::ScXMLTableRowContext( ScXMLImport& rImport,
OUString sCellStyleName;
if ( xAttrList.is() )
{
sax_fastparser::FastAttributeList *pAttribList;
assert( dynamic_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() ) != nullptr );
pAttribList = static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
sax_fastparser::FastAttributeList *pAttribList =
static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
for ( auto it = pAttribList->begin(); it != pAttribList->end(); ++it)
for( auto &it : *pAttribList )
{
switch( it.getToken() )
{
......
......@@ -146,11 +146,10 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport,
if ( xAttrList.is() )
{
sax_fastparser::FastAttributeList *pAttribList;
assert( dynamic_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() ) != nullptr );
pAttribList = static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
sax_fastparser::FastAttributeList *pAttribList =
static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
for ( auto it = pAttribList->begin(); it != pAttribList->end(); ++it)
for( auto &it : *pAttribList )
{
switch( it.getToken() )
{
......
......@@ -93,22 +93,18 @@ void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & rPrefix,
if ( Attribs.is() )
{
sax_fastparser::FastAttributeList *pAttribList;
assert( dynamic_cast< sax_fastparser::FastAttributeList *>( Attribs.get() ) != nullptr );
pAttribList = static_cast< sax_fastparser::FastAttributeList *>( Attribs.get() );
sax_fastparser::FastAttributeList *pAttribList =
static_cast< sax_fastparser::FastAttributeList *>( Attribs.get() );
const std::vector< sal_Int32 >& rAttrTokenList = pAttribList->getFastAttributeTokens();
for ( size_t i = 0; i < rAttrTokenList.size(); i++ )
for( auto &it : *pAttribList )
{
const OUString& rAttrValue = OUString(pAttribList->getFastAttributeValue(i),
pAttribList->AttributeValueLength(i), RTL_TEXTENCODING_UTF8);
sal_Int32 nToken = rAttrTokenList[ i ];
sal_Int32 nToken = it.getToken();
const OUString& rAttrNamespacePrefix = SvXMLImport::getNamespacePrefixFromToken( nToken );
OUString sAttrName = SvXMLImport::getNameFromToken( nToken );
if ( !rAttrNamespacePrefix.isEmpty() )
sAttrName = rAttrNamespacePrefix + ":" + sAttrName;
mrImport.maAttrList->AddAttribute( sAttrName, "CDATA", rAttrValue );
mrImport.maAttrList->AddAttribute( sAttrName, "CDATA", it.toString() );
}
uno::Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment