[frameworks/kio] src: UDSEntry: properly mark deprecated, add missing since, fix doc formatting

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

UDSEntry: properly mark deprecated, add missing since, fix doc formatting

reserve(int) is marked deprecated now that it says it is, so its callers in the
tree say instead how many of each kind of field they are about to insert. What
they asked for was a guess either way, since reserve(int) split the number it was
given into a third strings and two thirds numbers.

amend a7b7e249eded900d92aa2240793b40d7e1a65b8d

M  +2    -0    src/core/udsentry.cpp
M  +44   -16   src/core/udsentry.h
M  +2    -1    src/kioworkers/http/http.cpp
M  +4    -2    src/widgets/renamedialog.cpp

https://invent.kde.org/frameworks/kio/-/commit/d1cb3b7b78a6000f744662e2d1a09775c12e4473

diff --git a/src/core/udsentry.cpp b/src/core/udsentry.cpp
index 5f0435fda1..850df15b9f 100644
--- a/src/core/udsentry.cpp
+++ b/src/core/udsentry.cpp
@@ -573,11 +573,13 @@ void UDSEntry::clear()
     d->clear();
 }
 
+#if KIOCORE_BUILD_DEPRECATED_SINCE(6, 29)
 void UDSEntry::reserve(int size)
 {
     d->reserveStrings(size / 3);
     d->reserveNumbers(size * 2 / 3);
 }
