Overhaul memory model to new Arbutils memory.
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-12-12 12:22:48 +01:00
parent 1dc3aafd33
commit 5c39694f19
33 changed files with 279 additions and 211 deletions

View File

@@ -45,14 +45,14 @@ namespace CreatureLib::Battling {
}
inline bool HasNext() { return _index < _size; }
ArbUt::BorrowedPtr<Script> GetNextNotNull() {
std::optional<ArbUt::BorrowedPtr<Script>> GetNextNotNull() {
while (HasNext()) {
auto s = GetNext();
if (s != nullptr) {
return s;
}
}
return nullptr;
return {};
}
ArbUt::BorrowedPtr<Script> GetNext() {

View File

@@ -27,14 +27,16 @@ namespace CreatureLib::Battling {
_lookup.Insert(script->GetName(), _scripts.Count() - 1);
}
ArbUt::BorrowedPtr<Script> Get(const ArbUt::BasicStringView& key) const { return Get(key.GetHash()); }
std::optional<ArbUt::BorrowedPtr<Script>> Get(const ArbUt::BasicStringView& key) const {
return Get(key.GetHash());
}
ArbUt::BorrowedPtr<Script> Get(uint32_t keyHash) const noexcept {
std::optional<ArbUt::BorrowedPtr<Script>> Get(uint32_t keyHash) const noexcept {
size_t v;
if (_lookup.TryGet(keyHash, v)) {
return _scripts[v];
}
return nullptr;
return {};
}
void Remove(const ArbUt::BasicStringView& key) { Remove(key.GetHash()); }