sw/source/core/doc/doctxm.cxx | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)
New commits: commit cb5c088c008fe1c83d9dbfa1537f91f0678d3c80 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Nov 28 13:09:41 2024 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Nov 28 15:26:53 2024 +0100 clarify that nNum is reused for two different things so the first use of nNum is dead after scope no logic change intended Change-Id: I81a51531418b32a09f5b9dba1131bc65ac71df3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177483 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 146e6ada4c7c..fc2552385b70 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -676,7 +676,6 @@ OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, const OUString& aName( rType.GetTypeName() ); const sal_Int32 nNmLen = aName.getLength(); - SwSectionFormats::size_type nNum = 0; const SwSectionFormats::size_type nFlagSize = ( mpSectionFormatTable->size() / 8 ) +2; std::unique_ptr<sal_uInt8[]> pSetFlags(new sal_uInt8[ nFlagSize ]); memset( pSetFlags.get(), 0, nFlagSize ); @@ -694,7 +693,7 @@ OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, if ( rNm.startsWith(aName) ) { // Calculate number and set the Flag - nNum = o3tl::toInt32(rNm.subView( nNmLen )); + SwSectionFormats::size_type nNum = o3tl::toInt32(rNm.subView(nNmLen)); if( nNum-- && nNum < mpSectionFormatTable->size() ) pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } @@ -707,7 +706,7 @@ OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, return sChkStr; // All Numbers have been flagged accordingly, so get the right Number - nNum = mpSectionFormatTable->size(); + SwSectionFormats::size_type nNum = mpSectionFormatTable->size(); for( SwSectionFormats::size_type n = 0; n < nFlagSize; ++n ) { sal_uInt8 nTmp = pSetFlags[ n ]; commit 6b85f012ff816533299fb35707825c9f9eb652bb Author: Caolán McNamara <[email protected]> AuthorDate: Thu Nov 28 13:07:58 2024 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Nov 28 15:26:48 2024 +0100 we can deindent this and make it conditional given that we return early on the opposite condition no logic change intended, git diff -w is your friend Change-Id: I37b7db3a1d092ffbe0ef41561982555f6b6d3bae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177482 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 10011c858a5d..146e6ada4c7c 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -706,24 +706,21 @@ OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, if (bUseChkStr) return sChkStr; - if( !bUseChkStr ) + // All Numbers have been flagged accordingly, so get the right Number + nNum = mpSectionFormatTable->size(); + for( SwSectionFormats::size_type n = 0; n < nFlagSize; ++n ) { - // All Numbers have been flagged accordingly, so get the right Number - nNum = mpSectionFormatTable->size(); - for( SwSectionFormats::size_type n = 0; n < nFlagSize; ++n ) + sal_uInt8 nTmp = pSetFlags[ n ]; + if( nTmp != 0xff ) { - sal_uInt8 nTmp = pSetFlags[ n ]; - if( nTmp != 0xff ) + // so get the Number + nNum = n * 8; + while( nTmp & 1 ) { - // so get the Number - nNum = n * 8; - while( nTmp & 1 ) - { - ++nNum; - nTmp >>= 1; - } - break; + ++nNum; + nTmp >>= 1; } + break; } } return aName + OUString::number( ++nNum ); commit ea24f2356211530e5ee3517d7e5c764e06d751f2 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Nov 28 13:06:52 2024 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Nov 28 15:26:42 2024 +0100 return early if bUseChkStr is true no logic change intended Change-Id: Ie1b4d15af35b01c9f490db7eb33c9493775ab9b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177481 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 6a523914dc43..10011c858a5d 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -703,6 +703,9 @@ OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, } } + if (bUseChkStr) + return sChkStr; + if( !bUseChkStr ) { // All Numbers have been flagged accordingly, so get the right Number @@ -723,8 +726,6 @@ OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, } } } - if ( bUseChkStr ) - return sChkStr; return aName + OUString::number( ++nNum ); }
