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

View File

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

View File

@ -101,7 +101,6 @@ static void ExtractStatusbarItemParameters(
if ( rEntry.Name == ITEM_DESCRIPTOR_COMMANDURL )
{
rEntry.Value >>= rCommandURL;
rCommandURL = rCommandURL.intern();
}
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 )
{
if ( rEntry.Name == ITEM_DESCRIPTOR_COMMANDURL )
{
rEntry.Value >>= rCommandURL;
rCommandURL = rCommandURL.intern();
}
else if ( rEntry.Name == ITEM_DESCRIPTOR_LABEL )
rEntry.Value >>= rLabel;
else if ( rEntry.Name == ITEM_DESCRIPTOR_TYPE )
@ -284,7 +281,7 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
case TB_ATTRIBUTE_URL:
{
bAttributeURL = true;
aCommandURL = xAttribs->getValueByIndex( n ).intern();
aCommandURL = xAttribs->getValueByIndex( n );
}
break;

View File

@ -58,7 +58,7 @@ public:
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.
_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
// back Complete to have a valid encoded URL in all cases!
_rURL.Complete = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE );
if ( _bUseIntern )
_rURL.Complete = _rURL.Complete.intern();
_rParser.SetMark( u"" );
_rParser.SetParam( u"" );
@ -136,7 +134,7 @@ sal_Bool SAL_CALL URLTransformer::parseStrict( css::util::URL& aURL )
}
else if ( !aParser.HasError() )
{
lcl_ParserHelper(aParser,aURL,false);
lcl_ParserHelper(aParser,aURL);
// Return "URL is parsed".
return true;
}
@ -174,7 +172,7 @@ sal_Bool SAL_CALL URLTransformer::parseSmart( css::util::URL& aURL,
bool bOk = aParser.SetSmartURL( aURL.Complete );
if ( bOk )
{
lcl_ParserHelper(aParser,aURL,true);
lcl_ParserHelper(aParser,aURL);
// Return "URL is parsed".
return true;
}

View File

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

View File

@ -83,9 +83,9 @@ namespace oox::ppt {
if(msCurrentAttribute.equalsAscii( attrConv->mpMSName ) )
{
Attribute attr;
attr.name = OUString::intern( attrConv->mpAPIName,
strlen(attrConv->mpAPIName),
RTL_TEXTENCODING_ASCII_US );
attr.name = OUString( attrConv->mpAPIName,
strlen(attrConv->mpAPIName),
RTL_TEXTENCODING_ASCII_US );
attr.type = attrConv->meAttribute;
maAttributes.push_back( attr );
SAL_INFO("oox.ppt", "OOX: attrName is " << msCurrentAttribute << " -> " << attrConv->mpAPIName );

View File

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

View File

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

View File

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