comphelper/source/misc/accessiblecomponenthelper.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
New commits: commit ba767f634384c7dca5cb42364e51bc1a8dbd1835 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Dec 11 16:37:34 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Dec 12 08:05:19 2024 +0100 a11y: Simplify OCommonAccessibleComponent::getAccessibleIndexInParent Just return the child index right away instead of assigning to a local variable first if the currently inspected child is the one. Change-Id: Ie5620498c34644fcf5523ce3eec6c71cb7486d71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178325 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/comphelper/source/misc/accessiblecomponenthelper.cxx b/comphelper/source/misc/accessiblecomponenthelper.cxx index 678e87e17cae..5d5ca53286ff 100644 --- a/comphelper/source/misc/accessiblecomponenthelper.cxx +++ b/comphelper/source/misc/accessiblecomponenthelper.cxx @@ -174,9 +174,6 @@ namespace comphelper { OExternalLockGuard aGuard( this ); - // -1 for child not found/no parent (according to specification) - sal_Int64 nRet = -1; - try { Reference< XAccessibleContext > xParentContext( implGetParentContext() ); @@ -198,11 +195,11 @@ namespace comphelper return -1; sal_Int64 nChildCount = xParentContext->getAccessibleChildCount(); - for ( sal_Int64 nChild = 0; ( nChild < nChildCount ) && ( -1 == nRet ); ++nChild ) + for (sal_Int64 nChild = 0; nChild < nChildCount; ++nChild) { Reference< XAccessible > xChild( xParentContext->getAccessibleChild( nChild ) ); if ( xChild.get() == xCreator.get() ) - nRet = nChild; + return nChild; } } catch( const Exception& ) @@ -210,7 +207,7 @@ namespace comphelper OSL_FAIL( "OCommonAccessibleComponent::getAccessibleIndexInParent: caught an exception!" ); } - return nRet; + return -1; }