Skip to content

Commit

Permalink
cleanup: Make ToxId move-only.
Browse files Browse the repository at this point in the history
We never copy it except in one place where it's a mistake.

Also removed an unimplemented member function declaration from ToxId.
  • Loading branch information
iphydf committed Nov 30, 2024
1 parent 3256137 commit b3b454d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/core/toxid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ ToxId::ToxId()
* @brief The copy constructor.
* @param other ToxId to copy
*/
ToxId::ToxId(const ToxId& other)
: toxId(other.toxId)
ToxId::ToxId(ToxId&& other)
: toxId(std::move(other.toxId))
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/core/toxid.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ToxId
static constexpr int numHexChars = size * 2;

ToxId();
ToxId(const ToxId& other);
ToxId(ToxId&& other);
explicit ToxId(const QString& id);
explicit ToxId(const QByteArray& rawId);
explicit ToxId(const uint8_t* rawId, int len);
Expand All @@ -39,7 +39,6 @@ class ToxId
static bool isValidToxId(const QString& id);
static bool isToxId(const QString& id);
const uint8_t* getBytes() const;
QByteArray getToxId() const;
ToxPk getPublicKey() const;
QString getNoSpamString() const;

Expand Down
2 changes: 1 addition & 1 deletion src/widget/form/addfriendform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool checkIsValidId(const QString& id)

AddFriendForm::AddFriendForm(ToxId ownId_, Settings& settings_, Style& style_,
IMessageBoxManager& messageBoxManager_, Core& core_)
: ownId{ownId_}
: ownId{std::move(ownId_)}
, settings{settings_}
, style{style_}
, messageBoxManager{messageBoxManager_}
Expand Down
8 changes: 0 additions & 8 deletions test/core/toxid_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ private slots:
void equalTest();
void notEqualTest();
void clearTest();
void copyTest();
void validationTest();
};

Expand Down Expand Up @@ -60,13 +59,6 @@ void TestToxId::clearTest()
QVERIFY(empty == test);
}

void TestToxId::copyTest()
{
ToxId src(testToxId);
ToxId copy = src;
QVERIFY(copy == src);
}

void TestToxId::validationTest()
{
QVERIFY(ToxId(testToxId).isValid());
Expand Down

0 comments on commit b3b454d

Please sign in to comment.