Small code style changes

This commit is contained in:
Coder12a 2019-01-09 16:26:26 -06:00
parent 647330a033
commit 69f789e5fd

View File

@ -13,7 +13,6 @@ function colddb.Colddb(directory)
local self = {}
self.db = {
global_tag = "",
directory = directory,
tags = {},
mem_pool = {},
@ -70,9 +69,10 @@ function colddb.Colddb(directory)
local function delete_lines_func_end(args)
local cs = args.cs
if self.db.indexes_pool[cs] or self.db.indexes_pool[cs].file then
self.db.indexes_pool[cs].file:close()
self.db.indexes_pool[cs].file = nil
local index = self.db.indexes_pool[cs]
if index and index.file then
index.file:close()
index.file = nil
args.file:seek("set")
args.file:write(string.format("%i", args.count))
args.file:close()
@ -83,10 +83,12 @@ function colddb.Colddb(directory)
os.remove(args.oldfile)
os.rename(args.copyfile, args.oldfile)
end
local pool = self.db.indexes_pool[cs]
for i, l in pairs(args.removedlist) do
self.db.indexes_pool[cs].deleted_items[i] = nil
pool.deleted_items[i] = nil
end
self.db.indexes_pool[cs].deleting = false
pool.deleting = false
self.db.indexes_pool[cs] = pool
end
args = nil
end
@ -96,7 +98,7 @@ function colddb.Colddb(directory)
local fl = f.file
self.db.async.iterate(1, count, function(i)
local line = fl:read("*l")
if args.do_not_skip_removed_items or not self.db.indexes_pool[cs].deleted_items[line] then
if args.do_not_skip_removed_items or not f.deleted_items[line] then
local ar = func_on_iterate(line, i, args)
if ar ~= nil then
args = ar
@ -107,8 +109,9 @@ function colddb.Colddb(directory)
if end_func then
end_func(args)
end
if self.db.iterate_queue[cs] and self.db.iterate_queue[cs][1] then
local copy = self.db.iterate_queue[cs][1]
local iterate_queue = self.db.iterate_queue[cs]
if iterate_queue and iterate_queue[1] then
local copy = iterate_queue[1]
f = self.db.indexes_pool[cs]
if not f or not f.file then
self.open_index_table(copy.tag_name)
@ -139,12 +142,14 @@ function colddb.Colddb(directory)
t = self.get_tag(tag_name)
end
local cs = string.format("%s%s", t, name)
if not self.db.mem_pool[cs] then
self.db.mem_pool[cs] = {mem = _table, indexes = self.db.indexes}
local mem_pool = self.db.mem_pool[cs]
if not mem_pool then
mem_pool = {mem = _table, indexes = self.db.indexes}
else
self.db.mem_pool[cs].mem = _table
self.db.mem_pool[cs].indexes = self.db.indexes
mem_pool.mem = _table
mem_pool.indexes = self.db.indexes
end
self.db.mem_pool[cs] = mem_pool
end
end
@ -324,12 +329,12 @@ function colddb.Colddb(directory)
f.deleted_items[i] = true
end
end
if not self.db.indexes_pool[cs].deleting then
if not f.deleting then
self.db.indexes_pool[cs].deleting = false
end
if f and f.file and not self.db.indexes_pool[cs].deleting then
if f and f.file and not f.deleting then
self.db.indexes_pool[cs].deleting = true
if self.db.indexes_pool[cs].needs_flushing == true then
if f.needs_flushing == true then
f.file:flush()
self.db.indexes_pool[cs].needs_flushing = false
end
@ -649,7 +654,7 @@ function colddb.Colddb(directory)
self.db.mem_pool_del[cs] = true
if self.db.indexes and self.file_Exists("æIndex_table", tag_name) then
self.db.async.queue_task(function()
local cs2 = string.format("%s%s",t,"æIndex_table")
local cs2 = string.format("%s%s", t, "æIndex_table")
if not (self.db.indexes_pool[cs2] and self.db.indexes_pool[cs2].file) then
self.open_index_table(tag_name)
end