aboutsummaryrefslogtreecommitdiffstats
path: root/util/serialization.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-10-12 00:15:08 +0200
committerKim Alvefur <zash@zash.se>2018-10-12 00:15:08 +0200
commit1789a7adf85b8c3467941d5962630745fbdac723 (patch)
tree222422bfe31840426bb1021e252ca13d7a2218a0 /util/serialization.lua
parente0a16c75dcd3416e1f87b79aac5af5c461e05a23 (diff)
downloadprosody-1789a7adf85b8c3467941d5962630745fbdac723.tar.gz
prosody-1789a7adf85b8c3467941d5962630745fbdac723.zip
util.serialization: Remove encoding of very large or very small numbers in scientific notation
Also difficult to describe this option, easier to remove it. %.18g covers a very large range of numbers
Diffstat (limited to 'util/serialization.lua')
-rw-r--r--util/serialization.lua13
1 files changed, 1 insertions, 12 deletions
diff --git a/util/serialization.lua b/util/serialization.lua
index 852b41da..64497382 100644
--- a/util/serialization.lua
+++ b/util/serialization.lua
@@ -20,11 +20,6 @@ local pcall = pcall;
local envload = require"util.envload".envload;
local pos_inf, neg_inf = math.huge, -math.huge;
-local m_log = math.log;
-local m_log10 = math.log10 or function (n)
- return m_log(n, 10);
-end
-local m_floor = math.floor;
-- luacheck: ignore 143/math
local m_type = math.type or function (n)
return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float";
@@ -124,7 +119,6 @@ local function new(opt)
local unquoted = opt.unquoted == nil and "^[%a_][%w_]*$" or opt.unquoted;
local hex = opt.hex;
local freeze = opt.freeze;
- local precision = opt.precision or 10;
-- serialize one table, recursively
-- t - table being serialized
@@ -237,12 +231,7 @@ local function new(opt)
elseif t ~= t then
return "(0/0)";
end
- local log = m_floor(m_log10(t));
- if log > precision then
- return s_format("%.18e", t);
- else
- return s_format("%.18g", t);
- end
+ return s_format("%.18g", t);
end
-- Are these faster than tostring?