From 7aba9dcf13ac464acfcfe3cba7b2e5918790ce0e Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Thu, 5 Nov 2015 21:50:55 +0100 Subject: a vector is unnecessary here, tdf#79983 follow-up Only the first case-insensitive match needs to be remembered. Change-Id: Ifac666760878f769bc04d567db9284eedaa40a65 --- sc/source/core/tool/userlist.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx index d29e38899451..3bc65eee96dd 100644 --- a/sc/source/core/tool/userlist.cxx +++ b/sc/source/core/tool/userlist.cxx @@ -274,7 +274,7 @@ ScUserList::ScUserList(const ScUserList& r) : const ScUserListData* ScUserList::GetData(const OUString& rSubStr) const { - std::vector matchData; + const ScUserListData* pFirstCaseInsensitive = nullptr; DataType::const_iterator itr = maData.begin(), itrEnd = maData.end(); sal_uInt16 nIndex; bool bMatchCase = false; @@ -285,15 +285,12 @@ const ScUserListData* ScUserList::GetData(const OUString& rSubStr) const { if (bMatchCase) return &(*itr); - matchData.push_back(itr); + if (!pFirstCaseInsensitive) + pFirstCaseInsensitive = &(*itr); } } - if (matchData.empty()) - { - return NULL; - } - return &(**matchData.begin()); + return pFirstCaseInsensitive; } const ScUserListData& ScUserList::operator[](size_t nIndex) const -- cgit v1.2.3