mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Remove deprecated usage of sprintf
This commit is contained in:
parent
405b2976d5
commit
94597e7af6
@ -663,9 +663,7 @@ int IBonusBearer::valOfBonuses(Bonus::BonusType type, const CSelector &selector)
|
||||
int IBonusBearer::valOfBonuses(Bonus::BonusType type, int subtype) const
|
||||
{
|
||||
//This part is performance-critical
|
||||
|
||||
char cachingStr[20] = {};
|
||||
std::sprintf(cachingStr, "type_%ds_%d", (int)type, subtype);
|
||||
std::string cachingStr = "type_" + std::to_string(int(type)) + "_" + std::to_string(subtype);
|
||||
|
||||
CSelector s = Selector::type()(type);
|
||||
if(subtype != -1)
|
||||
@ -694,8 +692,7 @@ bool IBonusBearer::hasBonus(const CSelector &selector, const CSelector &limit, c
|
||||
bool IBonusBearer::hasBonusOfType(Bonus::BonusType type, int subtype) const
|
||||
{
|
||||
//This part is performance-ciritcal
|
||||
char cachingStr[20] = {};
|
||||
std::sprintf(cachingStr, "type_%ds_%d", (int)type, subtype);
|
||||
std::string cachingStr = "type_" + std::to_string(int(type)) + "_" + std::to_string(subtype);
|
||||
|
||||
CSelector s = Selector::type()(type);
|
||||
if(subtype != -1)
|
||||
|
@ -161,10 +161,12 @@ public:
|
||||
std::string toString() const
|
||||
{
|
||||
//Performance is important here
|
||||
char str[16] = {};
|
||||
std::sprintf(str, "(%d %d %d)", x, y, z);
|
||||
std::string result = "{" +
|
||||
std::to_string(x) + " " +
|
||||
std::to_string(y) + " " +
|
||||
std::to_string(z) + "}";
|
||||
|
||||
return std::string(str);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool valid() const //Should be named "isValid"?
|
||||
|
Loading…
Reference in New Issue
Block a user