summaryrefslogtreecommitdiff
path: root/builtin/profiler/init.lua
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2017-06-03 14:55:10 -0400
committerShadowNinja <shadowninja@minetest.net>2017-06-03 14:55:10 -0400
commitcaecdb681c428c1aab9c0f7eec2570c0460f995c (patch)
treee5115982ea59bbf2343ba9b35bc4a0cfbb56f407 /builtin/profiler/init.lua
parent81d56b94919dceb7b2e51d70b21a7ca22f852bd5 (diff)
parent80dc961d24e1964e25d57039ddb2ba639f9f4d22 (diff)
downloadminetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.gz
minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.bz2
minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.zip
Merge 0.4.16 into stable-0.4
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