remove datasheet.builder.diff

This commit is contained in:
Cloud Wu
2017-06-02 19:32:37 +08:00
parent 6e36cf9940
commit a8b5b36737

View File

@@ -20,14 +20,17 @@ local function monitor(pointer)
end)
end
local function dumpsheet(v)
if type(v) == "string" then
return v
else
return dump.dump(v)
end
end
function builder.new(name, v)
assert(dataset[name] == nil)
local datastring
if type(v) == "string" then
datastring = v
else
datastring = dump.dump(v)
end
local datastring = dumpsheet(v)
local pointer = core.stringpointer(datastring)
skynet.call(service.address, "lua", "update", name, pointer)
cache[datastring] = pointer
@@ -37,13 +40,8 @@ end
function builder.update(name, v)
local lastversion = assert(dataset[name])
local diff
if type(v) == "string" then
diff = v
else
local newversion = dump.dump(v)
diff = dump.diff(lastversion, newversion)
end
local newversion = dumpsheet(v)
local diff = dump.diff(lastversion, newversion)
local pointer = core.stringpointer(diff)
skynet.call(service.address, "lua", "update", name, pointer)
cache[diff] = pointer
@@ -57,13 +55,6 @@ function builder.compile(v)
return dump.dump(v)
end
function builder.diff(v1,v2)
local lastversion = dump.dump(v1)
local newversion = dump.dump(v2)
return dump.diff(lastversion, newversion)
end
local function datasheet_service()
local skynet = require "skynet"