diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-08-10 19:07:30 +0300 |
---|---|---|
committer | Arkadiy Illarionov <qarkai@gmail.com> | 2019-08-17 14:08:33 +0200 |
commit | edcdfe5477559ca6c62897f0cad47d4d6149d77a (patch) | |
tree | bf97f0a716e760a3de4d95604483d26d943bd69f /sax/source | |
parent | 5ad254ed246cf8d11b55e50ed0ccba5736d0cdbb (diff) |
Simplify Sequence iterations in postprocess..sax
Use range-based loops, STL and comphelper functions
Change-Id: If738d8f4e792c4686870183b0c0fdfbb61fd3351
Reviewed-on: https://gerrit.libreoffice.org/77245
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'sax/source')
-rw-r--r-- | sax/source/expatwrap/xml2utf.cxx | 11 | ||||
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 7 | ||||
-rw-r--r-- | sax/source/fastparser/legacyfastparser.cxx | 18 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 4 |
4 files changed, 15 insertions, 25 deletions
diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx index c71f0bf2a993..103ef46344cb 100644 --- a/sax/source/expatwrap/xml2utf.cxx +++ b/sax/source/expatwrap/xml2utf.cxx @@ -187,15 +187,8 @@ bool XMLFile2UTFConverter::isEncodingRecognizable( const Sequence< sal_Int8 > &s if( bCheckIfFirstClosingBracketExsists ) { - for( sal_Int32 i = 0; i < seq.getLength() ; i ++ ) - { - // whole <?xml tag is valid - if( '>' == pSource[ i ] ) - { - return true; - } - } - return false; + // whole <?xml tag is valid + return std::find(seq.begin(), seq.end(), '>') != seq.end(); } // No <? tag in front, no need for a bigger buffer diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 4f1641f80b76..517f16f7c14a 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -408,11 +408,10 @@ void Entity::startElement( Event const *pEvent ) if ( mxNamespaceHandler.is() ) { - Sequence< xml::Attribute > NSDeclAttribs = pEvent->mxDeclAttributes->getUnknownAttributes(); - sal_uInt16 len = NSDeclAttribs.getLength(); - for (sal_uInt16 i = 0; i < len; i++) + const Sequence< xml::Attribute > NSDeclAttribs = pEvent->mxDeclAttributes->getUnknownAttributes(); + for (const auto& rNSDeclAttrib : NSDeclAttribs) { - mxNamespaceHandler->registerNamespace( NSDeclAttribs[i].Name, NSDeclAttribs[i].Value ); + mxNamespaceHandler->registerNamespace( rNSDeclAttrib.Name, rNSDeclAttrib.Value ); } } diff --git a/sax/source/fastparser/legacyfastparser.cxx b/sax/source/fastparser/legacyfastparser.cxx index 13dfc3b1d9bf..994835acc666 100644 --- a/sax/source/fastparser/legacyfastparser.cxx +++ b/sax/source/fastparser/legacyfastparser.cxx @@ -227,12 +227,11 @@ void SAL_CALL CallbackDocumentHandler::startUnknownElement( const OUString& /*Na rtl::Reference < comphelper::AttributeList > rAttrList = new comphelper::AttributeList; m_aNamespaceHandler->addNSDeclAttributes( rAttrList ); - Sequence< xml::FastAttribute > fastAttribs = Attribs->getFastAttributes(); - sal_uInt16 len = fastAttribs.getLength(); - for (sal_uInt16 i = 0; i < len; i++) + const Sequence< xml::FastAttribute > fastAttribs = Attribs->getFastAttributes(); + for (const auto& rAttr : fastAttribs) { - const OUString& rAttrValue = fastAttribs[i].Value; - sal_Int32 nToken = fastAttribs[i].Token; + const OUString& rAttrValue = rAttr.Value; + sal_Int32 nToken = rAttr.Token; const OUString& rAttrNamespacePrefix = CallbackDocumentHandler::getNamespacePrefixFromToken( nToken ); OUString sAttrName = CallbackDocumentHandler::getNameFromToken( nToken ); if ( !rAttrNamespacePrefix.isEmpty() ) @@ -241,12 +240,11 @@ void SAL_CALL CallbackDocumentHandler::startUnknownElement( const OUString& /*Na rAttrList->AddAttribute( sAttrName, "CDATA", rAttrValue ); } - Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes(); - len = unknownAttribs.getLength(); - for (sal_uInt16 i = 0; i < len; i++) + const Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes(); + for (const auto& rAttr : unknownAttribs) { - const OUString& rAttrValue = unknownAttribs[i].Value; - const OUString& rAttrName = unknownAttribs[i].Name; + const OUString& rAttrValue = rAttr.Value; + const OUString& rAttrName = rAttr.Name; rAttrList->AddAttribute( rAttrName, "CDATA", rAttrValue ); } diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 70a359b1c5ee..444924f0d521 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -773,9 +773,9 @@ namespace sax_fastparser { // Sort it all std::map< sal_Int32, Int8Sequence >::iterator iter; - for ( sal_Int32 i=0, len=maOrder.getLength(); i < len; i++ ) + for ( const auto nIndex : std::as_const(maOrder) ) { - iter = maData.find( maOrder[i] ); + iter = maData.find( nIndex ); if ( iter != maData.end() ) ForMerge::append( iter->second ); } |