svl/source/misc/inettype.cxx |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 22e6fb8e2e78d753c65e8966cd3c85d81ffbb04f
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jul 25 11:43:20 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jul 26 13:46:15 2025 +0200

    constify aStaticTypeNameMap
    
    and reduce its size, we don't need to store entries that map to an empty 
string
    
    Change-Id: I2520ba84b2facf89fa4cc1cc8c6ae0d88fc56c6a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188326
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    (cherry picked from commit d174753fd085af7f2d5358b515e7fa9ee3f8445a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188395
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx
index 7487214bc071..a6a24ef92de8 100644
--- a/svl/source/misc/inettype.cxx
+++ b/svl/source/misc/inettype.cxx
@@ -44,7 +44,7 @@ MediaTypeEntry const * seekEntry(OUString const & rTypeName,
 /** A mapping from type names to type ids and extensions.  Sorted by type
     name.
  */
-MediaTypeEntry const aStaticTypeNameMap[CONTENT_TYPE_LAST + 1]
+constexpr MediaTypeEntry aStaticTypeNameMap[]
     = { { u" "_ustr, CONTENT_TYPE_UNKNOWN },
         { CONTENT_TYPE_STR_X_CNT_FSYSBOX, CONTENT_TYPE_X_CNT_FSYSBOX },
         { CONTENT_TYPE_STR_X_CNT_FSYSFOLDER, CONTENT_TYPE_X_CNT_FSYSFOLDER },
@@ -265,7 +265,7 @@ INetContentType INetContentTypes::GetContentType(OUString 
const & rTypeName)
     {
         aType += "/" + aSubType;
         MediaTypeEntry const * pEntry = seekEntry(aType, aStaticTypeNameMap,
-                                                  CONTENT_TYPE_LAST + 1);
+                                                  
SAL_N_ELEMENTS(aStaticTypeNameMap) + 1);
         return pEntry ? pEntry->m_eTypeID : CONTENT_TYPE_UNKNOWN;
     }
     else
@@ -280,8 +280,8 @@ OUString INetContentTypes::GetContentType(INetContentType 
eTypeID)
     static std::array<OUString, CONTENT_TYPE_LAST + 1> aMap = []()
     {
         std::array<OUString, CONTENT_TYPE_LAST + 1> tmp;
-        for (std::size_t i = 0; i <= CONTENT_TYPE_LAST; ++i)
-            tmp[aStaticTypeNameMap[i].m_eTypeID] = 
aStaticTypeNameMap[i].m_pTypeName;
+        for (const auto & rEntry : aStaticTypeNameMap)
+            tmp[rEntry.m_eTypeID] = rEntry.m_pTypeName;
         tmp[CONTENT_TYPE_UNKNOWN] = CONTENT_TYPE_STR_APP_OCTSTREAM;
         tmp[CONTENT_TYPE_TEXT_PLAIN] = CONTENT_TYPE_STR_TEXT_PLAIN +
                                         "; charset=iso-8859-1";

Reply via email to