+#endif
 
 void UDSEntry::reserve(std::initializer_list<uint> fields)
 {
diff --git a/src/core/udsentry.h b/src/core/udsentry.h
index a0a30f04e3..66434cfa09 100644
--- a/src/core/udsentry.h
+++ b/src/core/udsentry.h
@@ -136,35 +136,52 @@ public:
      */
     bool isLink() const;
 
+#if KIOCORE_ENABLE_DEPRECATED_SINCE(6, 29)
     /*!
      * Calling this function before inserting items into an empty UDSEntry may save time and memory.
+     *
      * \a size number of items for which memory will be pre-allocated
      *
      * \deprecated[6.29] Use reserveStrings() and reserveNumbers().
      */
+    KIOCORE_DEPRECATED_VERSION(6, 29, "Use reserveStrings() and reserveNumbers()")
     void reserve(int size);
+#endif
 
     /*!
-     * Calling those functions before inserting items into an empty UDSEntry may save time and memory.
-     * \a size number of items for which memory will be pre-allocated
+     * Calling this function before inserting items into an empty UDSEntry may save time and memory.
      *
-     * Use reserveStrings for UDS_STRING fields and reserveNumbers for UDS_NUMBER fields.
+     * \a size number of UDS_STRING fields for which memory will be pre-allocated
+     *
+     * \sa reserveNumbers()
      *
      * \since 6.29
      */
     void reserveStrings(int size);
-    //! \sa reserveStrings
+
+    /*!
+     * Calling this function before inserting items into an empty UDSEntry may save time and memory.
+     *
+     * \a size number of UDS_NUMBER fields for which memory will be pre-allocated
+     *
+     * \sa reserveStrings()
+     *
+     * \since 6.29
+     */
     void reserveNumbers(int size);
 
     /*!
-     * Pre-allocate `fields` fields in the backend storage according to their UDS_TYPE
+     * Pre-allocate \a fields fields in the backend storage according to their UDS_TYPE
      *
      * Example:
      *
-     *     UDSEntry entry;
-     *     entry.reserve({UDS_SIZE, UDS_ACCESS, UDS_MODIFICATION_TIME, UDS_NAME});
+     * \code
+     * UDSEntry entry;
+     * entry.reserve({UDS_SIZE, UDS_ACCESS, UDS_MODIFICATION_TIME, UDS_NAME});
+     * \endcode
+     *
+     * \a fields the fields to pre-allocate for
      *
-     * \a fields
      * \since 6.29
      */
     void reserve(std::initializer_list<uint> fields);
@@ -172,14 +189,17 @@ public:
     /*!
      * Insert the values passed as pairs {field, value} in a initializer_list
      *
-     * This will first pre-allocates the necessary memory in the underlying storage vector.
+     * This will first pre-allocate the necessary memory in the underlying storage vector.
      *
      * Example:
      *
-     *     UDSEntry entry;
-     *     entry.insert({{UDS_SIZE, 0}, {UDS_ACCESS, 0}});
+     * \code
+     * UDSEntry entry;
+     * entry.insert({{UDS_SIZE, 0}, {UDS_ACCESS, 0}});
+     * \endcode
+     *
+     * \a fieldValuePairs the fields and the values to insert
      *
-     * \a fields
      * \since 6.29
      */
     void insert(std::initializer_list<std::pair<uint, const QString &>> fieldValuePairs);
@@ -187,14 +207,17 @@ public:
     /*!
      * Insert the values passed as pairs {field, value} in a initializer_list
      *
-     * This will first pre-allocates the necessary memory in the underlying storage vector.
+     * This will first pre-allocate the necessary memory in the underlying storage vector.
      *
      * Example:
      *
-     *     UDSEntry entry;
-     *     entry.insert({{UDS_NAME, ""}, {UDS_USER, ""}});
+     * \code
+     * UDSEntry entry;
+     * entry.insert({{UDS_NAME, ""}, {UDS_USER, ""}});
+     * \endcode
+     *
+     * \a fieldValuePairs the fields and the values to insert
      *
-     * \a fields
      * \since 6.29
      */
     void insert(std::initializer_list<std::pair<uint, long long>> fieldValuePairs);
@@ -237,10 +260,15 @@ public:
     int count() const;
     /*!
      * The number of number fields (including time fields)
+     *
+     * \since 6.29
      */
     int numbersCount() const;
+
     /*!
      * The number of string fields
+     *
+     * \since 6.29
      */
     int stringsCount() const;
 
diff --git a/src/kioworkers/http/http.cpp b/src/kioworkers/http/http.cpp
index 49a8dab933..e439acfa91 100644
--- a/src/kioworkers/http/http.cpp
+++ b/src/kioworkers/http/http.cpp
@@ -1165,7 +1165,8 @@ KIO::WorkerResult HTTPProtocol::stat(const QUrl &url)
 
         // When downloading we assume it exists
         KIO::UDSEntry entry;
-        entry.reserve(3);
+        entry.reserveStrings(1);
+        entry.reserveNumbers(2);
         entry.fastInsert(KIO::UDSEntry::UDS_NAME, url.fileName());
         entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG); // a file
         entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IRGRP | S_IROTH); // readable by everybody
diff --git a/src/widgets/renamedialog.cpp b/src/widgets/renamedialog.cpp
index 7d733163d6..8cbb364de2 100644
--- a/src/widgets/renamedialog.cpp
+++ b/src/widgets/renamedialog.cpp
@@ -355,7 +355,8 @@ RenameDialog::RenameDialog(QWidget *parent,
         } else {
             UDSEntry srcUds;
 
-            srcUds.reserve(6);
+            srcUds.reserveStrings(1);
+            srcUds.reserveNumbers(5);
             srcUds.fastInsert(UDSEntry::UDS_NAME, d->src.fileName());
             if (mtimeSrc.isValid()) {
                 srcUds.fastInsert(UDSEntry::UDS_MODIFICATION_TIME, mtimeSrc.toMSecsSinceEpoch() / 1000);
@@ -377,7 +378,8 @@ RenameDialog::RenameDialog(QWidget *parent,
         } else {
             UDSEntry destUds;
 
-            destUds.reserve(4);
+            destUds.reserveStrings(1);
+            destUds.reserveNumbers(5);
             destUds.fastInsert(UDSEntry::UDS_NAME, d->dest.fileName());
             if (mtimeDest.isValid()) {
                 destUds.fastInsert(UDSEntry::UDS_MODIFICATION_TIME, mtimeDest.toMSecsSinceEpoch() / 1000);
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.