Rework several libraries to use new StringViewDictionary
This commit is contained in:
@@ -2,22 +2,18 @@
|
||||
|
||||
#define BASELIBRARY(simpleName, fullname, returnType) \
|
||||
export_func u8 simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
|
||||
Try(p->Insert(ArbUt::StringView::CalculateHash(name), t);) \
|
||||
} \
|
||||
\
|
||||
export_func u8 simpleName##_InsertWithHash(fullname* p, u32 hashedKey, returnType* t) { \
|
||||
Try(p->Insert(hashedKey, t);) \
|
||||
Try(p->Insert(ArbUt::StringView(name), t);) \
|
||||
} \
|
||||
\
|
||||
export_func u8 simpleName##_Delete(fullname* p, const char* name) { \
|
||||
Try(p->Delete(ArbUt::StringView::CalculateHash(name));) \
|
||||
Try(p->DeleteByHash(ArbUt::StringView::CalculateHash(name));) \
|
||||
} \
|
||||
\
|
||||
export_func u8 simpleName##_DeleteWithHash(fullname* p, u32 hashedKey) { Try(p->Delete(hashedKey);) } \
|
||||
export_func u8 simpleName##_DeleteWithHash(fullname* p, u32 hashedKey) { Try(p->DeleteByHash(hashedKey);) } \
|
||||
\
|
||||
export_func bool simpleName##_TryGet(fullname* p, const char* name, const returnType*& out) { \
|
||||
ArbUt::BorrowedPtr<const returnType> o; \
|
||||
auto v = p->TryGet(ArbUt::StringView::CalculateHash(name)); \
|
||||
auto v = p->TryGetByHash(ArbUt::StringView::CalculateHash(name)); \
|
||||
if (!v.has_value()) { \
|
||||
out = nullptr; \
|
||||
return false; \
|
||||
@@ -29,7 +25,7 @@
|
||||
\
|
||||
export_func bool simpleName##_TryGetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
|
||||
ArbUt::BorrowedPtr<const returnType> o; \
|
||||
auto v = p->TryGet(hashedKey); \
|
||||
auto v = p->TryGetByHash(hashedKey); \
|
||||
if (!v.has_value()) { \
|
||||
out = nullptr; \
|
||||
return false; \
|
||||
@@ -40,11 +36,11 @@
|
||||
} \
|
||||
\
|
||||
export_func u8 simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
|
||||
Try(out = p->Get(ArbUt::StringView::CalculateHash(name)).GetRaw();) \
|
||||
Try(out = p->GetByHash(ArbUt::StringView::CalculateHash(name)).GetRaw();) \
|
||||
} \
|
||||
\
|
||||
export_func u8 simpleName##_GetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
|
||||
Try(out = p->Get(hashedKey).GetRaw();) \
|
||||
Try(out = p->GetByHash(hashedKey).GetRaw();) \
|
||||
} \
|
||||
\
|
||||
export_func size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); } \
|
||||
|
||||
Reference in New Issue
Block a user