sw/source/core/doc/acmplwrd.cxx | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
New commits: commit c37b27af9195d4c5861676a3d5d5173e3476d3bc Author: Takeshi Abe <t...@fixedpoint.jp> Date: Sun Jun 17 19:20:00 2018 +0900 sw: Avoid unnecessary copy in SwAutoCompleteWord::GetWordsMatching() Its sole client code in sw/source/uibase/docvw/edtwin.cxx allows the precondition that its 2nd argument rWords is empty. This also corrects the @param description of the argument. Change-Id: Icc12bc36d0d4157ed05ef10fb3c3db325c6bfaf2 Reviewed-on: https://gerrit.libreoffice.org/55943 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx index 5ccdc9859398..75f683bec8bf 100644 --- a/sw/source/core/doc/acmplwrd.cxx +++ b/sw/source/core/doc/acmplwrd.cxx @@ -37,6 +37,7 @@ #include <sfx2/docfile.hxx> #include <docsh.hxx> +#include <cassert> #include <vector> class SwAutoCompleteClient : public SwClient @@ -346,24 +347,13 @@ void SwAutoCompleteWord::SetMinWordLen( sal_uInt16 n ) /** Return all words matching a given prefix * * @param aMatch the prefix to search for - * @param aWords the words to search in + * @param rWords the words found matching */ -bool SwAutoCompleteWord::GetWordsMatching(const OUString& aMatch, std::vector<OUString>& aWords) const +bool SwAutoCompleteWord::GetWordsMatching(const OUString& aMatch, std::vector<OUString>& rWords) const { - std::vector<OUString> suggestions; - m_LookupTree.findSuggestions(aMatch, suggestions); - - if (suggestions.empty()) - { - return false; - } - - for (const OUString & suggestion : suggestions) - { - aWords.push_back( suggestion ); - } - - return true; + assert(rWords.empty()); + m_LookupTree.findSuggestions(aMatch, rWords); + return !rWords.empty(); } void SwAutoCompleteWord::CheckChangedList( _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits