meta: avoid creating a new shared_ptr if not needed (perf)
This commit is contained in:
2
TODO
2
TODO
@@ -35,6 +35,6 @@ TODO:
|
||||
* meta non-const allow_cast overloads: (const int &) to (int &) is not allowed, but (const int &) to (double &) is allowed (support only for convertibles)
|
||||
* review build process for testbed (i.e. tests first due to SDL)
|
||||
* use any for meta_custom_node
|
||||
* avoid copying meta_type/data/func nodes
|
||||
* avoid copying meta_type/data/func nodes, and use unique_ptr for meta_custom
|
||||
* paged vector as a standalone class
|
||||
* resource: shared_from_this?
|
||||
|
||||
@@ -786,7 +786,7 @@ struct meta_custom {
|
||||
*/
|
||||
template<typename Type>
|
||||
[[nodiscard]] operator Type *() const noexcept {
|
||||
return (type_id<Type>().hash() == node.type) ? std::static_pointer_cast<Type>(node.value).get() : nullptr;
|
||||
return (type_id<Type>().hash() == node.type) ? static_cast<Type *>(node.value.get()) : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -796,7 +796,7 @@ struct meta_custom {
|
||||
template<typename Type>
|
||||
[[nodiscard]] operator Type &() const noexcept {
|
||||
ENTT_ASSERT(type_id<Type>().hash() == node.type, "Invalid type");
|
||||
return *std::static_pointer_cast<Type>(node.value);
|
||||
return *static_cast<Type *>(node.value.get());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user