diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-15 16:43:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-15 20:11:48 +0200 |
commit | 558aaa9ed222e7142fe87c9bab9a8293a5e2a159 (patch) | |
tree | 7b9a0361dd07dbc0ca6b67ef130d27368569cf18 /xmlhelp | |
parent | ba74c925a5ef872c291613d4be589e1ab4b4e9e1 (diff) |
use more string_view in xml*
Change-Id: Ie219cb3feb98660463858d00f82f882881946ad0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133072
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlhelp')
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/databases.cxx | 47 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/databases.hxx | 8 |
2 files changed, 28 insertions, 27 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index 48e6788b0639..7d70fde659ce 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -567,35 +567,36 @@ namespace chelp { KeywordInfo::KeywordElement::KeywordElement( Databases const *pDatabases, helpdatafileproxy::Hdf* pHdf, OUString const & ky, - OUString const & data ) + std::u16string_view data ) : key( ky ) { pDatabases->replaceName( key ); init( pDatabases,pHdf,data ); } -void KeywordInfo::KeywordElement::init( Databases const *pDatabases,helpdatafileproxy::Hdf* pHdf,const OUString& ids ) +void KeywordInfo::KeywordElement::init( Databases const *pDatabases,helpdatafileproxy::Hdf* pHdf, std::u16string_view ids ) { std::vector< OUString > id,anchor; - int idx = -1,k; + size_t idx = std::u16string_view::npos; + size_t k = 0; for (;;) { - k = ++idx; - idx = ids.indexOf( ';', k ); - if( idx == -1 ) + idx = ids.find( ';', k ); + if( idx == std::u16string_view::npos ) break; - int h = ids.indexOf( '#', k ); - if( h < idx ) + size_t h = ids.find( '#', k ); + if( h == std::u16string_view::npos || h < idx ) { // found an anchor - id.push_back( ids.copy( k, h-k ) ); - anchor.push_back( ids.copy( h+1, idx-h-1 ) ); + id.push_back( OUString(ids.substr( k, h-k )) ); + anchor.push_back( OUString(ids.substr( h+1, idx-h-1 )) ); } else { - id.push_back( ids.copy( k, idx-k ) ); + id.push_back( OUString(ids.substr( k, idx-k )) ); anchor.emplace_back( ); } + k = ++idx; } listId.realloc( id.size() ); @@ -775,10 +776,10 @@ KeywordInfo* Databases::getKeyword( const OUString& Database, return it->second.get(); } -Reference< XHierarchicalNameAccess > Databases::jarFile( const OUString& jar, +Reference< XHierarchicalNameAccess > Databases::jarFile( std::u16string_view jar, const OUString& Language ) { - if( jar.isEmpty() || Language.isEmpty() ) + if( jar.empty() || Language.isEmpty() ) { return Reference< XHierarchicalNameAccess >( nullptr ); } @@ -795,14 +796,14 @@ Reference< XHierarchicalNameAccess > Databases::jarFile( const OUString& jar, { OUString zipFile; // Extension jar file? Search for ? - sal_Int32 nQuestionMark1 = jar.indexOf( '?' ); - sal_Int32 nQuestionMark2 = jar.lastIndexOf( '?' ); - if( nQuestionMark1 != -1 && nQuestionMark2 != -1 && nQuestionMark1 != nQuestionMark2 ) + size_t nQuestionMark1 = jar.find( '?' ); + size_t nQuestionMark2 = jar.rfind( '?' ); + if( nQuestionMark1 != std::u16string_view::npos && nQuestionMark2 != std::u16string_view::npos && nQuestionMark1 != nQuestionMark2 ) { - OUString aExtensionPath = jar.copy( nQuestionMark1 + 1, nQuestionMark2 - nQuestionMark1 - 1 ); - OUString aPureJar = jar.copy( nQuestionMark2 + 1 ); + std::u16string_view aExtensionPath = jar.substr( nQuestionMark1 + 1, nQuestionMark2 - nQuestionMark1 - 1 ); + std::u16string_view aPureJar = jar.substr( nQuestionMark2 + 1 ); - zipFile = expandURL( aExtensionPath + "/" + aPureJar ); + zipFile = expandURL( OUString::Concat(aExtensionPath) + "/" + aPureJar ); } else { @@ -1795,12 +1796,12 @@ OUString IndexFolderIterator::implGetIndexFolderFromPackage( bool& o_rbTemporary return aIndexFolder; } -void IndexFolderIterator::deleteTempIndexFolder( const OUString& aIndexFolder ) +void IndexFolderIterator::deleteTempIndexFolder( std::u16string_view aIndexFolder ) { - sal_Int32 nLastSlash = aIndexFolder.lastIndexOf( '/' ); - if( nLastSlash != -1 ) + size_t nLastSlash = aIndexFolder.rfind( '/' ); + if( nLastSlash != std::u16string_view::npos ) { - OUString aTmpFolder = aIndexFolder.copy( 0, nLastSlash ); + OUString aTmpFolder( aIndexFolder.substr( 0, nLastSlash ) ); try { m_xSFA->kill( aTmpFolder ); diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx index 66c351088e46..9c42d1b08d01 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.hxx +++ b/xmlhelp/source/cxxhelp/provider/databases.hxx @@ -93,7 +93,7 @@ namespace chelp { KeywordElement( Databases const * pDatabases, helpdatafileproxy::Hdf* pHdf, OUString const & key, - OUString const & ids ); + std::u16string_view ids ); private: @@ -102,7 +102,7 @@ namespace chelp { css::uno::Sequence< OUString > listAnchor; css::uno::Sequence< OUString > listTitle; - void init( Databases const *pDatabases,helpdatafileproxy::Hdf* pHdf,const OUString& ids ); + void init( Databases const *pDatabases,helpdatafileproxy::Hdf* pHdf, std::u16string_view ids ); }; explicit KeywordInfo( const std::vector< KeywordElement >& aVector ); @@ -193,7 +193,7 @@ namespace chelp { */ css::uno::Reference< css::container::XHierarchicalNameAccess > - jarFile( const OUString& jar, + jarFile( std::u16string_view jar, const OUString& Language ); css::uno::Reference< css::container::XHierarchicalNameAccess > @@ -423,7 +423,7 @@ namespace chelp { {} OUString nextIndexFolder( bool& o_rbExtension, bool& o_rbTemporary ); - void deleteTempIndexFolder( const OUString& aIndexFolder ); + void deleteTempIndexFolder( std::u16string_view aIndexFolder ); private: OUString implGetIndexFolderFromPackage( bool& o_rbTemporary, |