diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-06-04 12:48:50 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-06-04 14:13:24 +0200 |
commit | 1fa085f223761b8dcd7e7ac592eb70450a774543 (patch) | |
tree | 90c64ffc3a0b8c0efbb6db64086fc3cfb710c8a0 /sc/inc | |
parent | ca595a7d7e35ca814e4eb6cb5d7afbc88f85c850 (diff) |
Simplify ScUserList, don't use unique_ptr.
Change-Id: Idd0ce7bfff115a3b762e963dd6cea7927c78e295
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152586
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/inc')
-rw-r--r-- | sc/inc/userlist.hxx | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx index e91fbcc0164e..7625ad15f5ee 100644 --- a/sc/inc/userlist.hxx +++ b/sc/inc/userlist.hxx @@ -23,13 +23,12 @@ #include <rtl/ustring.hxx> -#include <memory> #include <vector> /** * Stores individual user-defined sort list. */ -class SC_DLLPUBLIC ScUserListData +class SC_DLLPUBLIC ScUserListData final { public: struct SAL_DLLPRIVATE SubStr @@ -48,8 +47,9 @@ private: public: ScUserListData(OUString aStr); + // Copy ctor and assignment operator re-initialize tokens. Is this intended on copy? ScUserListData(const ScUserListData& rData); - ~ScUserListData(); + ScUserListData& operator=(const ScUserListData& rData); const OUString& GetString() const { return aStr; } void SetString(const OUString& rStr); @@ -65,32 +65,31 @@ public: */ class SC_DLLPUBLIC ScUserList { - typedef std::vector<std::unique_ptr<ScUserListData>> DataType; + typedef std::vector<ScUserListData> DataType; DataType maData; public: - typedef DataType::iterator iterator; - typedef DataType::const_iterator const_iterator; - ScUserList(); - ScUserList(const ScUserList& r); + ScUserList(const ScUserList& r) = default; + + void EraseData(size_t nIndex) { maData.erase(maData.cbegin() + nIndex); } const ScUserListData* GetData(const OUString& rSubStr) const; /// If the list in rStr is already inserted bool HasEntry(std::u16string_view rStr) const; - const ScUserListData& operator[](size_t nIndex) const; - ScUserListData& operator[](size_t nIndex); - ScUserList& operator=(const ScUserList& r); + const ScUserListData& operator[](size_t nIndex) const { return maData[nIndex]; } + ScUserListData& operator[](size_t nIndex) { return maData[nIndex]; } + ScUserList& operator=(const ScUserList& r) = default; bool operator==(const ScUserList& r) const; - bool operator!=(const ScUserList& r) const; - - iterator begin(); - const_iterator begin() const; - void clear(); - size_t size() const; - void push_back(ScUserListData* p); - void erase(const iterator& itr); + bool operator!=(const ScUserList& r) const { return !operator==(r); } + + void clear() { maData.clear(); } + size_t size() const { return maData.size(); } + template <class... Args> void emplace_back(Args&&... args) + { + maData.emplace_back(std::forward<Args>(args)...); + } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |