summaryrefslogtreecommitdiff
path: root/comphelper/source/misc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-10-02 10:25:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-10-02 13:07:00 +0200
commite3c961e6a3917d95534652e0f982918cc1079015 (patch)
tree1efa9761d9d2159f06800f1f15b625a7dcc15d47 /comphelper/source/misc
parentfa229eb1ecbcbb7b861679158ad706e37d454526 (diff)
reduce allocations in InterceptedInteraction
the list of intercepted interactions is static per sub-class, so just pass up a o3tl::span at constructor time. Change-Id: Ib45c5a3338e0eb3848486dfc707052f07492eb61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157480 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper/source/misc')
-rw-r--r--comphelper/source/misc/simplefileaccessinteraction.cxx12
-rw-r--r--comphelper/source/misc/stillreadwriteinteraction.cxx61
2 files changed, 38 insertions, 35 deletions
diff --git a/comphelper/source/misc/simplefileaccessinteraction.cxx b/comphelper/source/misc/simplefileaccessinteraction.cxx
index 8cd77af7d693..f7a4f0eab237 100644
--- a/comphelper/source/misc/simplefileaccessinteraction.cxx
+++ b/comphelper/source/misc/simplefileaccessinteraction.cxx
@@ -29,10 +29,9 @@ const sal_Int32 HANDLE_CERTIFICATEREQUEST = 3;
/// Will handle com::sun::star::ucb::AuthenticationRequest
const sal_Int32 HANDLE_AUTHENTICATIONREQUEST = 4;
-SimpleFileAccessInteraction::SimpleFileAccessInteraction(
- const css::uno::Reference<css::task::XInteractionHandler>& xHandler)
+static o3tl::span<const ::ucbhelper::InterceptedInteraction::InterceptedRequest> getInterceptions()
{
- std::vector<::ucbhelper::InterceptedInteraction::InterceptedRequest> lInterceptions{
+ static const ::ucbhelper::InterceptedInteraction::InterceptedRequest lInterceptions[]{
{ //intercept standard IO error exception (local file and WebDAV)
css::uno::Any(css::ucb::InteractiveIOException()),
cppu::UnoType<css::task::XInteractionAbort>::get(), HANDLE_INTERACTIVEIOEXCEPTION },
@@ -52,9 +51,14 @@ SimpleFileAccessInteraction::SimpleFileAccessInteraction(
css::uno::Any(css::ucb::AuthenticationRequest()),
cppu::UnoType<css::task::XInteractionApprove>::get(), HANDLE_AUTHENTICATIONREQUEST }
};
+ return lInterceptions;
+}
+SimpleFileAccessInteraction::SimpleFileAccessInteraction(
+ const css::uno::Reference<css::task::XInteractionHandler>& xHandler)
+ : InterceptedInteraction(getInterceptions())
+{
setInterceptedHandler(xHandler);
- setInterceptions(std::move(lInterceptions));
}
SimpleFileAccessInteraction::~SimpleFileAccessInteraction() {}
diff --git a/comphelper/source/misc/stillreadwriteinteraction.cxx b/comphelper/source/misc/stillreadwriteinteraction.cxx
index 88bc25bc46cb..a6d1db057745 100644
--- a/comphelper/source/misc/stillreadwriteinteraction.cxx
+++ b/comphelper/source/misc/stillreadwriteinteraction.cxx
@@ -34,43 +34,42 @@
namespace comphelper{
+const sal_Int32 HANDLE_INTERACTIVEIOEXCEPTION = 0;
+const sal_Int32 HANDLE_UNSUPPORTEDDATASINKEXCEPTION = 1;
+const sal_Int32 HANDLE_AUTHENTICATIONREQUESTEXCEPTION = 2;
+const sal_Int32 HANDLE_CERTIFICATEVALIDATIONREQUESTEXCEPTION = 3;
+
+static o3tl::span<const ::ucbhelper::InterceptedInteraction::InterceptedRequest> getInterceptions()
+{
+ static const ::ucbhelper::InterceptedInteraction::InterceptedRequest lInterceptions[] {
+ {
+ css::uno::Any(css::ucb::InteractiveIOException()),
+ cppu::UnoType<css::task::XInteractionAbort>::get(), HANDLE_INTERACTIVEIOEXCEPTION
+ },
+ {
+ css::uno::Any(css::ucb::UnsupportedDataSinkException()),
+ cppu::UnoType<css::task::XInteractionAbort>::get(), HANDLE_UNSUPPORTEDDATASINKEXCEPTION
+ },
+ {
+ css::uno::Any(css::ucb::AuthenticationRequest()),
+ cppu::UnoType<css::task::XInteractionApprove>::get(), HANDLE_AUTHENTICATIONREQUESTEXCEPTION
+ },
+ {
+ css::uno::Any(css::ucb::CertificateValidationRequest()),
+ cppu::UnoType<css::task::XInteractionApprove>::get(), HANDLE_CERTIFICATEVALIDATIONREQUESTEXCEPTION
+ },
+ };
+ return lInterceptions;
+}
+
StillReadWriteInteraction::StillReadWriteInteraction(const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
css::uno::Reference< css::task::XInteractionHandler > xAuxiliaryHandler)
- : m_bUsed (false)
+ : InterceptedInteraction(getInterceptions())
+ , m_bUsed (false)
, m_bHandledByMySelf (false)
, m_xAuxiliaryHandler(std::move(xAuxiliaryHandler))
{
- std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest > lInterceptions;
- lInterceptions.reserve(4);
- ::ucbhelper::InterceptedInteraction::InterceptedRequest aInterceptedRequest;
-
- aInterceptedRequest.Handle = HANDLE_INTERACTIVEIOEXCEPTION;
- aInterceptedRequest.Request <<= css::ucb::InteractiveIOException();
- aInterceptedRequest.Continuation = cppu::UnoType<css::task::XInteractionAbort>::get();
- lInterceptions.push_back(aInterceptedRequest);
-
- aInterceptedRequest.Handle = HANDLE_UNSUPPORTEDDATASINKEXCEPTION;
- aInterceptedRequest.Request <<= css::ucb::UnsupportedDataSinkException();
- aInterceptedRequest.Continuation = cppu::UnoType<css::task::XInteractionAbort>::get();
- lInterceptions.push_back(aInterceptedRequest);
-
- aInterceptedRequest.Handle = HANDLE_AUTHENTICATIONREQUESTEXCEPTION;
- aInterceptedRequest.Request <<= css::ucb::AuthenticationRequest();
- aInterceptedRequest.Continuation = cppu::UnoType<css::task::XInteractionApprove>::get();
- lInterceptions.push_back(aInterceptedRequest);
-
- aInterceptedRequest.Handle = HANDLE_CERTIFICATEVALIDATIONREQUESTEXCEPTION;
- aInterceptedRequest.Request <<= css::ucb::CertificateValidationRequest();
- aInterceptedRequest.Continuation = cppu::UnoType<css::task::XInteractionApprove>::get();
- lInterceptions.push_back(aInterceptedRequest);
-
setInterceptedHandler(xHandler);
- setInterceptions(std::move(lInterceptions));
-}
-
-void StillReadWriteInteraction::resetInterceptions()
-{
- setInterceptions(std::vector< ::ucbhelper::InterceptedInteraction::InterceptedRequest >());
}
void StillReadWriteInteraction::resetErrorStates()