From a5af08b3ed160a569d389474dc5d5445dccf3a63 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 6 May 2022 11:52:20 +0200 Subject: [PATCH] tdf#121740 fast path in cancelCommandExecution skip the cost of constructing a SimpleIOErrorRequest in the common case Change-Id: Ib0a8989a9ffa76e6b71f984e0f32be94ec5cb8ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133959 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../provider/cancelcommandexecution.cxx | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ucbhelper/source/provider/cancelcommandexecution.cxx b/ucbhelper/source/provider/cancelcommandexecution.cxx index 89245ca78492..90c0168c6508 100644 --- a/ucbhelper/source/provider/cancelcommandexecution.cxx +++ b/ucbhelper/source/provider/cancelcommandexecution.cxx @@ -27,7 +27,9 @@ #include #include #include +#include #include +#include #include #include #include "simpleioerrorrequest.hxx" @@ -80,11 +82,23 @@ void cancelCommandExecution( const ucb::IOErrorCode eError, const uno::Reference< ucb::XCommandProcessor > & xContext ) { - rtl::Reference< ucbhelper::SimpleIOErrorRequest > xRequest - = new ucbhelper::SimpleIOErrorRequest( - eError, rArgs, rMessage, xContext ); - if ( xEnv.is() ) + if ( !xEnv ) { + // Fast path + + ucb::InteractiveAugmentedIOException aRequest; + aRequest.Message = rMessage; + aRequest.Context = xContext; + aRequest.Classification = task::InteractionClassification_ERROR; + aRequest.Code = eError; + aRequest.Arguments = rArgs; + cppu::throwException( uno::Any( aRequest ) ); + } + else + { + rtl::Reference< ucbhelper::SimpleIOErrorRequest > xRequest + = new ucbhelper::SimpleIOErrorRequest( + eError, rArgs, rMessage, xContext ); uno::Reference< task::XInteractionHandler > xIH = xEnv->getInteractionHandler(); if ( xIH.is() ) @@ -99,10 +113,9 @@ void cancelCommandExecution( const ucb::IOErrorCode eError, xContext, xRequest->getRequest() ); } + cppu::throwException( xRequest->getRequest() ); } - cppu::throwException( xRequest->getRequest() ); - OSL_FAIL( "Return from cppu::throwException call!!!" ); throw uno::RuntimeException(); }