Permalink
Browse files

Remove some useless or dangerous std::move calls

  • Loading branch information...
mbasaglia committed Nov 9, 2015
1 parent 04c9435 commit 4e2fbd0326c480beba1785865e9f31bbc8b9a2b8
@@ -206,7 +206,7 @@ namespace Cmd {

// Engine calls available everywhere

void AddCommand(std::string name, const CmdBase& cmd, std::string description);
void AddCommand(const std::string& name, const CmdBase& cmd, std::string description);
void RemoveCommand(const std::string& name);
Environment* GetEnv();

@@ -232,7 +232,7 @@ namespace Cvar {

bool Register(CvarProxy* proxy, const std::string& name, std::string description, int flags, const std::string& defaultValue);
std::string GetValue(const std::string& cvarName);
void SetValue(const std::string& cvarName, std::string value);
void SetValue(const std::string& cvarName, const std::string& value);
bool AddFlags(const std::string& cvarName, int flags);

// Implementation of templates
@@ -124,15 +124,15 @@ namespace Cmd {
Args currentArgs;
Args oldArgs;

void AddCommand(std::string name, const CmdBase& cmd, std::string description) {
void AddCommand(const std::string& name, const CmdBase& cmd, std::string description) {
CommandMap& commands = GetCommandMap();

if (!IsValidCmdName(name)) {
commandLog.Warn("Cmd::AddCommand: Invalid command name '%s'", name);
return;
}

if (!commands.insert({std::move(name), commandRecord_t{std::move(description), &cmd}}).second) {
if (!commands.insert({name, commandRecord_t{std::move(description), &cmd}}).second) {
commandLog.Warn("Cmd::AddCommand: %s already defined", name);
}
}
@@ -78,7 +78,7 @@ namespace Cmd {

//TODO make it thread safe
// Registers a command
void AddCommand(std::string name, const CmdBase& cmd, std::string description);
void AddCommand(const std::string& name, const CmdBase& cmd, std::string description);
// Changes the description of a command
void ChangeDescription(std::string name, std::string description);
// Removes a command
@@ -231,8 +231,7 @@ namespace Cvar {
}
}

std::string oldValue = std::move(cvar->value);
cvar->value = std::move(value);
std::swap(cvar->value, value);
cvar->flags |= flags;

// mark for archival if flagged as archive-on-change
@@ -250,7 +249,7 @@ namespace Cvar {
//The proxy could not parse the value, rollback
Log::Notice("Value '%s' is not valid for cvar %s: %s\n",
cvar->value.c_str(), cvarName.c_str(), result.description.c_str());
cvar->value = std::move(oldValue);
cvar->value = value;
}
}
SetCCvar(*cvar);
@@ -259,12 +258,12 @@ namespace Cvar {
}

// Simple proxies for SetValueInternal
void SetValue(const std::string& cvarName, std::string value) {
InternalSetValue(cvarName, std::move(value), 0, false, true);
void SetValue(const std::string& cvarName, const std::string& value) {
InternalSetValue(cvarName, value, 0, false, true);
}

void SetValueForce(const std::string& cvarName, std::string value) {
InternalSetValue(cvarName, std::move(value), 0, true, true);
void SetValueForce(const std::string& cvarName, const std::string& value) {
InternalSetValue(cvarName, value, 0, true, true);
}

std::string GetValue(const std::string& cvarName) {
@@ -308,7 +307,7 @@ namespace Cvar {
cvar->flags |= flags;
cvar->proxy = proxy;

cvar->resetValue = std::move(defaultValue);
cvar->resetValue = defaultValue;
cvar->description = "";

/*
@@ -483,8 +482,8 @@ namespace Cvar {
return info;
}

void SetValueCProxy(const std::string& cvarName, std::string value) {
InternalSetValue(cvarName, std::move(value), 0, true, false);
void SetValueCProxy(const std::string& cvarName, const std::string& value) {
InternalSetValue(cvarName, value, 0, true, false);
}

/*
@@ -63,9 +63,9 @@ namespace Cvar {

// Generic ways to access cvars, might specialize it to parse and serialize automatically

void SetValue(const std::string& cvarName, std::string value);
void SetValue(const std::string& cvarName, const std::string& value);
//Used for ROM cvars, will trigger a warning if the cvar is not ROM
void SetValueForce(const std::string& cvarName, std::string value);
void SetValueForce(const std::string& cvarName, const std::string& value);
std::string GetValue(const std::string& cvarName);

// Returns a list of cvars matching the prefix as well as their description
@@ -83,7 +83,7 @@ namespace Cvar {
cvar_t* FindCCvar(const std::string& cvarName);
std::string GetCvarConfigText();
char* InfoString(int flag, bool big);
void SetValueCProxy(const std::string& cvarName, std::string value);
void SetValueCProxy(const std::string& cvarName, const std::string& value);

void SetCheatsAllowed(bool allowed);

@@ -91,12 +91,12 @@ namespace Cmd {
commandsInitialized = true;
}

void AddCommand(std::string name, const Cmd::CmdBase& cmd, std::string description) {
void AddCommand(const std::string& name, const Cmd::CmdBase& cmd, std::string description) {
if (commandsInitialized) {
GetCommandMap()[name] = {&cmd, ""};
AddCommandRPC(std::move(name), std::move(description));
AddCommandRPC(name, std::move(description));
} else {
GetCommandMap()[std::move(name)] = {&cmd, std::move(description)};
GetCommandMap()[name] = {&cmd, std::move(description)};
}
}

@@ -317,7 +317,7 @@ namespace Cvar{
return value;
}

void SetValue(const std::string& name, std::string value) {
void SetValue(const std::string& name, const std::string& value) {
VM::SendMsg<VM::SetCvarMsg>(name, value);
}

0 comments on commit 4e2fbd0

Please sign in to comment.