From 0600affd91ca799c75354a8c63d2b40373b08996 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 22 Nov 2021 18:01:36 +0200 Subject: tdf#133835 speedup calc autofilter (10) Remove more temporary buffers in INetURLObject::setAbsURIRef Change-Id: I3c5430937e3365a15b396504226d3bbdd39c4cc1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125668 Tested-by: Jenkins Reviewed-by: Noel Grandin --- tools/source/fsys/urlobj.cxx | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'tools') diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 7e29adc7d1c7..8c3d2845eab2 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -1419,18 +1419,17 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef, } // Parse - OUStringBuffer aSynPath(256); + sal_Int32 nBeforePathLength = m_aAbsURIRef.getLength(); if (!parsePath(m_eScheme, &pPos, pEnd, eMechanism, eCharset, bSkippedInitialSlash, nSegmentDelimiter, nAltSegmentDelimiter, getSchemeInfo().m_bQuery ? '?' : 0x80000000, - nFragmentDelimiter, aSynPath)) + nFragmentDelimiter, m_aAbsURIRef)) { setInvalid(); return false; } - m_aPath.set(m_aAbsURIRef, aSynPath.makeStringAndClear(), - m_aAbsURIRef.getLength()); + m_aPath = SubString(nBeforePathLength, m_aAbsURIRef.getLength() - nBeforePathLength); // Parse ? if (getSchemeInfo().m_bQuery && pPos < pEnd && *pPos == '?') @@ -2951,7 +2950,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, DBG_ASSERT(pBegin, "INetURLObject::parsePath(): Null output param"); sal_Unicode const * pPos = *pBegin; - + const sal_Int32 nSynPathBeforeLen = rSynPath.getLength(); switch (eScheme) { case INetProtocol::NotValid: @@ -2959,7 +2958,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, case INetProtocol::Ftp: if (pPos < pEnd && *pPos != '/' && *pPos != nFragmentDelimiter) - return false; + goto failed; while (pPos < pEnd && *pPos != nFragmentDelimiter) { EscapeType eEscapeType; @@ -2968,7 +2967,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, appendUCS4(rSynPath, nUTF32, eEscapeType, PART_HTTP_PATH, eCharset, true); } - if (rSynPath.isEmpty()) + if (rSynPath.getLength() - nSynPathBeforeLen == 0) rSynPath.append('/'); break; @@ -2978,7 +2977,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, case INetProtocol::Smb: case INetProtocol::Cmis: if (pPos < pEnd && *pPos != '/' && *pPos != nFragmentDelimiter) - return false; + goto failed; while (pPos < pEnd && *pPos != nQueryDelimiter && *pPos != nFragmentDelimiter) { @@ -2988,7 +2987,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, appendUCS4(rSynPath, nUTF32, eEscapeType, PART_HTTP_PATH, eCharset, true); } - if (rSynPath.isEmpty()) + if (rSynPath.getLength() - nSynPathBeforeLen == 0) rSynPath.append('/'); break; @@ -2999,7 +2998,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, else if (pPos < pEnd && *pPos != nSegmentDelimiter && *pPos != nAltSegmentDelimiter) - return false; + goto failed; while (pPos < pEnd && *pPos != nFragmentDelimiter) { EscapeType eEscapeType; @@ -3018,8 +3017,8 @@ bool INetURLObject::parsePath(INetProtocol eScheme, || *pPos == nFragmentDelimiter || *pPos == nSegmentDelimiter || *pPos == nAltSegmentDelimiter) - && rSynPath.getLength() == 2 - && rtl::isAsciiAlpha(rSynPath[1])) + && rSynPath.getLength() - nSynPathBeforeLen == 2 + && rtl::isAsciiAlpha(rSynPath[nSynPathBeforeLen + 1])) { // A first segment of is translated to // : @@ -3030,7 +3029,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, appendUCS4(rSynPath, nUTF32, eEscapeType, PART_PCHAR, eCharset, true); } - if (rSynPath.isEmpty()) + if (rSynPath.getLength() - nSynPathBeforeLen == 0) rSynPath.append('/'); break; } @@ -3074,7 +3073,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, else { if (*pPos != '/') - return false; + goto failed; while (pPos < pEnd && *pPos != nQueryDelimiter && *pPos != nFragmentDelimiter) { @@ -3106,7 +3105,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, case INetProtocol::VndSunStarPkg: if (pPos < pEnd && *pPos != '/' && *pPos != nQueryDelimiter && *pPos != nFragmentDelimiter) - return false; + goto failed; while (pPos < pEnd && *pPos != nQueryDelimiter && *pPos != nFragmentDelimiter) { @@ -3119,7 +3118,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, appendUCS4(rSynPath, nUTF32, eEscapeType, PART_PCHAR, eCharset, false); } - if (rSynPath.isEmpty()) + if (rSynPath.getLength() - nSynPathBeforeLen == 0) rSynPath.append('/'); break; @@ -3127,7 +3126,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, case INetProtocol::VndSunStarExpand: { if (pPos == pEnd || *pPos == nFragmentDelimiter) - return false; + goto failed; Part ePart = PART_URIC_NO_SLASH; while (pPos != pEnd && *pPos != nFragmentDelimiter) { @@ -3145,7 +3144,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, if (pPos < pEnd) { if (*pPos != '/' || pEnd - pPos > 1) - return false; + goto failed; ++pPos; } rSynPath.append('/'); @@ -3153,7 +3152,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, case INetProtocol::VndSunStarTdoc: if (pPos == pEnd || *pPos != '/') - return false; + goto failed; while (pPos < pEnd && *pPos != nFragmentDelimiter) { EscapeType eEscapeType; @@ -3178,7 +3177,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, PART_URIC, eCharset, true); } if (rSynPath.isEmpty()) - return false; + goto failed; break; default: OSL_ASSERT(false); @@ -3187,6 +3186,9 @@ bool INetURLObject::parsePath(INetProtocol eScheme, *pBegin = pPos; return true; +failed: + rSynPath.setLength(nSynPathBeforeLen); + return false; } bool INetURLObject::setPath(OUString const & rThePath, -- cgit