ucbhelper/source/provider/cancelcommandexecution.cxx |   25 ++++++++++++++-----
 1 file changed, 19 insertions(+), 6 deletions(-)

New commits:
commit a5af08b3ed160a569d389474dc5d5445dccf3a63
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri May 6 11:52:20 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat May 7 15:26:06 2022 +0200

    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 <noel.gran...@collabora.co.uk>

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 <rtl/ref.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <com/sun/star/ucb/CommandFailedException.hpp>
+#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
 #include <ucbhelper/interactionrequest.hxx>
 #include <ucbhelper/cancelcommandexecution.hxx>
 #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();
 }

Reply via email to