Remove ScriptContext::CreateContext

This function nudges one into using it instead of the constructor. Even
though a `std::shared_ptr` isn't required.
This commit is contained in:
phosit
2025-06-04 08:02:00 +02:00
parent 5daae13525
commit 13453a3c7b
7 changed files with 13 additions and 24 deletions
+1 -6
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -102,11 +102,6 @@ void GCSliceCallbackHook(JSContext*, JS::GCProgress progress, const JS::GCDescri
#endif
}
std::shared_ptr<ScriptContext> ScriptContext::CreateContext(int contextSize, uint32_t heapGrowthBytesGCTrigger)
{
return std::make_shared<ScriptContext>(contextSize, heapGrowthBytesGCTrigger);
}
ScriptContext::ScriptContext(int contextSize, uint32_t heapGrowthBytesGCTrigger):
m_JobQueue{std::make_unique<Script::JobQueue>()},
m_ContextSize{contextSize},
+3 -7
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -47,9 +47,6 @@ class JobQueue;
class ScriptContext
{
public:
ScriptContext(int contextSize, uint32_t heapGrowthBytesGCTrigger);
~ScriptContext();
/**
* Returns a context, in which any number of ScriptInterfaces compartments can live.
* Each context should only ever be used on a single thread.
@@ -57,10 +54,9 @@ public:
* @param contextSize Maximum size in bytes of the new context
* @param heapGrowthBytesGCTrigger Size in bytes of cumulated allocations after which a GC will be triggered
*/
static std::shared_ptr<ScriptContext> CreateContext(
int contextSize = DEFAULT_CONTEXT_SIZE,
ScriptContext(int contextSize = DEFAULT_CONTEXT_SIZE,
uint32_t heapGrowthBytesGCTrigger = DEFAULT_HEAP_GROWTH_BYTES_GCTRIGGER);
~ScriptContext();
/**
* MaybeIncrementalGC checks if running a GC is worth the time that will take.