Adds caching for expensive type resolution.
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:
@@ -9,8 +9,10 @@
|
||||
#include "../../Battling/PkmnScriptCategory.hpp"
|
||||
#include "../../Battling/Pokemon/Pokemon.hpp"
|
||||
#include "AngelScriptMetadata.hpp"
|
||||
#include "AngelscriptUserdata.hpp"
|
||||
#include "ByteCodeHandling/FileByteCodeStream.hpp"
|
||||
#include "ByteCodeHandling/MemoryByteCodeStream.hpp"
|
||||
#include "ContextPool.hpp"
|
||||
#include "TypeRegistry/BasicScriptClass.hpp"
|
||||
#include "TypeRegistry/Battling/RegisterBattleClass.hpp"
|
||||
#include "TypeRegistry/Battling/RegisterBattleLibrary.hpp"
|
||||
@@ -48,6 +50,22 @@ static void TranslateException(asIScriptContext* ctx, void* /*userParam*/) {
|
||||
}
|
||||
}
|
||||
|
||||
AngelScriptResolver::AngelScriptResolver() : _userData(new AngelscriptUserdata(this)) {}
|
||||
|
||||
AngelScriptResolver::~AngelScriptResolver() {
|
||||
for (const auto& ius : _itemUseScripts) {
|
||||
delete ius.second;
|
||||
}
|
||||
delete _contextPool;
|
||||
for (const auto& category : _typeDatabase) {
|
||||
for (const auto& type : category.second) {
|
||||
delete type.second;
|
||||
}
|
||||
}
|
||||
delete _userData;
|
||||
_engine->ShutDownAndRelease();
|
||||
}
|
||||
|
||||
void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg, bool includeStandard) {
|
||||
for (auto scriptCategory : ScriptCategoryHelper::GetValues()) {
|
||||
_typeDatabase.Insert(scriptCategory, {});
|
||||
@@ -101,7 +119,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg,
|
||||
_engine->RegisterGlobalProperty("const StaticLibrary@ StaticLib", (void*)staticLib.get());
|
||||
}
|
||||
|
||||
_contextPool = new ContextPool(_engine);
|
||||
_contextPool = new ContextPool(_engine, _userData);
|
||||
|
||||
asPrepareMultithread();
|
||||
}
|
||||
@@ -209,6 +227,7 @@ AngelScriptResolver::LoadEvolutionScript(const ArbUt::StringView& view) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* ctx = _contextPool->RequestContext();
|
||||
|
||||
auto* factory = typeInfoOption.value().get()->GetFactoryByIndex(0);
|
||||
ctx->Prepare(factory);
|
||||
auto result = ctx->Execute();
|
||||
@@ -441,4 +460,4 @@ i32 AngelScriptResolver::IncludeCallback(const char* include, const char*, CScri
|
||||
return -102;
|
||||
}
|
||||
return builder->AddSectionFromFile((const char*)path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user