refactor(Core): apply clang-tidy modernize-pass-by-value (#3823)

This commit is contained in:
Francesco Borzì
2020-12-13 01:11:15 +01:00
committed by GitHub
parent 282966c117
commit adf436c937
10 changed files with 36 additions and 24 deletions
+3 -1
View File
@@ -7,6 +7,8 @@
#ifndef _TRANSACTION_H #ifndef _TRANSACTION_H
#define _TRANSACTION_H #define _TRANSACTION_H
#include <utility>
#include "SQLOperation.h" #include "SQLOperation.h"
//- Forward declare (don't include header to prevent circular includes) //- Forward declare (don't include header to prevent circular includes)
@@ -48,7 +50,7 @@ class TransactionTask : public SQLOperation
friend class DatabaseWorker; friend class DatabaseWorker;
public: public:
TransactionTask(SQLTransaction trans) : m_trans(trans) { } ; TransactionTask(SQLTransaction trans) : m_trans(std::move(trans)) { } ;
~TransactionTask() override = default; ~TransactionTask() override = default;
protected: protected:
+5 -4
View File
@@ -8,13 +8,14 @@
#define _ADDONMGR_H #define _ADDONMGR_H
#include "Define.h" #include "Define.h"
#include <string>
#include <list> #include <list>
#include <string>
#include <utility>
struct AddonInfo struct AddonInfo
{ {
AddonInfo(const std::string& name, uint8 enabled, uint32 crc, uint8 state, bool crcOrPubKey) AddonInfo(std::string name, uint8 enabled, uint32 crc, uint8 state, bool crcOrPubKey)
: Name(name), Enabled(enabled), CRC(crc), State(state), UsePublicKeyOrCRC(crcOrPubKey) {} : Name(std::move(name)), Enabled(enabled), CRC(crc), State(state), UsePublicKeyOrCRC(crcOrPubKey) {}
std::string Name; std::string Name;
uint8 Enabled; uint8 Enabled;
@@ -25,7 +26,7 @@ struct AddonInfo
struct SavedAddon struct SavedAddon
{ {
SavedAddon(const std::string& name, uint32 crc) : Name(name) SavedAddon(std::string name, uint32 crc) : Name(std::move(name))
{ {
CRC = crc; CRC = crc;
} }
+3 -2
View File
@@ -9,6 +9,7 @@
#include "Common.h" #include "Common.h"
#include <map> #include <map>
#include <utility>
struct AuctionEntry; struct AuctionEntry;
struct CalendarEvent; struct CalendarEvent;
@@ -110,8 +111,8 @@ public: // Constructors
explicit MailDraft(uint16 mailTemplateId, bool need_items = true) explicit MailDraft(uint16 mailTemplateId, bool need_items = true)
: m_mailTemplateId(mailTemplateId), m_mailTemplateItemsNeed(need_items), m_money(0), m_COD(0) : m_mailTemplateId(mailTemplateId), m_mailTemplateItemsNeed(need_items), m_money(0), m_COD(0)
{} {}
MailDraft(std::string const& subject, std::string const& body) MailDraft(std::string subject, std::string body)
: m_mailTemplateId(0), m_mailTemplateItemsNeed(false), m_subject(subject), m_body(body), m_money(0), m_COD(0) {} : m_mailTemplateId(0), m_mailTemplateItemsNeed(false), m_subject(std::move(subject)), m_body(std::move(body)), m_money(0), m_COD(0) {}
public: // Accessors public: // Accessors
[[nodiscard]] uint16 GetMailTemplateId() const { return m_mailTemplateId; } [[nodiscard]] uint16 GetMailTemplateId() const { return m_mailTemplateId; }
[[nodiscard]] std::string const& GetSubject() const { return m_subject; } [[nodiscard]] std::string const& GetSubject() const { return m_subject; }
+4 -2
View File
@@ -11,6 +11,8 @@
#ifndef __WORLDSESSION_H #ifndef __WORLDSESSION_H
#define __WORLDSESSION_H #define __WORLDSESSION_H
#include <utility>
#include "Common.h" #include "Common.h"
#include "SharedDefines.h" #include "SharedDefines.h"
#include "AddonMgr.h" #include "AddonMgr.h"
@@ -159,8 +161,8 @@ class CharacterCreateInfo
friend class Player; friend class Player;
protected: protected:
CharacterCreateInfo(std::string const& name, uint8 race, uint8 cclass, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId, CharacterCreateInfo(std::string name, uint8 race, uint8 cclass, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId,
WorldPacket& data) : Name(name), Race(race), Class(cclass), Gender(gender), Skin(skin), Face(face), HairStyle(hairStyle), HairColor(hairColor), FacialHair(facialHair), WorldPacket& data) : Name(std::move(name)), Race(race), Class(cclass), Gender(gender), Skin(skin), Face(face), HairStyle(hairStyle), HairColor(hairColor), FacialHair(facialHair),
OutfitId(outfitId), Data(data), CharCount(0) OutfitId(outfitId), Data(data), CharCount(0)
{} {}
+5 -3
View File
@@ -7,10 +7,12 @@
#define _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE
#include "dbcfile.h" #include "dbcfile.h"
#include "mpq_libmpq04.h"
DBCFile::DBCFile(const std::string& filename): #include "mpq_libmpq04.h"
filename(filename), recordSize(0), recordCount(0), fieldCount(0), stringSize(0), data(nullptr), stringTable(nullptr) #include <utility>
DBCFile::DBCFile(std::string filename):
filename(std::move(filename)), recordSize(0), recordCount(0), fieldCount(0), stringSize(0), data(nullptr), stringTable(nullptr)
{ {
} }
+3 -2
View File
@@ -8,11 +8,12 @@
#define DBCFILE_H #define DBCFILE_H
#include <cassert> #include <cassert>
#include <string> #include <string>
#include <utility>
class DBCFile class DBCFile
{ {
public: public:
DBCFile(const std::string& filename); DBCFile(std::string filename);
~DBCFile(); ~DBCFile();
// Open database. It must be openened before it can be used. // Open database. It must be openened before it can be used.
@@ -22,7 +23,7 @@ public:
class Exception class Exception
{ {
public: public:
Exception(const std::string& message): message(message) Exception(std::string message): message(std::move(message))
{ } { }
virtual ~Exception() = default; virtual ~Exception() = default;
const std::string& getMessage() {return message;} const std::string& getMessage() {return message;}
+3 -2
View File
@@ -10,9 +10,10 @@
#undef max #undef max
#include <cstdio> #include <cstdio>
#include <utility>
DBCFile::DBCFile(const std::string& filename): DBCFile::DBCFile(std::string filename):
filename(filename), recordSize(0), recordCount(0), fieldCount(0), stringSize(0), data(nullptr), stringTable(nullptr) filename(std::move(filename)), recordSize(0), recordCount(0), fieldCount(0), stringSize(0), data(nullptr), stringTable(nullptr)
{ {
} }
+3 -2
View File
@@ -9,11 +9,12 @@
#include <cassert> #include <cassert>
#include <string> #include <string>
#include <utility>
class DBCFile class DBCFile
{ {
public: public:
DBCFile(const std::string& filename); DBCFile(std::string filename);
~DBCFile(); ~DBCFile();
// Open database. It must be openened before it can be used. // Open database. It must be openened before it can be used.
@@ -25,7 +26,7 @@ public:
class Exception class Exception
{ {
public: public:
Exception(const std::string& message): message(message) Exception(std::string message): message(std::move(message))
{ } { }
virtual ~Exception() = default; virtual ~Exception() = default;
const std::string& getMessage() {return message;} const std::string& getMessage() {return message;}
+6 -5
View File
@@ -4,14 +4,15 @@
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/ */
#include "vmapexport.h"
#include "wmo.h" #include "wmo.h"
#include "vec3d.h" #include "vec3d.h"
#include "vmapexport.h"
#include <cassert>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cassert>
#include <map>
#include <fstream> #include <fstream>
#include <map>
#include <utility>
#undef min #undef min
#undef max #undef max
#include "mpq_libmpq04.h" #include "mpq_libmpq04.h"
@@ -124,8 +125,8 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE* pOutfile)
return true; return true;
} }
WMOGroup::WMOGroup(const std::string& filename) : WMOGroup::WMOGroup(std::string filename) :
filename(filename), MOPY(nullptr), MOVI(nullptr), MoviEx(nullptr), MOVT(nullptr), MOBA(nullptr), MobaEx(nullptr), filename(std::move(filename)), MOPY(nullptr), MOVI(nullptr), MoviEx(nullptr), MOVT(nullptr), MOBA(nullptr), MobaEx(nullptr),
hlq(nullptr), LiquEx(nullptr), LiquBytes(nullptr), groupName(0), descGroupName(0), mogpFlags(0), hlq(nullptr), LiquEx(nullptr), LiquBytes(nullptr), groupName(0), descGroupName(0), mogpFlags(0),
moprIdx(0), moprNItems(0), nBatchA(0), nBatchB(0), nBatchC(0), fogIdx(0), moprIdx(0), moprNItems(0), nBatchA(0), nBatchB(0), nBatchC(0), fogIdx(0),
liquidType(0), groupWMOID(0), mopy_size(0), moba_size(0), LiquEx_size(0), liquidType(0), groupWMOID(0), mopy_size(0), moba_size(0), LiquEx_size(0),
+1 -1
View File
@@ -98,7 +98,7 @@ public:
int nTriangles; // number when loaded int nTriangles; // number when loaded
uint32 liquflags; uint32 liquflags;
WMOGroup(std::string const& filename); WMOGroup(std::string filename);
~WMOGroup(); ~WMOGroup();
bool open(); bool open();