commit 0eb0b8531a08a81e1b9cdde108be124edbd6dfdd
Author: Guillaume Munch <[email protected]>
Date: Sat Dec 31 15:22:07 2016 +0100
Convert a pointer to a reference
The validity of the reference is guaranteed by QThreadLocalStorage
---
src/Paragraph.cpp | 8 ++++----
src/Text.cpp | 10 +++++-----
src/WordList.cpp | 6 +++---
src/WordList.h | 2 +-
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 6238033..ba101e4 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3705,11 +3705,11 @@ void Paragraph::deregisterWords()
Private::LangWordsMap::const_iterator itl = d->words_.begin();
Private::LangWordsMap::const_iterator ite = d->words_.end();
for (; itl != ite; ++itl) {
- WordList * wl = theWordList(itl->first);
+ WordList & wl = theWordList(itl->first);
Private::Words::const_iterator it = (itl->second).begin();
Private::Words::const_iterator et = (itl->second).end();
for (; it != et; ++it)
- wl->remove(*it);
+ wl.remove(*it);
}
d->words_.clear();
}
@@ -3785,11 +3785,11 @@ void Paragraph::registerWords()
Private::LangWordsMap::const_iterator itl = d->words_.begin();
Private::LangWordsMap::const_iterator ite = d->words_.end();
for (; itl != ite; ++itl) {
- WordList * wl = theWordList(itl->first);
+ WordList & wl = theWordList(itl->first);
Private::Words::const_iterator it = (itl->second).begin();
Private::Words::const_iterator et = (itl->second).end();
for (; it != et; ++it)
- wl->insert(*it);
+ wl.insert(*it);
}
}
diff --git a/src/Text.cpp b/src/Text.cpp
index deefc4b..8e0d1be 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -586,7 +586,7 @@ class TextCompletionList : public CompletionList
{
public:
///
- TextCompletionList(Cursor const & cur, WordList const * list)
+ TextCompletionList(Cursor const & cur, WordList const & list)
: buffer_(cur.buffer()), list_(list)
{}
///
@@ -597,19 +597,19 @@ public:
///
virtual size_t size() const
{
- return list_->size();
+ return list_.size();
}
///
virtual docstring const & data(size_t idx) const
{
- return list_->word(idx);
+ return list_.word(idx);
}
private:
///
Buffer const * buffer_;
///
- WordList const * list_;
+ WordList const & list_;
};
@@ -2156,7 +2156,7 @@ bool Text::completionSupported(Cursor const & cur) const
CompletionList const * Text::createCompletionList(Cursor const & cur) const
{
- WordList const * list = theWordList(cur.getFont().language()->lang());
+ WordList const & list = theWordList(cur.getFont().language()->lang());
return new TextCompletionList(cur, list);
}
diff --git a/src/WordList.cpp b/src/WordList.cpp
index d883994..8180985 100644
--- a/src/WordList.cpp
+++ b/src/WordList.cpp
@@ -34,18 +34,18 @@ typedef map<string, WordList *> GlobalWordList;
QThreadStorage<GlobalWordList *> theGlobalWordList;
-WordList * theWordList(string const & lang)
+WordList & theWordList(string const & lang)
{
if (!theGlobalWordList.hasLocalData())
theGlobalWordList.setLocalData(new GlobalWordList);
GlobalWordList * globalWordList = theGlobalWordList.localData();
GlobalWordList::iterator it = globalWordList->find(lang);
if (it != globalWordList->end())
- return it->second;
+ return *it->second;
else {
WordList * wl = new WordList;
(*globalWordList)[lang] = wl;
- return wl;
+ return *wl;
}
}
diff --git a/src/WordList.h b/src/WordList.h
index 5b0488b..0c5c0a8 100644
--- a/src/WordList.h
+++ b/src/WordList.h
@@ -38,7 +38,7 @@ private:
std::unique_ptr<Impl> d;
};
-WordList * theWordList(std::string const & lang);
+WordList & theWordList(std::string const & lang);
} // namespace lyx