aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-07-21 12:12:07 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-07-21 21:35:56 +0000
commit2f03202810f6c264509fb704511301d51f282292 (patch)
tree59169c9f8a8d7fc8b8a91eec9c3f86e230297204
parenta50b87870cf84e14eebfc2b00151342ec0d7e0f4 (diff)
Use QSharedPointer::create() more
Reduces allocations. This is the result of running the (experimental) clang-tidy check qt-modernize-qsharedpointer-create Discarded changes: none. Change-Id: I9ef1ccd46315f1bb8f3cc30a652f17c18b46232c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnclauseconverterjajp.cpp4
-rw-r--r--src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnndictionary.cpp2
-rw-r--r--src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnenginejajp.cpp10
-rw-r--r--src/virtualkeyboard/desktopinputselectioncontrol.cpp4
4 files changed, 10 insertions, 10 deletions
diff --git a/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnclauseconverterjajp.cpp b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnclauseconverterjajp.cpp
index 13ae45fa..947f6cee 100644
--- a/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnclauseconverterjajp.cpp
+++ b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnclauseconverterjajp.cpp
@@ -93,12 +93,12 @@ public:
/* check if the part of speech is valid */
if (fzk == NULL) {
if (connectible(stem.partOfSpeech.right, terminal.left)) {
- clause.reset(new WnnClause(input, stem));
+ clause = QSharedPointer<WnnClause>::create(input, stem);
}
} else {
if (connectible(stem.partOfSpeech.right, fzk->partOfSpeech.left)
&& connectible(fzk->partOfSpeech.right, terminal.left)) {
- clause.reset(new WnnClause(input, stem, *fzk));
+ clause = QSharedPointer<WnnClause>::create(input, stem, *fzk);
}
}
if (clause == NULL) {
diff --git a/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnndictionary.cpp b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnndictionary.cpp
index 2a8aad86..1063fd9a 100644
--- a/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnndictionary.cpp
+++ b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnndictionary.cpp
@@ -879,7 +879,7 @@ QSharedPointer<WnnWord> OpenWnnDictionary::getNextWord(int length)
/* Get the result from fixed dictionary */
int res = d->getNextWord(length);
if (res > 0)
- return QSharedPointer<WnnWord>(new WnnWord(d->getCandidate(), d->getStroke(), WnnPOS(d->getLeftPartOfSpeech(), d->getRightPartOfSpeech()), d->getFrequency()));
+ return QSharedPointer<WnnWord>::create(d->getCandidate(), d->getStroke(), WnnPOS(d->getLeftPartOfSpeech(), d->getRightPartOfSpeech()), d->getFrequency());
return QSharedPointer<WnnWord>();
}
diff --git a/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnenginejajp.cpp b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnenginejajp.cpp
index dbcfb0cd..dbcb7c37 100644
--- a/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnenginejajp.cpp
+++ b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/openwnnenginejajp.cpp
@@ -115,7 +115,7 @@ public:
if (!convResult.isEmpty()) {
for (QList<WnnClause>::ConstIterator it = convResult.constBegin();
it != convResult.constEnd(); it++) {
- addCandidate(QSharedPointer<WnnWord>(new WnnWord(*it)));
+ addCandidate(QSharedPointer<WnnWord>::create(*it));
}
}
/* end of candidates by single clause conversion */
@@ -128,7 +128,7 @@ public:
for (QList<WnnWord>::ConstIterator it = addCandidateList.constBegin();
it != addCandidateList.constEnd(); it++) {
- addCandidate(QSharedPointer<WnnWord>(new WnnWord(*it)));
+ addCandidate(QSharedPointer<WnnWord>::create(*it));
}
mGetCandidateFrom = 3;
@@ -282,7 +282,7 @@ int OpenWnnEngineJAJP::convert(ComposingText &text)
if (headCandidates.isEmpty()) {
return 0;
}
- head.reset(new WnnClause(input, headCandidates.first()));
+ head = QSharedPointer<WnnClause>::create(input, headCandidates.first());
/* set the rest of input string */
input = text.toString(ComposingText::LAYER1, cursor, text.size(ComposingText::LAYER1) - 1);
@@ -296,7 +296,7 @@ int OpenWnnEngineJAJP::convert(ComposingText &text)
sentence = d->mClauseConverter.consecutiveClauseConvert(input);
}
if (!head.isNull()) {
- sentence.reset(new WnnSentence(*head, sentence.data()));
+ sentence = QSharedPointer<WnnSentence>::create(*head, sentence.data());
}
if (sentence.isNull()) {
return 0;
@@ -356,7 +356,7 @@ bool OpenWnnEngineJAJP::learn(WnnWord &word)
}
} else {
ret = dict.learnWord(word, d->mPreviousWord.data());
- d->mPreviousWord.reset(new WnnWord(word));
+ d->mPreviousWord = QSharedPointer<WnnWord>::create(word);
d->mClauseConverter.setDictionary(&dict);
}
diff --git a/src/virtualkeyboard/desktopinputselectioncontrol.cpp b/src/virtualkeyboard/desktopinputselectioncontrol.cpp
index 7ecf0f6c..bb2925b5 100644
--- a/src/virtualkeyboard/desktopinputselectioncontrol.cpp
+++ b/src/virtualkeyboard/desktopinputselectioncontrol.cpp
@@ -176,8 +176,8 @@ void DesktopInputSelectionControl::createHandles()
Settings *settings = Settings::instance();
connect(settings, &Settings::styleChanged, this, &DesktopInputSelectionControl::reloadGraphics);
- m_anchorSelectionHandle.reset(new InputSelectionHandle(this, focusWindow));
- m_cursorSelectionHandle.reset(new InputSelectionHandle(this, focusWindow));
+ m_anchorSelectionHandle = QSharedPointer<InputSelectionHandle>::create(this, focusWindow);
+ m_cursorSelectionHandle = QSharedPointer<InputSelectionHandle>::create(this, focusWindow);
reloadGraphics();
if (QCoreApplication *app = QCoreApplication::instance()) {