Simplify a bit

Change-Id: I224602738ce41529cc5eca681f09db31241a5cac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175385
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2024-10-21 21:30:22 +02:00
parent dd18703696
commit 7a7b1f9cbd

View file

@ -33,17 +33,15 @@ void XMLNamespaces::addNamespace( const OUString& aName, const OUString& aValue
OUString aNamespaceName( aName );
// delete preceding "xmlns"
constexpr char aXMLAttributeNamespace[] = "xmlns";
if ( aNamespaceName.startsWith( aXMLAttributeNamespace ) )
if (std::u16string_view rest; aNamespaceName.startsWith("xmlns", &rest))
{
constexpr sal_Int32 nXMLNamespaceLength = RTL_CONSTASCII_LENGTH(aXMLAttributeNamespace);
if ( aNamespaceName.getLength() == nXMLNamespaceLength )
if (rest.empty())
{
aNamespaceName.clear();
}
else if ( aNamespaceName.getLength() >= nXMLNamespaceLength+2 )
else if (rest.size() > 1)
{
aNamespaceName = aNamespaceName.copy( nXMLNamespaceLength+1 );
aNamespaceName = rest.substr(1);
}
else
{