Implements ConstString in several core places in the library, improving performance.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -5,10 +5,10 @@ CreatureLib::Library::AttackData::AttackData(std::string name, uint8_t type,
|
||||
CreatureLib::Library::AttackCategory category, uint8_t power,
|
||||
uint8_t accuracy, uint8_t baseUsage,
|
||||
CreatureLib::Library::AttackTarget target, int8_t priority,
|
||||
std::unordered_set<std::string> flags)
|
||||
std::unordered_set<Arbutils::CaseInsensitiveConstString> flags)
|
||||
: _name(std::move(name)), _type(type), _category(category), _basePower(power), _accuracy(accuracy),
|
||||
_baseUsages(baseUsage), _target(target), _priority(priority), _flags(std::move(flags)) {}
|
||||
|
||||
bool CreatureLib::Library::AttackData::HasFlag(const std::string& key) const {
|
||||
bool CreatureLib::Library::AttackData::HasFlag(const Arbutils::CaseInsensitiveConstString& key) const {
|
||||
return this->_flags.find(key) != this->_flags.end();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef CREATURELIB_ATTACKDATA_HPP
|
||||
#define CREATURELIB_ATTACKDATA_HPP
|
||||
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include "AttackCategory.hpp"
|
||||
@@ -17,11 +18,12 @@ namespace CreatureLib::Library {
|
||||
uint8_t _baseUsages;
|
||||
AttackTarget _target;
|
||||
int8_t _priority;
|
||||
std::unordered_set<std::string> _flags;
|
||||
std::unordered_set<Arbutils::CaseInsensitiveConstString> _flags;
|
||||
|
||||
public:
|
||||
AttackData(std::string name, uint8_t type, AttackCategory category, uint8_t power, uint8_t accuracy,
|
||||
uint8_t baseUsage, AttackTarget target, int8_t priority, std::unordered_set<std::string> flags);
|
||||
uint8_t baseUsage, AttackTarget target, int8_t priority,
|
||||
std::unordered_set<Arbutils::CaseInsensitiveConstString> flags);
|
||||
virtual ~AttackData() = default;
|
||||
|
||||
inline const std::string& GetName() const { return _name; }
|
||||
@@ -33,7 +35,7 @@ namespace CreatureLib::Library {
|
||||
inline AttackTarget GetTarget() const { return _target; }
|
||||
inline int8_t GetPriority() const { return _priority; }
|
||||
|
||||
bool HasFlag(const std::string& key) const;
|
||||
bool HasFlag(const Arbutils::CaseInsensitiveConstString& key) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user