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