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:
@@ -1,9 +1,9 @@
|
||||
#include "Item.hpp"
|
||||
|
||||
bool CreatureLib::Library::Item::HasFlag(const std::string& flag) const {
|
||||
bool CreatureLib::Library::Item::HasFlag(const Arbutils::CaseInsensitiveConstString& flag) const {
|
||||
return this->_flags.find(flag) != this->_flags.end();
|
||||
}
|
||||
CreatureLib::Library::Item::Item(std::string name, CreatureLib::Library::ItemCategory category,
|
||||
CreatureLib::Library::BattleItemCategory battleCategory, int32_t price,
|
||||
std::unordered_set<std::string> flags)
|
||||
std::unordered_set<Arbutils::CaseInsensitiveConstString> flags)
|
||||
: _name(name), _category(category), _battleCategory(battleCategory), _price(price), _flags(flags) {}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef CREATURELIB_ITEM_HPP
|
||||
#define CREATURELIB_ITEM_HPP
|
||||
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include "BattleItemCategory.hpp"
|
||||
@@ -13,18 +14,18 @@ namespace CreatureLib::Library {
|
||||
ItemCategory _category;
|
||||
BattleItemCategory _battleCategory;
|
||||
int32_t _price;
|
||||
std::unordered_set<std::string> _flags;
|
||||
std::unordered_set<Arbutils::CaseInsensitiveConstString> _flags;
|
||||
|
||||
public:
|
||||
Item(std::string name, ItemCategory category, BattleItemCategory battleCategory, int32_t price,
|
||||
std::unordered_set<std::string> flags);
|
||||
std::unordered_set<Arbutils::CaseInsensitiveConstString> flags);
|
||||
|
||||
inline const std::string& GetName() const { return _name; }
|
||||
inline ItemCategory GetCategory() const { return _category; }
|
||||
inline BattleItemCategory GetBattleCategory() const { return _battleCategory; }
|
||||
inline const int32_t GetPrice() const { return _price; }
|
||||
|
||||
bool HasFlag(const std::string& flag) const;
|
||||
bool HasFlag(const Arbutils::CaseInsensitiveConstString& flag) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user