Improved performance when binding by reusing many common scripttype objects
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -24,11 +24,16 @@ namespace Porygon::UserData {
|
||||
return make_shared<UserDataCollectionType>(keyType, valueType, true, true);
|
||||
}
|
||||
|
||||
static UserDataCollectionType* CreateIndexable(const ScriptType* keyType, const ScriptType* valueType){
|
||||
return new UserDataCollectionType(shared_ptr<const ScriptType>(keyType),
|
||||
static shared_ptr<UserDataCollectionType> CreateIndexable(const ScriptType* keyType, const ScriptType* valueType){
|
||||
return make_shared<UserDataCollectionType>(shared_ptr<const ScriptType>(keyType),
|
||||
shared_ptr<const ScriptType>(valueType), true, true);
|
||||
}
|
||||
|
||||
static UserDataCollectionType* CreateIndexableExtern(const ScriptType* keyType, const ScriptType* valueType){
|
||||
return new UserDataCollectionType(shared_ptr<const ScriptType>(keyType),
|
||||
shared_ptr<const ScriptType>(valueType), true, true);
|
||||
}
|
||||
|
||||
static shared_ptr<UserDataCollectionType> CreateIterable(const shared_ptr<const ScriptType>& valueType){
|
||||
return make_shared<UserDataCollectionType>(nullptr, valueType, false, true);
|
||||
}
|
||||
@@ -42,7 +47,7 @@ namespace Porygon::UserData {
|
||||
if (!_indexable){
|
||||
return false;
|
||||
}
|
||||
return indexer->operator==(_keyType.get());
|
||||
return indexer->operator==(_keyType);
|
||||
}
|
||||
|
||||
[[nodiscard]] shared_ptr<const ScriptType> GetIndexedType(const ScriptType* indexer) const final{
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
namespace Porygon::UserData{
|
||||
extern "C" {
|
||||
UserDataCollectionType* CreateCollectionType(const ScriptType* keyType, const ScriptType* valueType){
|
||||
return UserDataCollectionType::CreateIndexable(keyType, valueType);
|
||||
return UserDataCollectionType::CreateIndexableExtern(keyType, valueType);
|
||||
}
|
||||
UserDataCollectionValue* CreateCollectionValue(UserDataCollectionType* type, void* obj,
|
||||
const EvalValue* (*get)(void*, const EvalValue*),
|
||||
void (*set)(void*, const EvalValue*, const EvalValue*),
|
||||
Iterator* (*getIterator)(void*)){
|
||||
return new UserDataCollectionValue(type, new UserDataCollectionHelper(obj, get, set, getIterator));
|
||||
return new UserDataCollectionValue(shared_ptr<UserDataCollectionType>(type), new UserDataCollectionHelper(obj, get, set, getIterator));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,18 +36,18 @@ namespace Porygon::UserData {
|
||||
};
|
||||
|
||||
class UserDataCollectionValue : public Evaluation::EvalValue{
|
||||
shared_ptr<UserDataCollectionType> _type;
|
||||
shared_ptr<const UserDataCollectionType> _type;
|
||||
shared_ptr<const UserDataCollectionHelper> _helper;
|
||||
const size_t _hash;
|
||||
UserDataCollectionValue(shared_ptr<UserDataCollectionType> type,
|
||||
UserDataCollectionValue(shared_ptr<const UserDataCollectionType> type,
|
||||
shared_ptr<const UserDataCollectionHelper> helper, size_t hash)
|
||||
: _type(std::move(type)), _helper(std::move(helper)), _hash(hash)
|
||||
{
|
||||
}
|
||||
public:
|
||||
|
||||
UserDataCollectionValue(ScriptType* type, const UserDataCollectionHelper* helper)
|
||||
: _type(dynamic_cast<UserDataCollectionType*>(type)), _helper(helper), _hash(Utilities::Random::Get())
|
||||
UserDataCollectionValue(shared_ptr<const ScriptType> type, const UserDataCollectionHelper* helper)
|
||||
: _type(dynamic_pointer_cast<const UserDataCollectionType>(type)), _helper(helper), _hash(Utilities::Random::Get())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user