OUString::intern is a relic

and a pessimisation. Remove usage thereof.

Change-Id: I98f6197aa375349b909a7ef1403ec06ca37890d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150269
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2023-04-12 10:18:33 +02:00
parent 8f9523b3ef
commit 08495e24e8
10 changed files with 31 additions and 38 deletions

View File

@@ -843,8 +843,8 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool
} }
else else
{ {
// Commit the string. Use intern() to ref-count it. // Commit the string
*(*_rRow)[i] = OUString::intern(pData, static_cast<sal_Int32>(nLastPos+1), m_eEncoding); *(*_rRow)[i] = OUString(pData, static_cast<sal_Int32>(nLastPos+1), m_eEncoding);
} }
} // if (nType == DataType::CHAR || nType == DataType::VARCHAR) } // if (nType == DataType::CHAR || nType == DataType::VARCHAR)
else if ( DataType::TIMESTAMP == nType ) else if ( DataType::TIMESTAMP == nType )
@@ -928,7 +928,7 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool
continue; continue;
} }
OUString aStr = OUString::intern(pData+nPos1, nPos2-nPos1+1, m_eEncoding); OUString aStr(pData+nPos1, nPos2-nPos1+1, m_eEncoding);
switch (nType) switch (nType)
{ {

View File

@@ -121,7 +121,6 @@ static void ExtractMenuParameters( const Sequence< PropertyValue >& rProp,
if ( p.Name == ITEM_DESCRIPTOR_COMMANDURL ) if ( p.Name == ITEM_DESCRIPTOR_COMMANDURL )
{ {
p.Value >>= rCommandURL; p.Value >>= rCommandURL;
rCommandURL = rCommandURL.intern();
} }
else if ( p.Name == ITEM_DESCRIPTOR_HELPURL ) else if ( p.Name == ITEM_DESCRIPTOR_HELPURL )
{ {
@@ -200,7 +199,7 @@ void ReadMenuDocumentHandlerBase::initPropertyCommon(
pProps[5].Name = m_aType; pProps[5].Name = m_aType;
// Common values // Common values
pProps[0].Value <<= rCommandURL.intern(); pProps[0].Value <<= rCommandURL;
pProps[1].Value <<= rHelpId; pProps[1].Value <<= rHelpId;
pProps[2].Value <<= Reference< XIndexContainer >(); pProps[2].Value <<= Reference< XIndexContainer >();
pProps[3].Value <<= rLabel; pProps[3].Value <<= rLabel;

View File

@@ -101,7 +101,6 @@ static void ExtractStatusbarItemParameters(
if ( rEntry.Name == ITEM_DESCRIPTOR_COMMANDURL ) if ( rEntry.Name == ITEM_DESCRIPTOR_COMMANDURL )
{ {
rEntry.Value >>= rCommandURL; rEntry.Value >>= rCommandURL;
rCommandURL = rCommandURL.intern();
} }
else if ( rEntry.Name == ITEM_DESCRIPTOR_HELPURL ) else if ( rEntry.Name == ITEM_DESCRIPTOR_HELPURL )
{ {

View File

@@ -65,10 +65,7 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue >& rProp,
for ( const PropertyValue& rEntry : rProp ) for ( const PropertyValue& rEntry : rProp )
{ {
if ( rEntry.Name == ITEM_DESCRIPTOR_COMMANDURL ) if ( rEntry.Name == ITEM_DESCRIPTOR_COMMANDURL )
{
rEntry.Value >>= rCommandURL; rEntry.Value >>= rCommandURL;
rCommandURL = rCommandURL.intern();
}
else if ( rEntry.Name == ITEM_DESCRIPTOR_LABEL ) else if ( rEntry.Name == ITEM_DESCRIPTOR_LABEL )
rEntry.Value >>= rLabel; rEntry.Value >>= rLabel;
else if ( rEntry.Name == ITEM_DESCRIPTOR_TYPE ) else if ( rEntry.Name == ITEM_DESCRIPTOR_TYPE )
@@ -284,7 +281,7 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
case TB_ATTRIBUTE_URL: case TB_ATTRIBUTE_URL:
{ {
bAttributeURL = true; bAttributeURL = true;
aCommandURL = xAttribs->getValueByIndex( n ).intern(); aCommandURL = xAttribs->getValueByIndex( n );
} }
break; break;

View File

@@ -58,7 +58,7 @@ public:
virtual OUString SAL_CALL getPresentation( const css::util::URL& aURL, sal_Bool bWithPassword ) override; virtual OUString SAL_CALL getPresentation( const css::util::URL& aURL, sal_Bool bWithPassword ) override;
}; };
void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL,bool _bUseIntern) void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL)
{ {
// Get all information about this URL. // Get all information about this URL.
_rURL.Protocol = INetURLObject::GetScheme( _rParser.GetProtocol() ); _rURL.Protocol = INetURLObject::GetScheme( _rParser.GetProtocol() );
@@ -98,8 +98,6 @@ void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL,bool _bUseI
// INetURLObject supports only an intelligent method of parsing URL's. So write // INetURLObject supports only an intelligent method of parsing URL's. So write
// back Complete to have a valid encoded URL in all cases! // back Complete to have a valid encoded URL in all cases!
_rURL.Complete = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE ); _rURL.Complete = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE );
if ( _bUseIntern )
_rURL.Complete = _rURL.Complete.intern();
_rParser.SetMark( u"" ); _rParser.SetMark( u"" );
_rParser.SetParam( u"" ); _rParser.SetParam( u"" );
@@ -136,7 +134,7 @@ sal_Bool SAL_CALL URLTransformer::parseStrict( css::util::URL& aURL )
} }
else if ( !aParser.HasError() ) else if ( !aParser.HasError() )
{ {
lcl_ParserHelper(aParser,aURL,false); lcl_ParserHelper(aParser,aURL);
// Return "URL is parsed". // Return "URL is parsed".
return true; return true;
} }
@@ -174,7 +172,7 @@ sal_Bool SAL_CALL URLTransformer::parseSmart( css::util::URL& aURL,
bool bOk = aParser.SetSmartURL( aURL.Complete ); bool bOk = aParser.SetSmartURL( aURL.Complete );
if ( bOk ) if ( bOk )
{ {
lcl_ParserHelper(aParser,aURL,true); lcl_ParserHelper(aParser,aURL);
// Return "URL is parsed". // Return "URL is parsed".
return true; return true;
} }

View File

@@ -101,7 +101,7 @@ void SAL_CALL AcceleratorConfigurationReader::startElement(const OUString&
switch(eAttribute) switch(eAttribute)
{ {
case E_ATTRIBUTE_URL : case E_ATTRIBUTE_URL :
sCommand = sValue.intern(); sCommand = sValue;
break; break;
case E_ATTRIBUTE_KEYCODE : case E_ATTRIBUTE_KEYCODE :

View File

@@ -83,7 +83,7 @@ namespace oox::ppt {
if(msCurrentAttribute.equalsAscii( attrConv->mpMSName ) ) if(msCurrentAttribute.equalsAscii( attrConv->mpMSName ) )
{ {
Attribute attr; Attribute attr;
attr.name = OUString::intern( attrConv->mpAPIName, attr.name = OUString( attrConv->mpAPIName,
strlen(attrConv->mpAPIName), strlen(attrConv->mpAPIName),
RTL_TEXTENCODING_ASCII_US ); RTL_TEXTENCODING_ASCII_US );
attr.type = attrConv->meAttribute; attr.type = attrConv->meAttribute;

View File

@@ -894,7 +894,7 @@ void ScXMLExport::ExportExternalRefCacheStyles()
// Export each unique number format used in the external ref cache. // Export each unique number format used in the external ref cache.
vector<sal_uInt32> aNumFmts; vector<sal_uInt32> aNumFmts;
pRefMgr->getAllCachedNumberFormats(aNumFmts); pRefMgr->getAllCachedNumberFormats(aNumFmts);
const OUString aDefaultStyle = OUString("Default").intern(); static constexpr OUStringLiteral aDefaultStyle(u"Default");
for (const auto& rNumFmt : aNumFmts) for (const auto& rNumFmt : aNumFmts)
{ {
sal_Int32 nNumFmt = static_cast<sal_Int32>(rNumFmt); sal_Int32 nNumFmt = static_cast<sal_Int32>(rNumFmt);
@@ -904,7 +904,7 @@ void ScXMLExport::ExportExternalRefCacheStyles()
uno::Any aVal; uno::Any aVal;
aVal <<= nNumFmt; aVal <<= nNumFmt;
vector<XMLPropertyState> aProps; vector<XMLPropertyState> aProps;
aVal <<= aDefaultStyle; aVal <<= OUString(aDefaultStyle);
aProps.emplace_back(nEntryIndex, aVal); aProps.emplace_back(nEntryIndex, aVal);
OUString aName; OUString aName;

View File

@@ -1838,8 +1838,8 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
p->rINetAttr.GetINetFormat().GetValue(), p->rINetAttr.GetINetFormat().GetValue(),
INetURLObject::DecodeMechanism::Unambiguous ) ); INetURLObject::DecodeMechanism::Unambiguous ) );
// We have to distinguish between intern and real URLs // We have to distinguish between internal and real URLs
const bool bIntern = '#' == aURL[0]; const bool bInternal = '#' == aURL[0];
// GetCursor_() is a SwShellCursor, which is derived from // GetCursor_() is a SwShellCursor, which is derived from
// SwSelPaintRects, therefore the rectangles of the current // SwSelPaintRects, therefore the rectangles of the current
@@ -1856,7 +1856,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
// Create the destination for internal links: // Create the destination for internal links:
sal_Int32 nDestId = -1; sal_Int32 nDestId = -1;
if ( bIntern ) if ( bInternal )
{ {
aURL = aURL.copy( 1 ); aURL = aURL.copy( 1 );
mrSh.SwCursorShell::ClearMark(); mrSh.SwCursorShell::ClearMark();
@@ -1882,7 +1882,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
} }
} }
if ( !bIntern || -1 != nDestId ) if ( !bInternal || -1 != nDestId )
{ {
// #i44368# Links in Header/Footer // #i44368# Links in Header/Footer
const bool bHeaderFooter = pDoc->IsInHeaderFooter( *pTNd ); const bool bHeaderFooter = pDoc->IsInHeaderFooter( *pTNd );
@@ -1909,14 +1909,14 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
s_aLinkIdMap.push_back( aLinkEntry ); s_aLinkIdMap.push_back( aLinkEntry );
// Connect Link and Destination: // Connect Link and Destination:
if ( bIntern ) if ( bInternal )
pPDFExtOutDevData->SetLinkDest( nLinkId, nDestId ); pPDFExtOutDevData->SetLinkDest( nLinkId, nDestId );
else else
pPDFExtOutDevData->SetLinkURL( nLinkId, aURL ); pPDFExtOutDevData->SetLinkURL( nLinkId, aURL );
// #i44368# Links in Header/Footer // #i44368# Links in Header/Footer
if ( bHeaderFooter ) if ( bHeaderFooter )
MakeHeaderFooterLinks(*pPDFExtOutDevData, *pTNd, rLinkRect, nDestId, aURL, bIntern, altText); MakeHeaderFooterLinks(*pPDFExtOutDevData, *pTNd, rLinkRect, nDestId, aURL, bInternal, altText);
} }
} }
} }
@@ -1943,11 +1943,11 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
OUString aURL( pItem->GetURL() ); OUString aURL( pItem->GetURL() );
if (aURL.isEmpty()) if (aURL.isEmpty())
continue; continue;
const bool bIntern = '#' == aURL[0]; const bool bInternal = '#' == aURL[0];
// Create the destination for internal links: // Create the destination for internal links:
sal_Int32 nDestId = -1; sal_Int32 nDestId = -1;
if ( bIntern ) if ( bInternal )
{ {
aURL = aURL.copy( 1 ); aURL = aURL.copy( 1 );
mrSh.SwCursorShell::ClearMark(); mrSh.SwCursorShell::ClearMark();
@@ -1972,7 +1972,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
} }
} }
if ( !bIntern || -1 != nDestId ) if ( !bInternal || -1 != nDestId )
{ {
Point aNullPt; Point aNullPt;
const SwRect aLinkRect = pFrameFormat->FindLayoutRect( false, &aNullPt ); const SwRect aLinkRect = pFrameFormat->FindLayoutRect( false, &aNullPt );
@@ -1988,7 +1988,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
pPDFExtOutDevData->CreateLink(aRect, formatName, aLinkPageNum); pPDFExtOutDevData->CreateLink(aRect, formatName, aLinkPageNum);
// Connect Link and Destination: // Connect Link and Destination:
if ( bIntern ) if ( bInternal )
pPDFExtOutDevData->SetLinkDest( nLinkId, nDestId ); pPDFExtOutDevData->SetLinkDest( nLinkId, nDestId );
else else
pPDFExtOutDevData->SetLinkURL( nLinkId, aURL ); pPDFExtOutDevData->SetLinkURL( nLinkId, aURL );
@@ -2002,7 +2002,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
{ {
const SwTextNode* pTNd = pAnchorNode->GetTextNode(); const SwTextNode* pTNd = pAnchorNode->GetTextNode();
if ( pTNd ) if ( pTNd )
MakeHeaderFooterLinks(*pPDFExtOutDevData, *pTNd, aLinkRect, nDestId, aURL, bIntern, formatName); MakeHeaderFooterLinks(*pPDFExtOutDevData, *pTNd, aLinkRect, nDestId, aURL, bInternal, formatName);
} }
} }
} }
@@ -2358,8 +2358,8 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
for ( const auto& rBookmark : rBookmarks ) for ( const auto& rBookmark : rBookmarks )
{ {
OUString aBookmarkName( rBookmark.aBookmark ); OUString aBookmarkName( rBookmark.aBookmark );
const bool bIntern = '#' == aBookmarkName[0]; const bool bInternal = '#' == aBookmarkName[0];
if ( bIntern ) if ( bInternal )
{ {
aBookmarkName = aBookmarkName.copy( 1 ); aBookmarkName = aBookmarkName.copy( 1 );
JumpToSwMark( &mrSh, aBookmarkName ); JumpToSwMark( &mrSh, aBookmarkName );
@@ -2632,7 +2632,7 @@ void SwEnhancedPDFExportHelper::MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rP
const SwRect& rLinkRect, const SwRect& rLinkRect,
sal_Int32 nDestId, sal_Int32 nDestId,
const OUString& rURL, const OUString& rURL,
bool bIntern, bool bInternal,
OUString const& rContent) const OUString const& rContent) const
{ {
// We assume, that the primary link has just been exported. Therefore // We assume, that the primary link has just been exported. Therefore
@@ -2663,7 +2663,7 @@ void SwEnhancedPDFExportHelper::MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rP
rPDFExtOutDevData.CreateLink(aRect, rContent, aHFLinkPageNum); rPDFExtOutDevData.CreateLink(aRect, rContent, aHFLinkPageNum);
// Connect Link and Destination: // Connect Link and Destination:
if ( bIntern ) if ( bInternal )
rPDFExtOutDevData.SetLinkDest( nHFLinkId, nDestId ); rPDFExtOutDevData.SetLinkDest( nHFLinkId, nDestId );
else else
rPDFExtOutDevData.SetLinkURL( nHFLinkId, rURL ); rPDFExtOutDevData.SetLinkURL( nHFLinkId, rURL );

View File

@@ -707,8 +707,8 @@ void CURI::initFromConstant(const sal_Int16 i_Constant)
throw css::lang::IllegalArgumentException( throw css::lang::IllegalArgumentException(
"CURI::initialize: invalid URIs constant argument", *this, 0); "CURI::initialize: invalid URIs constant argument", *this, 0);
} }
m_Namespace = OUString::createFromAscii(ns).intern(); m_Namespace = OUString::createFromAscii(ns);
m_LocalName = OUString::createFromAscii(ln).intern(); m_LocalName = OUString::createFromAscii(ln);
} }
// css::lang::XInitialization: // css::lang::XInitialization: