[network/kio-extras] /: workers: fill UDSEntry one value type at a time

Méven Car <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit d1749b4b8f3bfaab8ba7afc5d40d5a49884648e9 by Méven Car.
Committed on 29/07/2026 at 07:31.
Pushed by meven into branch 'master'.

workers: fill UDSEntry one value type at a time

Since KIO 6.29 a UDSEntry keeps its string values and its number values in
two separate vectors. Filling one vector and then the other is faster than
alternating between them, and the memory for each one is reserved on its
own. The workers here built their entries in whatever order the fields came
to mind, so most of them jumped between the two vectors several times per
entry.

Group the fields by value type, so that each entry inserts all of its
strings and then all of its numbers. Where the field values arrive in an
order the worker does not choose, such as the file info dictionary the afc
device returns, collect them in local variables first and insert them
grouped afterwards.

The new common/udsentry_compat.h wraps the per-type reserve and the two
insert overloads that take an initializer list. It keeps the version check
in one place, so a build against KIO older than 6.29 still gets the single
reserve and a plain fastInsert for each field. The header can be removed
once KF_MIN_VERSION reaches 6.29.

M  +1    -1    CMakeLists.txt
M  +25   -16   activities/KioActivities.cpp
M  +15   -9    activities/KioActivitiesApi.cpp
M  +7    -3    afc/afcapp.cpp
M  +39   -10   afc/afcclient.cpp
M  +34   -23   afc/kio_afc.cpp
M  +37   -21   archive/kio_archivebase.cpp
A  +71   -0    common/udsentry_compat.h     [License: LGPL(v2.0+)]
M  +33   -18   filenamesearch/kio_filenamesearch.cpp
M  +20   -9    man/kio_man.cpp
M  +58   -34   mtp/kio_mtp.cpp
M  +13   -6    nfs/kio_nfs.cpp
M  +35   -24   recentlyused/recentlyused.cpp
M  +33   -21   sftp/kio_sftp.cpp
M  +13   -8    smb/dnssddiscoverer.cpp
M  +18   -8    smb/kio_smb_browse.cpp
M  +43   -19   smb/smbcdiscoverer.cpp
M  +13   -9    smb/wsdiscoverer.cpp

https://invent.kde.org/network/kio-extras/-/commit/d1749b4b8f3bfaab8ba7afc5d40d5a49884648e9

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e0bc974b..734cd3d20 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -105,7 +105,7 @@ if (BUILD_DOC)
     )
 endif()
 
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/common)
 
 if(NOT WIN32)
     # we need a version of samba which has already smbc_set_context(), Alex
diff --git a/activities/KioActivities.cpp b/activities/KioActivities.cpp
index 71acff09f..f65381bf0 100644
--- a/activities/KioActivities.cpp
+++ b/activities/KioActivities.cpp
@@ -7,6 +7,7 @@
 
 #include "KioActivities.h"
 #include "KioActivitiesApi.h"
+#include "udsentry_compat.h"
 
 #include <QCoreApplication>
 
@@ -103,16 +104,22 @@ KIO::WorkerResult ActivitiesProtocol::listDir(const QUrl &url)
         KIO::UDSEntryList udslist;
 
         KIO::UDSEntry uds;
-        uds.reserve(9);
-        uds.fastInsert(KIO::UDSEntry::UDS_NAME, QStringLiteral("current"));
-        uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("Current activity"));
-        uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_TYPE, i18n("Activity"));
-        uds.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("activities"));
-        uds.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-        uds.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
-        uds.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0500);
-        uds.fastInsert(KIO::UDSEntry::UDS_USER, KUser().loginName());
-        uds.fastInsert(KIO::UDSEntry::UDS_TARGET_URL, QStringLiteral("activities:/") + activities.currentActivity());
+        const QString currentActivityUrl = QStringLiteral("activities:/") + activities.currentActivity();
+        KIOExtras::insertStrings(uds,
+                                 {
+                                     {KIO::UDSEntry::UDS_NAME, QStringLiteral("current")},
+                                     {KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("Current activity")},
+                                     {KIO::UDSEntry::UDS_DISPLAY_TYPE, i18n("Activity")},
+                                     {KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("activities")},
+                                     {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                                     {KIO::UDSEntry::UDS_USER, KUser().loginName()},
+                                     {KIO::UDSEntry::UDS_TARGET_URL, currentActivityUrl},
+                                 });
+        KIOExtras::insertNumbers(uds,
+                                 {
+                                     {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                     {KIO::UDSEntry::UDS_ACCESS, 0500},
+                                 });
         udslist << uds;
 
         for (const auto &activity : activities.activities()) {
@@ -175,13 +182,15 @@ KIO::WorkerResult ActivitiesProtocol::stat(const QUrl &url)
     case ActivitiesProtocolApi::RootItem: {
         QString dirName = i18n("Activities");
         KIO::UDSEntry uds;
-        uds.reserve(6);
-        uds.fastInsert(KIO::UDSEntry::UDS_NAME, dirName);
-        uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, dirName);
-        uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_TYPE, dirName);
-        uds.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("activities"));
+        KIOExtras::insertStrings(uds,
+                                 {
+                                     {KIO::UDSEntry::UDS_NAME, dirName},
+                                     {KIO::UDSEntry::UDS_DISPLAY_NAME, dirName},
+                                     {KIO::UDSEntry::UDS_DISPLAY_TYPE, dirName},
+                                     {KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("activities")},
+                                     {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                                 });
         uds.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-        uds.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
 
         statEntry(uds);
 
diff --git a/activities/KioActivitiesApi.cpp b/activities/KioActivitiesApi.cpp
index d7bcd7241..2db0e8e0a 100644
--- a/activities/KioActivitiesApi.cpp
+++ b/activities/KioActivitiesApi.cpp
@@ -7,6 +7,7 @@
 
 #include "KioActivitiesApi.h"
 #include "KioActivities.h"
+#include "udsentry_compat.h"
 
 #include <QCoreApplication>
 
@@ -79,16 +80,21 @@ void ActivitiesProtocolApi::syncActivities(KActivities::Consumer &activities)
 KIO::UDSEntry ActivitiesProtocolApi::activityEntry(const QString &activity)
 {
     KIO::UDSEntry uds;
-    uds.reserve(8);
     KActivities::Info activityInfo(activity);
-    uds.fastInsert(KIO::UDSEntry::UDS_NAME, activity);
-    uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, activityInfo.name());
-    uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_TYPE, i18n("Activity"));
-    uds.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, activityInfo.icon());
-    uds.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    uds.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
-    uds.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0500);
-    uds.fastInsert(KIO::UDSEntry::UDS_USER, KUser().loginName());
+    KIOExtras::insertStrings(uds,
+                             {
+                                 {KIO::UDSEntry::UDS_NAME, activity},
+                                 {KIO::UDSEntry::UDS_DISPLAY_NAME, activityInfo.name()},
+                                 {KIO::UDSEntry::UDS_DISPLAY_TYPE, i18n("Activity")},
+                                 {KIO::UDSEntry::UDS_ICON_NAME, activityInfo.icon()},
+                                 {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                                 {KIO::UDSEntry::UDS_USER, KUser().loginName()},
+                             });
+    KIOExtras::insertNumbers(uds,
+                             {
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {KIO::UDSEntry::UDS_ACCESS, 0500},
+                             });
     return uds;
 }
 
diff --git a/afc/afcapp.cpp b/afc/afcapp.cpp
index 35bb240a5..ebe28ef87 100644
--- a/afc/afcapp.cpp
+++ b/afc/afcapp.cpp
@@ -4,6 +4,7 @@
  */
 
 #include "afcapp.h"
+#include "udsentry_compat.h"
 
 #include "afc_debug.h"
 
@@ -80,11 +81,14 @@ QString AfcApp::iconPath() const
 UDSEntry AfcApp::entry(const QString &name) const
 {
     UDSEntry entry;
-    entry.fastInsert(UDSEntry::UDS_NAME, !name.isEmpty() ? name : m_bundleId);
-    entry.fastInsert(UDSEntry::UDS_DISPLAY_NAME, m_displayName);
-    entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {UDSEntry::UDS_NAME, !name.isEmpty() ? name : m_bundleId},
+                                 {UDSEntry::UDS_DISPLAY_NAME, m_displayName},
+                             });
     if (!m_iconPath.isEmpty()) {
         entry.fastInsert(UDSEntry::UDS_ICON_NAME, m_iconPath);
     }
+    entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
     return entry;
 }
diff --git a/afc/afcclient.cpp b/afc/afcclient.cpp
index be5443720..aebc71a4b 100644
--- a/afc/afcclient.cpp
+++ b/afc/afcclient.cpp
@@ -5,6 +5,8 @@
 
 #include "afcclient.h"
 
+#include <optional>
+
 #include "afc_debug.h"
 
 #include "afcdevice.h"
@@ -152,26 +154,32 @@ WorkerResult AfcClient::entry(const QString &path, UDSEntry &entry)
     });
 
     const int lastSlashIdx = path.lastIndexOf(QLatin1Char('/'));
-    entry.fastInsert(UDSEntry::UDS_NAME, path.mid(lastSlashIdx + 1));
 
     // Apply special icons for known locations
+    QString iconName;
     if (m_appId.isEmpty()) {
         static const QHash<QString, QString> s_folderIcons = {{QStringLiteral("/DCIM"), QStringLiteral("camera-photo")},
                                                               {QStringLiteral("/Documents"), QStringLiteral("folder-documents")},
                                                               {QStringLiteral("/Downloads"), QStringLiteral("folder-downloads")},
                                                               {QStringLiteral("/Photos"), QStringLiteral("folder-pictures")}};
-        const QString iconName = s_folderIcons.value(path);
-        if (!iconName.isEmpty()) {
-            entry.fastInsert(UDSEntry::UDS_ICON_NAME, iconName);
-        }
+        iconName = s_folderIcons.value(path);
     }
 
+    // The device hands the file info back as an unordered list of key and value pairs. Collect the
+    // values here and insert them below, so that the entry gets all its strings and then all its
+    // numbers rather than a mix in whatever order the device chose.
+    bool isDirectory = false;
+    std::optional<long long> size;
+    std::optional<long long> fileType;
+    std::optional<long long> modificationTime;
+    std::optional<long long> creationTime;
+
     for (int i = 0; info[i]; i += 2) {
         const auto *key = info[i];
         const auto *value = info[i + 1];
 
         if (strcmp(key, "st_size") == 0) {
-            entry.fastInsert(UDSEntry::UDS_SIZE, atoll(value));
+            size = atoll(value);
         } else if (strcmp(key, "st_blocks") == 0) {
             // no UDS equivalent
         } else if (strcmp(key, "st_nlink") == 0) {
@@ -182,7 +190,7 @@ WorkerResult AfcClient::entry(const QString &path, UDSEntry &entry)
                 type = S_IFREG;
             } else if (strcmp(value, "S_IFDIR") == 0) {
                 type = S_IFDIR;
-                entry.fastInsert(UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
+                isDirectory = true;
             } else if (strcmp(value, "S_IFLNK") == 0) {
                 type = S_IFLNK;
             } else if (strcmp(value, "S_IFBLK") == 0) {
@@ -196,15 +204,15 @@ WorkerResult AfcClient::entry(const QString &path, UDSEntry &entry)
             }
 
             if (type) {
-                entry.fastInsert(UDSEntry::UDS_FILE_TYPE, type);
+                fileType = type;
             } else {
                 qCWarning(KIO_AFC_LOG) << "Encountered unknown" << key << "of" << value << "for" << path;
             }
             // is returned in nanoseconds
         } else if (strcmp(key, "st_mtime") == 0) {
-            entry.fastInsert(UDSEntry::UDS_MODIFICATION_TIME, atoll(value) / 1000000000);
+            modificationTime = atoll(value) / 1000000000;
         } else if (strcmp(key, "st_birthtime") == 0) {
-            entry.fastInsert(UDSEntry::UDS_CREATION_TIME, atoll(value) / 1000000000);
+            creationTime = atoll(value) / 1000000000;
         } else if (strcmp(key, "LinkTarget") == 0) {
             // TODO figure out why afc_make_link fails with AFC_E_OP_NOT_SUPPORTED and then implement this
             // entry.fastInsert(UDSEntry::UDS_LINK_DEST, QString::fromUtf8(value));
@@ -213,6 +221,27 @@ WorkerResult AfcClient::entry(const QString &path, UDSEntry &entry)
         }
     }
 
+    entry.fastInsert(UDSEntry::UDS_NAME, path.mid(lastSlashIdx + 1));
+    if (!iconName.isEmpty()) {
+        entry.fastInsert(UDSEntry::UDS_ICON_NAME, iconName);
+    }
+    if (isDirectory) {
+        entry.fastInsert(UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
+    }
+
+    if (size) {
+        entry.fastInsert(UDSEntry::UDS_SIZE, *size);
+    }
+    if (fileType) {
+        entry.fastInsert(UDSEntry::UDS_FILE_TYPE, *fileType);
+    }
+    if (modificationTime) {
+        entry.fastInsert(UDSEntry::UDS_MODIFICATION_TIME, *modificationTime);
+    }
+    if (creationTime) {
+        entry.fastInsert(UDSEntry::UDS_CREATION_TIME, *creationTime);
+    }
+
     return WorkerResult::pass();
 }
 
diff --git a/afc/kio_afc.cpp b/afc/kio_afc.cpp
index 0294f41d0..51640ef13 100644
--- a/afc/kio_afc.cpp
+++ b/afc/kio_afc.cpp
@@ -4,6 +4,7 @@
  */
 
 #include "kio_afc.h"
+#include "udsentry_compat.h"
 
 #include "afc_debug.h"
 
@@ -131,10 +132,13 @@ Result AfcWorker::clientForUrl(const AfcUrl &afcUrl, AfcClient::Ptr &client) con
 UDSEntry AfcWorker::overviewEntry(const QString &fileName) const
 {
     UDSEntry entry;
-    entry.fastInsert(UDSEntry::UDS_NAME, !fileName.isEmpty() ? fileName : i18n("Apple Devices"));
-    entry.fastInsert(UDSEntry::UDS_ICON_NAME, QStringLiteral("phone-apple-iphone"));
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {UDSEntry::UDS_NAME, !fileName.isEmpty() ? fileName : i18n("Apple Devices")},
+                                 {UDSEntry::UDS_ICON_NAME, QStringLiteral("phone-apple-iphone")},
+                                 {UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                             });
     entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
     return entry;
 }
 
@@ -143,16 +147,6 @@ UDSEntry AfcWorker::deviceEntry(const AfcDevice *device, const QString &fileName
     const QString deviceId = device->id();
     const QString deviceClass = device->deviceClass();
 
-    UDSEntry entry;
-    entry.fastInsert(UDSEntry::UDS_NAME, !fileName.isEmpty() ? fileName : deviceId);
-    if (!device->name().isEmpty()) {
-        entry.fastInsert(UDSEntry::UDS_DISPLAY_NAME, device->name());
-    }
-    // TODO prettier
-    entry.fastInsert(UDSEntry::UDS_DISPLAY_TYPE, deviceClass);
-    entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
-
     QString iconName;
     // We can assume iPod running iOS/supporting imobiledevice is an iPod touch?
     if (deviceClass.contains(QLatin1String("iPad"))) {
@@ -163,28 +157,45 @@ UDSEntry AfcWorker::deviceEntry(const AfcDevice *device, const QString &fileName
         iconName = QStringLiteral("phone-apple-iphone");
     }
 
-    entry.fastInsert(UDSEntry::UDS_ICON_NAME, iconName);
+    UDSEntry entry;
+    // TODO prettier display type
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {UDSEntry::UDS_NAME, !fileName.isEmpty() ? fileName : deviceId},
+                                 {UDSEntry::UDS_DISPLAY_TYPE, deviceClass},
+                                 {UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                                 {UDSEntry::UDS_ICON_NAME, iconName},
+                             });
+    if (!device->name().isEmpty()) {
+        entry.fastInsert(UDSEntry::UDS_DISPLAY_NAME, device->name());
+    }
 
     if (asLink) {
         const QString contentsUrl = QStringLiteral("afc://%1/").arg(deviceId);
-        entry.fastInsert(UDSEntry::UDS_LINK_DEST, contentsUrl);
-        entry.fastInsert(UDSEntry::UDS_TARGET_URL, contentsUrl);
+        KIOExtras::insertStrings(entry,
+                                 {
+                                     {UDSEntry::UDS_LINK_DEST, contentsUrl},
+                                     {UDSEntry::UDS_TARGET_URL, contentsUrl},
+                                 });
     }
 
+    entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
     return entry;
 }
 
 UDSEntry AfcWorker::appsOverviewEntry(const AfcDevice *device, const QString &fileName) const
 {
     UDSEntry entry;
-    entry.fastInsert(UDSEntry::UDS_NAME, !fileName.isEmpty() ? fileName : AfcUrl::appsTag());
-    entry.fastInsert(UDSEntry::UDS_DISPLAY_NAME, i18nc("Link to folder with files stored inside apps", "Apps"));
-    entry.fastInsert(UDSEntry::UDS_ICON_NAME, QStringLiteral("folder-documents"));
-    entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-
     const QString appsUrl = QStringLiteral("afc://%1/%2/").arg(device->id(), AfcUrl::appsTag());
-    entry.fastInsert(UDSEntry::UDS_LINK_DEST, appsUrl);
-    entry.fastInsert(UDSEntry::UDS_TARGET_URL, appsUrl);
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {UDSEntry::UDS_NAME, !fileName.isEmpty() ? fileName : AfcUrl::appsTag()},
+                                 {UDSEntry::UDS_DISPLAY_NAME, i18nc("Link to folder with files stored inside apps", "Apps")},
+                                 {UDSEntry::UDS_ICON_NAME, QStringLiteral("folder-documents")},
+                                 {UDSEntry::UDS_LINK_DEST, appsUrl},
+                                 {UDSEntry::UDS_TARGET_URL, appsUrl},
+                             });
+    entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
 
     return entry;
 }
diff --git a/archive/kio_archivebase.cpp b/archive/kio_archivebase.cpp
index 07e8610b7..a58aa0af7 100644
--- a/archive/kio_archivebase.cpp
+++ b/archive/kio_archivebase.cpp
@@ -5,6 +5,7 @@
 */
 
 #include "kio_archivebase.h"
+#include "udsentry_compat.h"
 #include <kio_archive_debug.h>
 
 #include <errno.h>
@@ -188,41 +189,56 @@ KIO::StatDetails ArchiveProtocolBase::getStatDetails() const
 void ArchiveProtocolBase::createRootUDSEntry(KIO::UDSEntry &entry)
 {
     entry.clear();
-    entry.reserve(7);
 
     auto path = m_archiveFile->fileName();
     path = path.mid(path.lastIndexOf(QLatin1Char('/')) + 1);
 
-    entry.fastInsert(KIO::UDSEntry::UDS_NAME, QStringLiteral("."));
-    entry.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, path);
-    entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, m_mtime);
-    // entry.fastInsert( KIO::UDSEntry::UDS_ACCESS, 07777 ); // fake 'x' permissions, this is a pseudo-directory
-    entry.fastInsert(KIO::UDSEntry::UDS_USER, m_user);
-    entry.fastInsert(KIO::UDSEntry::UDS_GROUP, m_group);
-
     QMimeDatabase db;
-    QMimeType mt = db.mimeTypeForFile(m_archiveFile->fileName());
+    const QMimeType mt = db.mimeTypeForFile(m_archiveFile->fileName());
+
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_NAME, QStringLiteral(".")},
+                                 {KIO::UDSEntry::UDS_DISPLAY_NAME, path},
+                                 {KIO::UDSEntry::UDS_USER, m_user},
+                                 {KIO::UDSEntry::UDS_GROUP, m_group},
+                             });
     if (mt.isValid()) {
         entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, mt.name());
     }
+
+    // no UDS_ACCESS, the fake 'x' permissions of this pseudo-directory are left out
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {KIO::UDSEntry::UDS_MODIFICATION_TIME, m_mtime},
+                             });
 }
 
 void ArchiveProtocolBase::createUDSEntry(const KArchiveEntry *archiveEntry, UDSEntry &entry)
 {
     entry.clear();
 
-    entry.reserve(8);
-    entry.fastInsert(KIO::UDSEntry::UDS_NAME, archiveEntry->name());
-    entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, archiveEntry->isFile() ? archiveEntry->permissions() & S_IFMT : S_IFDIR); // keep file type only
-    if (archiveEntry->isFile()) {
-        entry.fastInsert(KIO::UDSEntry::UDS_SIZE, ((KArchiveFile *)archiveEntry)->size());
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_NAME, archiveEntry->name()},
+                                 {KIO::UDSEntry::UDS_USER, archiveEntry->user()},
+                                 {KIO::UDSEntry::UDS_GROUP, archiveEntry->group()},
+                                 {KIO::UDSEntry::UDS_LINK_DEST, archiveEntry->symLinkTarget()},
+                             });
+
+    const bool isFile = archiveEntry->isFile();
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 // keep file type only
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, isFile ? archiveEntry->permissions() & S_IFMT : S_IFDIR},
+                                 {KIO::UDSEntry::UDS_MODIFICATION_TIME, archiveEntry->date().toSecsSinceEpoch()},
+                                 // keep permissions only
+                                 {KIO::UDSEntry::UDS_ACCESS, archiveEntry->permissions() & 07777},
+                             });
+    if (isFile) {
+        entry.fastInsert(KIO::UDSEntry::UDS_SIZE, static_cast<const KArchiveFile *>(archiveEntry)->size());
     }
-    entry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, archiveEntry->date().toSecsSinceEpoch());
-    entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, archiveEntry->permissions() & 07777); // keep permissions only
-    entry.fastInsert(KIO::UDSEntry::UDS_USER, archiveEntry->user());
-    entry.fastInsert(KIO::UDSEntry::UDS_GROUP, archiveEntry->group());
-    entry.fastInsert(KIO::UDSEntry::UDS_LINK_DEST, archiveEntry->symLinkTarget());
 }
 
 KIO::WorkerResult ArchiveProtocolBase::listDir(const QUrl &url)
@@ -321,7 +337,7 @@ KIO::WorkerResult ArchiveProtocolBase::stat(const QUrl &url)
             // We have any other error
             return KIO::WorkerResult::fail(errorNum, url.toDisplayString());
         }
-        entry.reserve(2);
+        KIOExtras::reserveEntry(entry, 1, 1);
         // Real directory. Return just enough information for KRun to work
         entry.fastInsert(KIO::UDSEntry::UDS_NAME, url.fileName());
         qCDebug(KIO_ARCHIVE_LOG) << "returning name" << url.fileName();
diff --git a/common/udsentry_compat.h b/common/udsentry_compat.h
new file mode 100644
index 000000000..94a8fc8e9
--- /dev/null
+++ b/common/udsentry_compat.h
@@ -0,0 +1,71 @@
+/*
+ *   SPDX-FileCopyrightText: 2026 Méven Car <[email protected]>
+ *
+ *   SPDX-License-Identifier: LGPL-2.0-or-later
+ */
+
+#pragma once
+
+#include <kio/udsentry.h>
+#include <kio_version.h>
+
+#include <initializer_list>
+#include <utility>
+
+/*
+ * UDSEntry keeps string values and number values in two separate vectors since KIO 6.29.
+ * Filling one vector and then the other is faster than alternating between them, and the
+ * pre-allocation is per vector as well. The helpers below give a worker one way to write
+ * that which also builds against the older single-vector UDSEntry.
+ *
+ * Once KF_MIN_VERSION reaches 6.29 this header can go away. Call KIO::UDSEntry::reserveStrings
+ * and KIO::UDSEntry::reserveNumbers in place of reserveEntry, and the two KIO::UDSEntry::insert
+ * overloads taking an initializer list in place of insertStrings and insertNumbers.
+ */
+namespace KIOExtras
+{
+
+/*
+ * Pre-allocates room for stringFields string values and numberFields number values.
+ */
+inline void reserveEntry(KIO::UDSEntry &entry, int stringFields, int numberFields)
+{
+#if KIO_VERSION >= QT_VERSION_CHECK(6, 29, 0)
+    entry.reserveStrings(stringFields);
+    entry.reserveNumbers(numberFields);
+#else
+    entry.reserve(stringFields + numberFields);
+#endif
+}
+
+/*
+ * Inserts string fields, pre-allocating room for all of them first.
+ */
+inline void insertStrings(KIO::UDSEntry &entry, std::initializer_list<std::pair<uint, const QString &>> fieldValuePairs)
+{
+#if KIO_VERSION >= QT_VERSION_CHECK(6, 29, 0)
+    entry.insert(fieldValuePairs);
+#else
+    entry.reserve(entry.count() + int(fieldValuePairs.size()));
+    for (const auto &[field, value] : fieldValuePairs) {
+        entry.fastInsert(field, value);
+    }
+#endif
+}
+
+/*
+ * Inserts number fields, pre-allocating room for all of them first.
+ */
+inline void insertNumbers(KIO::UDSEntry &entry, std::initializer_list<std::pair<uint, long long>> fieldValuePairs)
+{
+#if KIO_VERSION >= QT_VERSION_CHECK(6, 29, 0)
+    entry.insert(fieldValuePairs);
+#else
+    entry.reserve(entry.count() + int(fieldValuePairs.size()));
+    for (const auto &[field, value] : fieldValuePairs) {
+        entry.fastInsert(field, value);
+    }
+#endif
+}
+
+}
diff --git a/filenamesearch/kio_filenamesearch.cpp b/filenamesearch/kio_filenamesearch.cpp
index c63830006..72e11752f 100644
--- a/filenamesearch/kio_filenamesearch.cpp
+++ b/filenamesearch/kio_filenamesearch.cpp
@@ -7,6 +7,7 @@
 
 #include "kio_filenamesearch.h"
 #include "kio_filenamesearch_p.h"
+#include "udsentry_compat.h"
 
 #include "kio_filenamesearch_debug.h"
 
@@ -94,21 +95,30 @@ KIO::WorkerResult FileNameSearchProtocol::stat(const QUrl &url)
     }
 
     KIO::UDSEntry uds;
-    uds.reserve(9);
-    uds.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0700);
-    uds.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    uds.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
-    uds.fastInsert(KIO::UDSEntry::UDS_ICON_OVERLAY_NAMES, QStringLiteral("baloo"));
-    uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_TYPE, i18n("Search Folder"));
-    uds.fastInsert(KIO::UDSEntry::UDS_URL, url.url());
+    KIOExtras::insertStrings(uds,
+                             {
+                                 {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                                 {KIO::UDSEntry::UDS_ICON_OVERLAY_NAMES, QStringLiteral("baloo")},
+                                 {KIO::UDSEntry::UDS_DISPLAY_TYPE, i18n("Search Folder")},
+                                 {KIO::UDSEntry::UDS_URL, url.url()},
+                             });
 
     QUrlQuery query(url);
     QString title = query.queryItemValue(QStringLiteral("title"), QUrl::FullyDecoded);
     if (!title.isEmpty()) {
-        uds.fastInsert(KIO::UDSEntry::UDS_NAME, title);
-        uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, title);
+        KIOExtras::insertStrings(uds,
+                                 {
+                                     {KIO::UDSEntry::UDS_NAME, title},
+                                     {KIO::UDSEntry::UDS_DISPLAY_NAME, title},
+                                 });
     }
 
+    KIOExtras::insertNumbers(uds,
+                             {
+                                 {KIO::UDSEntry::UDS_ACCESS, 0700},
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                             });
+
     statEntry(uds);
     return KIO::WorkerResult::pass();
 }
@@ -117,11 +127,13 @@ KIO::WorkerResult FileNameSearchProtocol::stat(const QUrl &url)
 void FileNameSearchProtocol::listRootEntry()
 {
     KIO::UDSEntry entry;
-    entry.reserve(4);
     entry.fastInsert(KIO::UDSEntry::UDS_NAME, QStringLiteral("."));
-    entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(KIO::UDSEntry::UDS_SIZE, 0);
-    entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH);
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {KIO::UDSEntry::UDS_SIZE, 0},
+                                 {KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH},
+                             });
     listEntry(entry);
 }
 
@@ -732,11 +744,14 @@ KIO::WorkerResult FileNameSearchProtocol::searchDirWithExternalTool(const QUrl &
         QString fullPath = rootDir.filePath(relativePath);
         url.setPath(fullPath);
         KIO::UDSEntry uds;
-        uds.reserve(4);
-        uds.fastInsert(KIO::UDSEntry::UDS_NAME, url.fileName());
-        uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, url.fileName());
-        uds.fastInsert(KIO::UDSEntry::UDS_URL, url.url());
-        uds.fastInsert(KIO::UDSEntry::UDS_LOCAL_PATH, fullPath);
+        const QString fileName = url.fileName();
+        KIOExtras::insertStrings(uds,
+                                 {
+                                     {KIO::UDSEntry::UDS_NAME, fileName},
+                                     {KIO::UDSEntry::UDS_DISPLAY_NAME, fileName},
+                                     {KIO::UDSEntry::UDS_URL, url.url()},
+                                     {KIO::UDSEntry::UDS_LOCAL_PATH, fullPath},
+                                 });
         listEntry(uds);
     };
 
diff --git a/man/kio_man.cpp b/man/kio_man.cpp
index 5ffa1a680..2fc017213 100644
--- a/man/kio_man.cpp
+++ b/man/kio_man.cpp
@@ -6,6 +6,7 @@
 
 #include "kio_man.h"
 #include "kio_man_debug.h"
+#include "udsentry_compat.h"
 
 #include <QByteArray>
 #include <QCoreApplication>
@@ -753,10 +754,12 @@ KIO::WorkerResult MANProtocol::stat(const QUrl &url)
     qCDebug(KIO_MAN_LOG) << "URL" << url.url() << "parsed to title" << title << "section" << section;
 
     UDSEntry entry;
-    entry.reserve(3);
-    entry.fastInsert(KIO::UDSEntry::UDS_NAME, title);
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_NAME, title},
+                                 {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("text/html")},
+                             });
     entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
-    entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("text/html"));
 
     statEntry(entry);
 
@@ -1332,7 +1335,6 @@ KIO::WorkerResult MANProtocol::listDir(const QUrl &url)
     // timed to maximise application performance.
 
     UDSEntry uds_entry;
-    uds_entry.reserve(4);
 
     uds_entry.fastInsert(KIO::UDSEntry::UDS_NAME, ".");
     uds_entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
@@ -1342,8 +1344,13 @@ KIO::WorkerResult MANProtocol::listDir(const QUrl &url)
     {
         for (const QString &sect : m_sectionNames) {
             uds_entry.clear(); // sectionName() is already I18N'ed
-            uds_entry.fastInsert(KIO::UDSEntry::UDS_NAME, (sect + " - " + sectionName(sect)));
-            uds_entry.fastInsert(KIO::UDSEntry::UDS_URL, ("man:/(" + sect + ')'));
+            const QString sectionTitle = sect + " - " + sectionName(sect);
+            const QString sectionUrl = "man:/(" + sect + ')';
+            KIOExtras::insertStrings(uds_entry,
+                                     {
+                                         {KIO::UDSEntry::UDS_NAME, sectionTitle},
+                                         {KIO::UDSEntry::UDS_URL, sectionUrl},
+                                     });
             uds_entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
             listEntry(uds_entry);
         }
@@ -1366,12 +1373,16 @@ KIO::WorkerResult MANProtocol::listDir(const QUrl &url)
             }
 
             uds_entry.clear();
-            uds_entry.fastInsert(KIO::UDSEntry::UDS_NAME, name);
+            const QString pageUrl = "man:" + page;
+            KIOExtras::insertStrings(uds_entry,
+                                     {
+                                         {KIO::UDSEntry::UDS_NAME, name},
+                                         {KIO::UDSEntry::UDS_URL, pageUrl},
+                                         {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("text/html")},
+                                     });
             if (!displayName.isEmpty())
                 uds_entry.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, displayName);
-            uds_entry.fastInsert(KIO::UDSEntry::UDS_URL, ("man:" + page));
             uds_entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
-            uds_entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("text/html"));
             listEntry(uds_entry);
         }
     }
diff --git a/mtp/kio_mtp.cpp b/mtp/kio_mtp.cpp
index 603b863e9..43cf78d98 100644
--- a/mtp/kio_mtp.cpp
+++ b/mtp/kio_mtp.cpp
@@ -9,6 +9,7 @@
 
 #include "kio_mtp.h"
 #include "kio_mtp_debug.h"
+#include "udsentry_compat.h"
 
 // #include <KComponentData>
 #include <QCoreApplication>
@@ -35,45 +36,61 @@ class KIOPluginForMetaData : public QObject
 static UDSEntry getEntry(const KMTPDeviceInterface *device)
 {
     UDSEntry entry;
-    entry.reserve(5);
-    entry.fastInsert(UDSEntry::UDS_NAME, device->friendlyName());
-    entry.fastInsert(UDSEntry::UDS_ICON_NAME, QStringLiteral("multimedia-player"));
-    entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH);
-    entry.fastInsert(UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {UDSEntry::UDS_NAME, device->friendlyName()},
+                                 {UDSEntry::UDS_ICON_NAME, QStringLiteral("multimedia-player")},
+                                 {UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                             });
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 {UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH},
+                             });
     return entry;
 }
 
 static UDSEntry getEntry(const KMTPStorageInterface *storage)
 {
     UDSEntry entry;
-    entry.reserve(5);
-    entry.fastInsert(UDSEntry::UDS_NAME, storage->description());
-    entry.fastInsert(UDSEntry::UDS_ICON_NAME, QStringLiteral("drive-removable-media"));
-    entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(UDSEntry::UDS_ACCESS, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
-    entry.fastInsert(UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {UDSEntry::UDS_NAME, storage->description()},
+                                 {UDSEntry::UDS_ICON_NAME, QStringLiteral("drive-removable-media")},
+                                 {UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                             });
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 {UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {UDSEntry::UDS_ACCESS, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH},
+                             });
     return entry;
 }
 
 static UDSEntry getEntry(const KMTPFile &file)
 {
     UDSEntry entry;
-    entry.reserve(9);
-    entry.fastInsert(UDSEntry::UDS_NAME, file.filename());
-    if (file.isFolder()) {
-        entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-        entry.fastInsert(UDSEntry::UDS_ACCESS, S_IRWXU | S_IRWXG | S_IRWXO);
-    } else {
-        entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFREG);
-        entry.fastInsert(UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH);
+    const bool isFolder = file.isFolder();
+
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {UDSEntry::UDS_NAME, file.filename()},
+                                 {UDSEntry::UDS_MIME_TYPE, file.filetype()},
+                             });
+
+    const auto modificationDate = file.modificationdate();
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 {UDSEntry::UDS_FILE_TYPE, isFolder ? S_IFDIR : S_IFREG},
+                                 {UDSEntry::UDS_ACCESS, isFolder ? S_IRWXU | S_IRWXG | S_IRWXO : S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH},
+                                 {UDSEntry::UDS_INODE, file.itemId()},
+                                 {UDSEntry::UDS_ACCESS_TIME, modificationDate},
+                                 {UDSEntry::UDS_MODIFICATION_TIME, modificationDate},
+                                 {UDSEntry::UDS_CREATION_TIME, modificationDate},
+                             });
+    if (!isFolder) {
         entry.fastInsert(UDSEntry::UDS_SIZE, file.filesize());
     }
-    entry.fastInsert(UDSEntry::UDS_MIME_TYPE, file.filetype());
-    entry.fastInsert(UDSEntry::UDS_INODE, file.itemId());
-    entry.fastInsert(UDSEntry::UDS_ACCESS_TIME, file.modificationdate());
-    entry.fastInsert(UDSEntry::UDS_MODIFICATION_TIME, file.modificationdate());
-    entry.fastInsert(UDSEntry::UDS_CREATION_TIME, file.modificationdate());
     return entry;
 }
 
@@ -177,11 +194,13 @@ WorkerResult MTPWorker::listDir(const QUrl &url)
 
     // list '.' entry, otherwise files cannot be pasted to empty folders
     KIO::UDSEntry entry;
-    entry.reserve(4);
     entry.fastInsert(KIO::UDSEntry::UDS_NAME, QStringLiteral("."));
-    entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(KIO::UDSEntry::UDS_SIZE, 0);
-    entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH);
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {KIO::UDSEntry::UDS_SIZE, 0},
+                                 {KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH},
+                             });
     listEntry(entry);
 
     const QStringList pathItems = url.path().split(QLatin1Char('/'), Qt::SkipEmptyParts);
@@ -300,11 +319,16 @@ WorkerResult MTPWorker::stat(const QUrl &url)
     UDSEntry entry;
     // root
     if (pathItems.size() < 1) {
-        entry.reserve(4);
-        entry.fastInsert(UDSEntry::UDS_NAME, QStringLiteral("mtp:///"));
-        entry.fastInsert(UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-        entry.fastInsert(UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH);
-        entry.fastInsert(UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
+        KIOExtras::insertStrings(entry,
+                                 {
+                                     {UDSEntry::UDS_NAME, QStringLiteral("mtp:///")},
+                                     {UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                                 });
+        KIOExtras::insertNumbers(entry,
+                                 {
+                                     {UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                     {UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH},
+                                 });
     } else {
         const KMTPDeviceInterface *mtpDevice = m_kmtpDaemon.deviceFromName(pathItems.first());
         if (mtpDevice) {
diff --git a/nfs/kio_nfs.cpp b/nfs/kio_nfs.cpp
index 771d6f664..eb42584d8 100644
--- a/nfs/kio_nfs.cpp
+++ b/nfs/kio_nfs.cpp
@@ -7,6 +7,7 @@
 */
 
 #include "kio_nfs.h"
+#include "udsentry_compat.h"
 
 #include <config-runtime.h>
 
@@ -967,12 +968,18 @@ void NFSProtocol::completeInvalidUDSEntry(KIO::UDSEntry &entry)
 // a blank UDSEntry or one where only UDS_NAME has been filled in.
 void NFSProtocol::createVirtualDirEntry(UDSEntry &entry)
 {
-    entry.fastInsert(KIO::UDSEntry::UDS_SIZE, 0); // dummy size
-    entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
-    entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
-    entry.fastInsert(KIO::UDSEntry::UDS_USER, QString::fromLatin1("root"));
-    entry.fastInsert(KIO::UDSEntry::UDS_GROUP, QString::fromLatin1("root"));
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                                 {KIO::UDSEntry::UDS_USER, QString::fromLatin1("root")},
+                                 {KIO::UDSEntry::UDS_GROUP, QString::fromLatin1("root")},
+                             });
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_SIZE, 0}, // dummy size
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH},
+                             });
 }
 
 #include "kio_nfs.moc"
diff --git a/recentlyused/recentlyused.cpp b/recentlyused/recentlyused.cpp
index 8d4027b2d..be45cefd2 100644
--- a/recentlyused/recentlyused.cpp
+++ b/recentlyused/recentlyused.cpp
@@ -6,6 +6,7 @@
 
 #include "recentlyused.h"
 #include "recentlyused-logsettings.h"
+#include "udsentry_compat.h"
 
 #include <QCoreApplication>
 #include <QDataStream>
@@ -189,14 +190,13 @@ KIO::UDSEntry RecentlyUsed::udsEntryFromResource(int row, const QString &resourc
     // replace name with a technical unique name
     const auto name = uds.stringValue(KIO::UDSEntry::UDS_NAME);
     uds.replace(KIO::UDSEntry::UDS_NAME, QStringLiteral("%1-%2").arg(name).arg(row));
-    uds.reserve(uds.count() + 5);
-    if (name.isEmpty()) {
-        uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, resource);
-    } else {
-        uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, name);
-    }
-    uds.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, mimeType);
-    uds.fastInsert(KIO::UDSEntry::UDS_TARGET_URL, resourceUrl.toString());
+    KIOExtras::insertStrings(uds,
+                             {
+                                 {KIO::UDSEntry::UDS_DISPLAY_NAME, name.isEmpty() ? resource : name},
+                                 {KIO::UDSEntry::UDS_MIME_TYPE, mimeType},
+                                 {KIO::UDSEntry::UDS_TARGET_URL, resourceUrl.toString()},
+                                 {KIO::UDSEntry::UDS_EXTRA, agent},
+                             });
     if (resourceUrl.isLocalFile()) {
         uds.fastInsert(KIO::UDSEntry::UDS_LOCAL_PATH, resource);
     }
@@ -210,7 +210,6 @@ KIO::UDSEntry RecentlyUsed::udsEntryFromResource(int row, const QString &resourc
         // override access time
         uds.replace(KIO::UDSEntry::UDS_ACCESS_TIME, lastUpdateTime);
     }
-    uds.fastInsert(KIO::UDSEntry::UDS_EXTRA, agent);
     return uds;
 }
 
@@ -223,15 +222,21 @@ KIO::WorkerResult RecentlyUsed::listDir(const QUrl &url)
 
         // add "." to transmit permissions for current directory
         KIO::UDSEntry uds;
-        uds.reserve(4);
-        uds.fastInsert(KIO::UDSEntry::UDS_NAME, QStringLiteral("."));
-        uds.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-        uds.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
+        KIOExtras::insertStrings(uds,
+                                 {
+                                     {KIO::UDSEntry::UDS_NAME, QStringLiteral(".")},
+                                     {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                                 });
 #ifdef Q_OS_WIN
-        uds.fastInsert(KIO::UDSEntry::UDS_ACCESS, _S_IREAD);
+        const long long access = _S_IREAD;
 #else
-        uds.fastInsert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR);
+        const long long access = S_IRUSR | S_IXUSR;
 #endif
+        KIOExtras::insertNumbers(uds,
+                                 {
+                                     {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                     {KIO::UDSEntry::UDS_ACCESS, access},
+                                 });
         udslist << uds;
 
         int limit = queryLimit(url);
@@ -295,18 +300,24 @@ KIO::WorkerResult RecentlyUsed::listDir(const QUrl &url)
 KIO::UDSEntry RecentlyUsed::udsEntryForRoot(const QString &dirName, const QString &iconName)
 {
     KIO::UDSEntry uds;
-    uds.reserve(7);
-    uds.fastInsert(KIO::UDSEntry::UDS_NAME, dirName);
-    uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, dirName);
-    uds.fastInsert(KIO::UDSEntry::UDS_DISPLAY_TYPE, dirName);
-    uds.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, iconName);
-    uds.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    uds.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
+    KIOExtras::insertStrings(uds,
+                             {
+                                 {KIO::UDSEntry::UDS_NAME, dirName},
+                                 {KIO::UDSEntry::UDS_DISPLAY_NAME, dirName},
+                                 {KIO::UDSEntry::UDS_DISPLAY_TYPE, dirName},
+                                 {KIO::UDSEntry::UDS_ICON_NAME, iconName},
+                                 {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory")},
+                             });
 #ifdef Q_OS_WIN
-    uds.fastInsert(KIO::UDSEntry::UDS_ACCESS, _S_IREAD);
+    const long long access = _S_IREAD;
 #else
-    uds.fastInsert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR);
+    const long long access = S_IRUSR | S_IXUSR;
 #endif
+    KIOExtras::insertNumbers(uds,
+                             {
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {KIO::UDSEntry::UDS_ACCESS, access},
+                             });
     return uds;
 }
 
diff --git a/sftp/kio_sftp.cpp b/sftp/kio_sftp.cpp
index 3eabae8a4..0c3804dd4 100644
--- a/sftp/kio_sftp.cpp
+++ b/sftp/kio_sftp.cpp
@@ -7,6 +7,7 @@
  */
 
 #include "kio_sftp.h"
+#include "udsentry_compat.h"
 #include <config-runtime.h>
 
 #include <array>
@@ -507,9 +508,9 @@ Result SFTPWorker::createUDSEntry(SFTPAttributesPtr sb, UDSEntry &entry, const Q
     Q_ASSERT(sb.get());
 
     entry.clear();
-    entry.reserve(10);
-    entry.fastInsert(KIO::UDSEntry::UDS_NAME, name /* awkwardly sftp_lstat doesn't fill the attributes name correctly, calculate from path */);
 
+    QString linkDest;
+    bool isSymlink = false;
     bool isBrokenLink = false;
     if (sb->type == SSH_FILEXFER_TYPE_SYMLINK) {
         std::unique_ptr<char, decltype(&free)> link(sftp_readlink(mSftp, path.constData()), free);
@@ -520,7 +521,8 @@ Result SFTPWorker::createUDSEntry(SFTPAttributesPtr sb, UDSEntry &entry, const Q
                                       QString::fromUtf8(path),
                                       QString::number(sftp_get_error(mSftp))));
         }
-        entry.fastInsert(KIO::UDSEntry::UDS_LINK_DEST, QFile::decodeName(link.get()));
+        isSymlink = true;
+        linkDest = QFile::decodeName(link.get());
         // A symlink -> follow it only if details > 1
         if (details > 1) {
             sftp_attributes sb2 = sftp_stat(mSftp, path.constData());
@@ -561,29 +563,39 @@ Result SFTPWorker::createUDSEntry(SFTPAttributesPtr sb, UDSEntry &entry, const Q
         access = modeToOptionalPerms(sb->permissions).value_or(perms::none);
         size = sb->size;
     }
-    entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, fileType);
-    entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, permsToPosix(access));
-    entry.fastInsert(KIO::UDSEntry::UDS_SIZE, narrow<long long>(size));
+    const bool withDetails = details > 0;
+    // Availability of the creation time depends on outside factors.
+    // https://bugs.kde.org/show_bug.cgi?id=375305
+    const bool withCreationTime = withDetails && (sb->flags & SSH_FILEXFER_ATTR_CREATETIME);
 
-    if (details > 0) {
-        if (sb->owner) {
-            entry.fastInsert(KIO::UDSEntry::UDS_USER, QString::fromUtf8(sb->owner));
-        } else {
-            entry.fastInsert(KIO::UDSEntry::UDS_USER, QString::number(sb->uid));
-        }
+    QString user;
+    QString group;
+    if (withDetails) {
+        user = sb->owner ? QString::fromUtf8(sb->owner) : QString::number(sb->uid);
+        group = sb->group ? QString::fromUtf8(sb->group) : QString::number(sb->gid);
+    }
 
-        if (sb->group) {
-            entry.fastInsert(KIO::UDSEntry::UDS_GROUP, QString::fromUtf8(sb->group));
-        } else {
-            entry.fastInsert(KIO::UDSEntry::UDS_GROUP, QString::number(sb->gid));
-        }
+    // The string values and the number values go to separate storage, so fill all of one
+    // kind and then all of the other rather than alternating between them.
+    KIOExtras::reserveEntry(entry, 1 + (isSymlink ? 1 : 0) + (withDetails ? 2 : 0), 3 + (withDetails ? 2 : 0) + (withCreationTime ? 1 : 0));
 
+    // awkwardly sftp_lstat doesn't fill the attributes name correctly, calculate from path
+    entry.fastInsert(KIO::UDSEntry::UDS_NAME, name);
+    if (isSymlink) {
+        entry.fastInsert(KIO::UDSEntry::UDS_LINK_DEST, linkDest);
+    }
+    if (withDetails) {
+        entry.fastInsert(KIO::UDSEntry::UDS_USER, user);
+        entry.fastInsert(KIO::UDSEntry::UDS_GROUP, group);
+    }
+
+    entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, fileType);
+    entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, permsToPosix(access));
+    entry.fastInsert(KIO::UDSEntry::UDS_SIZE, narrow<long long>(size));
+    if (withDetails) {
         entry.fastInsert(KIO::UDSEntry::UDS_ACCESS_TIME, sb->atime);
         entry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, sb->mtime);
-
-        if (sb->flags & SSH_FILEXFER_ATTR_CREATETIME) {
-            // Availability depends on outside factors.
-            // https://bugs.kde.org/show_bug.cgi?id=375305
+        if (withCreationTime) {
             entry.fastInsert(KIO::UDSEntry::UDS_CREATION_TIME, narrow<long long>(sb->createtime));
         }
     }
diff --git a/smb/dnssddiscoverer.cpp b/smb/dnssddiscoverer.cpp
index 86feafcc8..3c526638d 100644
--- a/smb/dnssddiscoverer.cpp
+++ b/smb/dnssddiscoverer.cpp
@@ -5,6 +5,7 @@
 
 #include "dnssddiscoverer.h"
 #include "kio_smb.h"
+#include "udsentry_compat.h"
 
 DNSSDDiscovery::DNSSDDiscovery(KDNSSD::RemoteService::Ptr service)
     : m_service(service)
@@ -19,12 +20,6 @@ QString DNSSDDiscovery::udsName() const
 KIO::UDSEntry DNSSDDiscovery::toEntry() const
 {
     KIO::UDSEntry entry;
-    entry.reserve(6);
-    entry.fastInsert(KIO::UDSEntry::UDS_NAME, udsName());
-
-    entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH));
-    entry.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, "network-server");
 
     // TODO: it may be better to resolve the host to an ip address. dnssd
     //   being able to find a service doesn't mean name resolution is
@@ -43,8 +38,18 @@ KIO::UDSEntry DNSSDDiscovery::toEntry() const
     }
     u.setPath("/"); // https://bugs.kde.org/show_bug.cgi?id=388922
 
-    entry.fastInsert(KIO::UDSEntry::UDS_URL, u.url());
-    entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-smb-server"));
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_NAME, udsName()},
+                                 {KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("network-server")},
+                                 {KIO::UDSEntry::UDS_URL, u.url()},
+                                 {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-smb-server")},
+                             });
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)},
+                             });
     return entry;
 }
 
diff --git a/smb/kio_smb_browse.cpp b/smb/kio_smb_browse.cpp
index 885e51689..3fe954965 100644
--- a/smb/kio_smb_browse.cpp
+++ b/smb/kio_smb_browse.cpp
@@ -7,6 +7,7 @@
 
 #include "kio_smb.h"
 #include "smburl.h"
+#include "udsentry_compat.h"
 
 #include <utility>
 
@@ -104,10 +105,13 @@ int SMBWorker::statToUDSEntry(const QUrl &url, const struct stat &st, KIO::UDSEn
     // Also see:
     // https://docs.microsoft.com/en-us/windows/win32/shell/how-to-customize-folders-with-desktop-ini
 
-    udsentry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, st.st_mode & S_IFMT);
-    udsentry.fastInsert(KIO::UDSEntry::UDS_SIZE, st.st_size);
-    udsentry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, st.st_mtime);
-    udsentry.fastInsert(KIO::UDSEntry::UDS_ACCESS_TIME, st.st_atime);
+    KIOExtras::insertNumbers(udsentry,
+                             {
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, st.st_mode & S_IFMT},
+                                 {KIO::UDSEntry::UDS_SIZE, st.st_size},
+                                 {KIO::UDSEntry::UDS_MODIFICATION_TIME, st.st_mtime},
+                                 {KIO::UDSEntry::UDS_ACCESS_TIME, st.st_atime},
+                             });
     // No, st_ctime is not UDS_CREATION_TIME...
 
     return 0;
