]> git.e2factory.org Git - e2factory.git/commitdiff
sl: remove merge option and make it the default
authorTobias Ulmer <tu@emlix.com>
Wed, 26 Oct 2016 17:49:50 +0000 (19:49 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:18 +0000 (15:41 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/sl.lua

index cc4ced4227ca94d715a1c3ae6c0fa65540f4db06..32d8b626c233d40abee455985038852dce5959a8 100644 (file)
@@ -27,16 +27,14 @@ local strict = require("strict")
 -- TODO: remove _sorted from method names,
 -- insertion order methods were and should not be used
 
---- Class "sl" for keeping string lists.
+--- String list class that keeps entries in sorted order
+-- while ignoring duplicate entries.
 -- Trying to use string list with anything but strings throws an exception.
 sl.sl = class("sl")
 
 --- Initialize string list [sl:new()]
--- @param merge Whether entries are to be merged, defaults to false (boolean).
-function sl.sl:initialize(merge)
-    assert(merge, debug.traceback())
-    assert(merge == nil or type(merge) == "boolean")
-    self._merge = merge or false
+-- @return new string list object
+function sl.sl:initialize()
     self._list = {}
     self._need_sort = false
 end
@@ -53,10 +51,8 @@ end
 function sl.sl:insert(entry)
     assert(type(entry) == "string")
 
-    if self._merge then
-        if self:lookup(entry) then
-            return
-        end
+    if self:lookup(entry) then
+        return
     end
     table.insert(self._list, entry)
     self._need_sort = true
@@ -142,7 +138,7 @@ end
 --- Create in independent string list copy.
 -- @return New string list object.
 function sl.sl:copy()
-    local c = sl.sl:new(self._merge)
+    local c = sl.sl:new()
 
     for _,e in pairs(self._list) do
         c:insert(e)