From 85c2ed8dc790689ce69ff0a08ff5a4de98df54b7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 10 Apr 2022 20:17:54 +0200 Subject: loplugin:stringview add check for getToken().toInt32 where we can convert that to o3tl::toInt32(o3tl::getToken( and avoid the heap allocation of a temporary string Change-Id: Ib11c19c6e6cdc0de3e551affd3578d181e292de4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132810 Tested-by: Jenkins Reviewed-by: Noel Grandin --- fpicker/source/office/RemoteFilesDialog.cxx | 2 +- fpicker/source/office/fileview.cxx | 11 ++++++----- fpicker/source/office/fileview.hxx | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'fpicker/source') diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index d417488e4a55..21fc6a28d8d1 100644 --- a/fpicker/source/office/RemoteFilesDialog.cxx +++ b/fpicker/source/office/RemoteFilesDialog.cxx @@ -248,7 +248,7 @@ void RemoteFilesDialog::InitSize() sal_Int32 nPos2{ sCfgStr.indexOf('|', nPos1+1 ) }; if (nPos2<0) return; - m_xFileView->SetConfigString( sCfgStr.copy(nPos2+1) ); + m_xFileView->SetConfigString( sCfgStr.subView(nPos2+1) ); } } diff --git a/fpicker/source/office/fileview.cxx b/fpicker/source/office/fileview.cxx index a0597203ee63..a9270e52fdb1 100644 --- a/fpicker/source/office/fileview.cxx +++ b/fpicker/source/office/fileview.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -1098,19 +1099,19 @@ OUString SvtFileView::GetConfigString() const return aContent; } -void SvtFileView::SetConfigString(const OUString& rCfgStr) +void SvtFileView::SetConfigString(std::u16string_view rCfgStr) { sal_Int32 nIdx = 0; - sal_uInt16 nSortColumn = static_cast(rCfgStr.getToken( 0, ';', nIdx ).toInt32()); - bool bAscending = static_cast(static_cast(rCfgStr.getToken( 0, ';', nIdx ).toInt32())); + sal_uInt16 nSortColumn = static_cast(o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx ))); + bool bAscending = static_cast(static_cast(o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx )))); std::vector aWidths(mpImpl->mxView->TypeColumnVisible() ? 4 : 3, -1); while ( nIdx != -1 ) { - sal_uInt16 nItemId = static_cast(rCfgStr.getToken( 0, ';', nIdx ).toInt32()); + sal_uInt16 nItemId = static_cast(o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx ))); - int nWidth = rCfgStr.getToken( 0, ';', nIdx ).toInt32(); + int nWidth = o3tl::toInt32(o3tl::getToken(rCfgStr, 0, ';', nIdx )); // skip "TYPE" if (!mpImpl->mxView->TypeColumnVisible() && nItemId != COLUMN_TITLE) diff --git a/fpicker/source/office/fileview.hxx b/fpicker/source/office/fileview.hxx index d86ee93900e1..19ddd60e1e15 100644 --- a/fpicker/source/office/fileview.hxx +++ b/fpicker/source/office/fileview.hxx @@ -162,7 +162,7 @@ public: // save and load column size and sort order OUString GetConfigString() const; - void SetConfigString( const OUString& rCfgStr ); + void SetConfigString( std::u16string_view rCfgStr ); void EndInplaceEditing(); -- cgit