aboutsummaryrefslogtreecommitdiff
path: root/builtin/profiler/init.lua
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-12-12 14:49:19 -0500
committerShadowNinja <shadowninja@minetest.net>2017-05-06 15:33:19 -0400
commit43d1f375d18a2fbc547a9b4f23d1354d645856ca (patch)
tree15de6977737b440b9d265f85dc1fe3c71e996a45 /builtin/profiler/init.lua
parenta024042bf5ad487685e952da7b96ffa845cd7731 (diff)
downloadminetest-43d1f375d18a2fbc547a9b4f23d1354d645856ca.tar.gz
minetest-43d1f375d18a2fbc547a9b4f23d1354d645856ca.tar.bz2
minetest-43d1f375d18a2fbc547a9b4f23d1354d645856ca.zip
Use a settings object for the main settings
This unifies the settings APIs. This also unifies the sync and async registration APIs, since the async registration API did not support adding non-functions to the API table.
Diffstat (limited to 'builtin/profiler/init.lua')
-rw-r--r--builtin/profiler/init.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/builtin/profiler/init.lua b/builtin/profiler/init.lua
index c1597d280..874950364 100644
--- a/builtin/profiler/init.lua
+++ b/builtin/profiler/init.lua
@@ -15,10 +15,18 @@
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+local function get_bool_default(name, default)
+ local val = core.settings:get_bool(name)
+ if val == nil then
+ return default
+ end
+ return val
+end
+
local profiler_path = core.get_builtin_path()..DIR_DELIM.."profiler"..DIR_DELIM
local profiler = {}
local sampler = assert(loadfile(profiler_path .. "sampling.lua"))(profiler)
-local instrumentation = assert(loadfile(profiler_path .. "instrumentation.lua"))(profiler, sampler)
+local instrumentation = assert(loadfile(profiler_path .. "instrumentation.lua"))(profiler, sampler, get_bool_default)
local reporter = dofile(profiler_path .. "reporter.lua")
profiler.instrument = instrumentation.instrument
@@ -27,7 +35,7 @@ profiler.instrument = instrumentation.instrument
-- Is called later, after `core.register_chatcommand` was set up.
--
function profiler.init_chatcommand()
- local instrument_profiler = core.setting_getbool("instrument.profiler") or false
+ local instrument_profiler = get_bool_default("instrument.profiler", false)
if instrument_profiler then
instrumentation.init_chatcommand()
end