Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Performance] Change to use Pass by reference where valid. #3163

Merged
merged 2 commits into from
Apr 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/crash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class EQEmuStackWalker : public StackWalker
StackWalker::OnOutput(szText);
}

const std::vector<std::string>& const GetLines() { return _lines; }
const std::vector<std::string>& GetLines() { return _lines; }
private:
std::vector<std::string> _lines;
};
Expand Down
2 changes: 1 addition & 1 deletion common/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ bool Database::GetVariable(std::string varname, std::string &varvalue)
return false;
}

bool Database::SetVariable(const std::string varname, const std::string &varvalue)
bool Database::SetVariable(const std::string& varname, const std::string &varvalue)
{
std::string escaped_name = Strings::Escape(varname);
std::string escaped_value = Strings::Escape(varvalue);
Expand Down
2 changes: 1 addition & 1 deletion common/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class Database : public DBcore {
/* Database Variables */

bool GetVariable(std::string varname, std::string &varvalue);
bool SetVariable(const std::string varname, const std::string &varvalue);
bool SetVariable(const std::string& varname, const std::string &varvalue);
bool LoadVariables();

/* General Queries */
Expand Down
2 changes: 1 addition & 1 deletion common/dbcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void DBcore::ping()
m_mutex->unlock();
}

MySQLRequestResult DBcore::QueryDatabase(std::string query, bool retryOnFailureOnce)
MySQLRequestResult DBcore::QueryDatabase(const std::string& query, bool retryOnFailureOnce)
{
auto r = QueryDatabase(query.c_str(), query.length(), retryOnFailureOnce);
return r;
Expand Down
2 changes: 1 addition & 1 deletion common/dbcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DBcore {
~DBcore();
eStatus GetStatus() { return pStatus; }
MySQLRequestResult QueryDatabase(const char *query, uint32 querylen, bool retryOnFailureOnce = true);
MySQLRequestResult QueryDatabase(std::string query, bool retryOnFailureOnce = true);
MySQLRequestResult QueryDatabase(const std::string& query, bool retryOnFailureOnce = true);
void TransactionBegin();
void TransactionCommit();
void TransactionRollback();
Expand Down
2 changes: 1 addition & 1 deletion common/eq_limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace EQ

LookupEntry(const LookupEntry *lookup_entry) { }
LookupEntry(
InventoryTypeSize_Struct InventoryTypeSize,
const InventoryTypeSize_Struct& InventoryTypeSize,
uint64 EquipmentBitmask,
uint64 GeneralBitmask,
uint64 CursorBitmask,
Expand Down
10 changes: 5 additions & 5 deletions common/proc_launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void ProcLauncher::Process() {
if(GetExitCodeProcess(cur->second->proc_info.hProcess, &res)) {
//got exit code, see if its still running...
if(res == STILL_ACTIVE) {
cur++;
++cur;
continue;
}
//else, it died, handle properly
Expand All @@ -76,7 +76,7 @@ void ProcLauncher::Process() {

//if we get here, the current process died.
tmp = cur;
tmp++;
++tmp;
ProcessTerminated(cur);
cur = tmp;
}
Expand Down Expand Up @@ -174,7 +174,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
std::vector<std::string>::iterator cur, end;
cur = it->args.begin();
end = it->args.end();
for(; cur != end; cur++) {
for(; cur != end; ++cur) {
args += " ";
args += *cur;
}
Expand Down Expand Up @@ -306,7 +306,7 @@ void ProcLauncher::TerminateAll(bool final) {
std::map<ProcRef, Spec *>::iterator cur, end;
cur = m_running.begin();
end = m_running.end();
for(; cur != end; cur++) {
for(; cur != end; ++cur) {
Terminate(cur->first, true);
}
} else {
Expand All @@ -317,7 +317,7 @@ void ProcLauncher::TerminateAll(bool final) {
std::map<ProcRef, Spec *>::iterator cur, end;
cur = running.begin();
end = running.end();
for(; cur != end; cur++) {
for(; cur != end; ++cur) {
Terminate(cur->first, true);
safe_delete(cur->second);
}
Expand Down
2 changes: 1 addition & 1 deletion common/profanity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ bool EQ::ProfanityManager::clear_database_entries(DBcore *db) {
return true;
}

bool EQ::ProfanityManager::check_for_existing_entry(std::string profanity) {
bool EQ::ProfanityManager::check_for_existing_entry(const std::string& profanity) {
if (profanity.empty()) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion common/profanity_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace EQ
private:
static bool load_database_entries(DBcore *db);
static bool clear_database_entries(DBcore *db);
static bool check_for_existing_entry(std::string profanity);
static bool check_for_existing_entry(const std::string& profanity);

};

Expand Down
4 changes: 2 additions & 2 deletions common/rulesys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ bool RuleManager::SetRule(const std::string &rule_name, const std::string &rule_

switch (type) {
case IntRule:
m_RuleIntValues[index] = Strings::ToInt(rule_value.c_str());
m_RuleIntValues[index] = Strings::ToInt(rule_value);
LogRules("Set rule [{}] to value [{}]", rule_name, m_RuleIntValues[index]);
break;
case RealRule:
m_RuleRealValues[index] = Strings::ToFloat(rule_value.c_str());
m_RuleRealValues[index] = Strings::ToFloat(rule_value);
LogRules("Set rule [{}] to value [{:.2f}]", rule_name, m_RuleRealValues[index]);
break;
case BoolRule:
Expand Down
2 changes: 1 addition & 1 deletion common/say_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void EQ::SayLinkEngine::generate_text()
m_LinkText = "null";
}

std::string EQ::SayLinkEngine::GenerateQuestSaylink(std::string saylink_text, bool silent, std::string link_name)
std::string EQ::SayLinkEngine::GenerateQuestSaylink(const std::string& saylink_text, bool silent, const std::string& link_name)
{
uint32 saylink_id = 0;

Expand Down
2 changes: 1 addition & 1 deletion common/say_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace EQ
const std::string& LinkBody() { return m_LinkBody; } // contains string format: '<LinkBody>'
const std::string& LinkText() { return m_LinkText; } // contains string format: '<LinkText>'

static std::string GenerateQuestSaylink(std::string saylink_text, bool silent, std::string link_name);
static std::string GenerateQuestSaylink(const std::string& saylink_text, bool silent, const std::string& link_name);

void Reset();

Expand Down
2 changes: 1 addition & 1 deletion common/zone_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ ZoneRepository::Zone *ZoneStore::GetZone(const char *in_zone_name)
return nullptr;
}

ZoneRepository::Zone *ZoneStore::GetZone(std::string in_zone_name)
ZoneRepository::Zone *ZoneStore::GetZone(const std::string& in_zone_name)
{
for (auto &z: m_zones) {
if (z.short_name == in_zone_name) {
Expand Down
4 changes: 2 additions & 2 deletions common/zone_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ZoneStore {

ZoneRepository::Zone *GetZone(uint32 zone_id, int version = 0);
ZoneRepository::Zone *GetZone(const char *in_zone_name);
ZoneRepository::Zone *GetZone(std::string in_zone_name);
ZoneRepository::Zone *GetZone(const std::string& in_zone_name);
uint32 GetZoneID(const char *in_zone_name);
uint32 GetZoneID(std::string zone_name);
std::string GetZoneName(uint32 zone_id);
Expand All @@ -53,7 +53,7 @@ extern ZoneStore zone_store;
* Global helpers
*/
inline uint32 ZoneID(const char *in_zone_name) { return zone_store.GetZoneID(in_zone_name); }
inline uint32 ZoneID(std::string zone_name) { return zone_store.GetZoneID(zone_name); }
inline uint32 ZoneID(const std::string& zone_name) { return zone_store.GetZoneID(zone_name); }
inline const char *ZoneName(uint32 zone_id, bool error_unknown = false)
{
return zone_store.GetZoneName(
Expand Down
2 changes: 1 addition & 1 deletion loginserver/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ bool Client::VerifyLoginHash(
* @param db_loginserver
*/
void Client::DoSuccessfulLogin(
const std::string in_account_name,
const std::string& in_account_name,
int db_account_id,
const std::string &db_loginserver
)
Expand Down
2 changes: 1 addition & 1 deletion loginserver/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class Client {
const std::string &password_hash
);

void DoSuccessfulLogin(const std::string in_account_name, int db_account_id, const std::string &db_loginserver);
void DoSuccessfulLogin(const std::string& in_account_name, int db_account_id, const std::string &db_loginserver);
void CreateLocalAccount(const std::string &username, const std::string &password);
void CreateEQEmuAccount(const std::string &in_account_name, const std::string &in_account_password, unsigned int loginserver_account_id);

Expand Down
4 changes: 2 additions & 2 deletions loginserver/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ class Options {
inline void AutoLinkAccounts(bool b) { auto_link_accounts = b; }
inline bool CanAutoLinkAccounts() const { return auto_link_accounts; }

inline void EQEmuLoginServerAddress(std::string v) { eqemu_loginserver_address = v; }
inline void EQEmuLoginServerAddress(const std::string& v) { eqemu_loginserver_address = v; }
inline std::string GetEQEmuLoginServerAddress() const { return eqemu_loginserver_address; }

inline void DefaultLoginServerName(std::string v) { default_loginserver_name = v; }
inline void DefaultLoginServerName(const std::string& v) { default_loginserver_name = v; }
inline std::string GetDefaultLoginServerName() const { return default_loginserver_name; }

inline void UpdateInsecurePasswords(bool b) { update_insecure_passwords = b; }
Expand Down
10 changes: 5 additions & 5 deletions ucs/chatchannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void ServerToClient45SayLink(std::string& clientSayLink, const std::string& serv
void ServerToClient50SayLink(std::string& clientSayLink, const std::string& serverSayLink);
void ServerToClient55SayLink(std::string& clientSayLink, const std::string& serverSayLink);

ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus) :
ChatChannel::ChatChannel(const std::string& inName, const std::string& inOwner, const std::string& inPassword, bool inPermanent, int inMinimumStatus) :
m_delete_timer(0) {

m_name = inName;
Expand Down Expand Up @@ -137,7 +137,7 @@ ChatChannel *ChatChannelList::CreateChannel(
return new_channel;
}

ChatChannel* ChatChannelList::FindChannel(std::string Name) {
ChatChannel* ChatChannelList::FindChannel(const std::string& Name) {

std::string normalized_name = CapitaliseName(Name);

Expand Down Expand Up @@ -283,7 +283,7 @@ void ChatChannel::SetPassword(const std::string& in_password) {
}
}

void ChatChannel::SetOwner(std::string& in_owner) {
void ChatChannel::SetOwner(const std::string& in_owner) {

m_owner = in_owner;

Expand Down Expand Up @@ -659,7 +659,7 @@ ChatChannel *ChatChannelList::RemoveClientFromChannel(const std::string& in_chan
std::string channel_name = in_channel_name;

if (in_channel_name.length() > 0 && isdigit(channel_name[0])) {
channel_name = c->ChannelSlotName(Strings::ToInt(in_channel_name.c_str()));
channel_name = c->ChannelSlotName(Strings::ToInt(in_channel_name));
}

auto *required_channel = FindChannel(channel_name);
Expand Down Expand Up @@ -784,7 +784,7 @@ bool ChatChannel::HasVoice(std::string inVoiced)
return std::find(std::begin(m_voiced), std::end(m_voiced), inVoiced) != std::end(m_voiced);
}

std::string CapitaliseName(std::string inString) {
std::string CapitaliseName(const std::string& inString) {

std::string NormalisedName = inString;

Expand Down
12 changes: 6 additions & 6 deletions ucs/chatchannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ChatChannel {

public:

ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus = 0);
ChatChannel(const std::string& inName, const std::string& inOwner, const std::string& inPassword, bool inPermanent, int inMinimumStatus = 0);
~ChatChannel();

void AddClient(Client *c);
Expand All @@ -29,7 +29,7 @@ class ChatChannel {
void SetPassword(const std::string& in_password);
bool IsOwner(const std::string& name) { return (m_owner == name); }
const std::string& GetPassword() { return m_password; }
void SetOwner(std::string& inOwner);
void SetOwner(const std::string& in_owner);
std::string& GetOwnerName();
void SetTemporary();
void SetPermanent();
Expand Down Expand Up @@ -76,7 +76,7 @@ class ChatChannelList {

public:
ChatChannel* CreateChannel(const std::string& name, const std::string& owner, const std::string& password, bool permanent, int minimum_status, bool save_to_database = false);
ChatChannel* FindChannel(std::string name);
ChatChannel* FindChannel(const std::string& Name);
Aeadoin marked this conversation as resolved.
Show resolved Hide resolved
ChatChannel* AddClientToChannel(std::string channel_name, Client* c, bool command_directed = false);
ChatChannel* RemoveClientFromChannel(const std::string& in_channel_name, Client* c, bool command_directed = false);
void RemoveChannel(ChatChannel *Channel);
Expand All @@ -91,8 +91,8 @@ class ChatChannelList {
static void AddToFilteredNames(const std::string& name);
static bool IsOnChannelBlockList(const std::string& channel_name);
static bool IsOnFilteredNameList(const std::string& channel_name);
static inline void SetChannelBlockList(std::vector<std::string> new_list) { m_blocked_channel_names = new_list; }
static inline void SetFilteredNameList(std::vector<std::string> new_list) { m_filtered_names = new_list; }
static inline void SetChannelBlockList(const std::vector<std::string>& new_list) { m_blocked_channel_names = new_list; }
static inline void SetFilteredNameList(const std::vector<std::string>& new_list) { m_filtered_names = new_list; }
private:

LinkedList<ChatChannel*> ChatChannels;
Expand All @@ -101,6 +101,6 @@ class ChatChannelList {

};

std::string CapitaliseName(std::string inString);
std::string CapitaliseName(const std::string& inString);

#endif