@@ -475,9 +479,12 @@ WorkerResult SMBWorker::listDir(const QUrl &kurl)
 
     UDSEntry udsentry;
     if (smbc->dirWasRoot()) {
-        udsentry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
         udsentry.fastInsert(KIO::UDSEntry::UDS_NAME, ".");
-        udsentry.fastInsert(KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH));
+        KIOExtras::insertNumbers(udsentry,
+                                 {
+                                     {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                     {KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH)},
+                                 });
     } else {
         udsentry.fastInsert(KIO::UDSEntry::UDS_NAME, ".");
         const int statErr = browse_stat_path(m_current_url, udsentry);
@@ -486,8 +493,11 @@ WorkerResult SMBWorker::listDir(const QUrl &kurl)
                 reportWarning(m_current_url, statErr);
             }
             // Create a default UDSEntry if we could not stat the actual directory
-            udsentry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-            udsentry.fastInsert(KIO::UDSEntry::UDS_ACCESS, (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH));
+            KIOExtras::insertNumbers(udsentry,
+                                     {
+                                         {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                         {KIO::UDSEntry::UDS_ACCESS, (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)},
+                                     });
         }
     }
     listEntry(udsentry);
diff --git a/smb/smbcdiscoverer.cpp b/smb/smbcdiscoverer.cpp
index d712c8892..c1fbd7351 100644
--- a/smb/smbcdiscoverer.cpp
+++ b/smb/smbcdiscoverer.cpp
@@ -8,6 +8,7 @@
 #include <QUrlQuery>
 
 #include "smbcdiscoverer.h"
+#include "udsentry_compat.h"
 
 static QEvent::Type LoopEvent = QEvent::User;
 
@@ -17,11 +18,17 @@ public:
     SMBCServerDiscovery(const UDSEntry &entry)
         : SMBCDiscovery(entry)
     {
-        m_entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-        m_entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH));
-        m_entry.fastInsert(KIO::UDSEntry::UDS_URL, url());
-        m_entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-smb-server"));
-        m_entry.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("network-server"));
+        KIOExtras::insertStrings(m_entry,
+                                 {
+                                     {KIO::UDSEntry::UDS_URL, url()},
+                                     {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-smb-server")},
+                                     {KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("network-server")},
+                                 });
+        KIOExtras::insertNumbers(m_entry,
+                                 {
+                                     {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                     {KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)},
+                                 });
     }
 
     QString url()
@@ -38,8 +45,11 @@ public:
     SMBCShareDiscovery(const UDSEntry &entry)
         : SMBCDiscovery(entry)
     {
-        m_entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-        m_entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH));
+        KIOExtras::insertNumbers(m_entry,
+                                 {
+                                     {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                     {KIO::UDSEntry::UDS_ACCESS, (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)},
+                                 });
     }
 };
 
@@ -49,10 +59,16 @@ public:
     SMBCWorkgroupDiscovery(const UDSEntry &entry)
         : SMBCDiscovery(entry)
     {
-        m_entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-        m_entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH));
-        m_entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-smb-workgroup"));
-        m_entry.fastInsert(KIO::UDSEntry::UDS_URL, url());
+        KIOExtras::insertStrings(m_entry,
+                                 {
+                                     {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-smb-workgroup")},
+                                     {KIO::UDSEntry::UDS_URL, url()},
+                                 });
+        KIOExtras::insertNumbers(m_entry,
+                                 {
+                                     {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                     {KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH)},
+                                 });
     }
 
     QString url()
@@ -79,11 +95,15 @@ public:
     SMBCPrinterDiscovery(const UDSEntry &entry)
         : SMBCDiscovery(entry)
     {
+        // The URL is relative to parent, but need to set it so we can append a marker. Subsequent stat calls
+        // wouldn't know that this is a printer because libsmbc doesn't reflect that in the stat output.
+        const QString printerUrl = udsName() + QStringLiteral("?kio-printer=true");
+        KIOExtras::insertStrings(m_entry,
+                                 {
+                                     {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/vnd.kde.kio.smb.printer")},
+                                     {KIO::UDSEntry::UDS_URL, printerUrl},
+                                 });
         m_entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0x0);
-        m_entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/vnd.kde.kio.smb.printer"));
-        // Relative to parent, but need to set it so we can append a marker. Subsequent stat calls wouldn't know that this is a printer
-        // because libsmbc doesn't reflect that in the stat output.
-        m_entry.fastInsert(KIO::UDSEntry::UDS_URL, udsName() + QStringLiteral("?kio-printer=true"));
     }
 };
 
@@ -142,7 +162,8 @@ bool SMBCDiscoverer::discoverNextFileInfo()
             return true;
         }
         UDSEntry entry;
-        entry.reserve(5); // Minimal size. stat will set at least 4 fields.
+        // Minimal size. stat will set at least 4 fields.
+        KIOExtras::reserveEntry(entry, 3, 2);
         entry.fastInsert(KIO::UDSEntry::UDS_NAME, name);
 
         m_url.addPath(name);
@@ -212,9 +233,12 @@ void SMBCDiscoverer::discoverNext()
     // Minimal potential size. The actual size depends on this function,
     // possibly the stat function, and lastly the Discovery objects themselves.
     // The smallest will be a ShareDiscovery with 5 fields.
-    entry.reserve(5);
-    entry.fastInsert(KIO::UDSEntry::UDS_NAME, name);
-    entry.fastInsert(KIO::UDSEntry::UDS_COMMENT, comment);
+    KIOExtras::reserveEntry(entry, 3, 2);
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_NAME, name},
+                                 {KIO::UDSEntry::UDS_COMMENT, comment},
+                             });
     // Ensure system shares are marked hidden.
     if (name.endsWith(QLatin1Char('$'))) {
         entry.fastInsert(KIO::UDSEntry::UDS_HIDDEN, 1);
diff --git a/smb/wsdiscoverer.cpp b/smb/wsdiscoverer.cpp
index 46405627c..36ef7dfba 100644
--- a/smb/wsdiscoverer.cpp
+++ b/smb/wsdiscoverer.cpp
@@ -4,6 +4,7 @@
 */
 
 #include "wsdiscoverer.h"
+#include "udsentry_compat.h"
 
 #include <QCoreApplication>
 #include <QDebug>
@@ -363,21 +364,24 @@ QString WSDiscovery::udsName() const
 KIO::UDSEntry WSDiscovery::toEntry() const
 {
     KIO::UDSEntry entry;
-    const int fastInsertCount = 6;
-    entry.reserve(fastInsertCount);
-    entry.fastInsert(KIO::UDSEntry::UDS_NAME, udsName());
-
-    entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
-    entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH));
-    entry.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, "network-server");
 
     QUrl u;
     u.setScheme(QStringLiteral("smb"));
     u.setHost(m_remote);
     u.setPath("/"); // https://bugs.kde.org/show_bug.cgi?id=388922
 
-    entry.fastInsert(KIO::UDSEntry::UDS_URL, u.url());
-    entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-smb-server"));
+    KIOExtras::insertStrings(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_NAME, udsName()},
+                                 {KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("network-server")},
+                                 {KIO::UDSEntry::UDS_URL, u.url()},
+                                 {KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-smb-server")},
+                             });
+    KIOExtras::insertNumbers(entry,
+                             {
+                                 {KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR},
+                                 {KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)},
+                             });
     return entry;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.