From 3731753efa1a22c0b31ef121cbd57b6fcc687db8 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Thu, 27 Oct 2016 17:42:13 +0200 Subject: [PATCH] sl: remove _sorted suffix Signed-off-by: Tobias Ulmer --- local/e2-dlist.lua | 2 +- local/e2-fetch-sources.lua | 2 +- local/e2-ls-project.lua | 6 +++--- local/e2build.lua | 6 +++--- local/e2tool.lua | 4 ++-- local/result.lua | 10 +++++----- local/sl.lua | 13 +++++-------- plugins/collect_project.lua | 20 ++++++++++---------- plugins/cvs.lua | 6 +++--- plugins/files.lua | 10 +++++----- plugins/git.lua | 6 +++--- plugins/svn.lua | 6 +++--- 12 files changed, 44 insertions(+), 47 deletions(-) diff --git a/local/e2-dlist.lua b/local/e2-dlist.lua index f3bed30..6fd1b71 100644 --- a/local/e2-dlist.lua +++ b/local/e2-dlist.lua @@ -61,7 +61,7 @@ local function e2_dlist(arg) if opts.recursive then dep, re = e2tool.dlist_recursive(resultname) else - dep, re = result.results[resultname]:depends_list():totable_sorted() + dep, re = result.results[resultname]:depends_list():totable() end if not dep then error(re) diff --git a/local/e2-fetch-sources.lua b/local/e2-fetch-sources.lua index e73f6c8..15685a2 100644 --- a/local/e2-fetch-sources.lua +++ b/local/e2-fetch-sources.lua @@ -182,7 +182,7 @@ local function e2_fetch_source(arg) e2lib.logf(3, "is regarded as result: %s", srcresname) local res = result.results[srcresname] - for sourcename in res:sources_list():iter_sorted() do + for sourcename in res:sources_list():iter() do sel[sourcename] = true end elseif opts.result then diff --git a/local/e2-ls-project.lua b/local/e2-ls-project.lua index 5b08170..d17b47f 100644 --- a/local/e2-ls-project.lua +++ b/local/e2-ls-project.lua @@ -104,7 +104,7 @@ local function e2_ls_project(arg) for _, resultname in pairs(results) do local res = result.results[resultname] - for sourcename in res:sources_list():iter_sorted() do + for sourcename in res:sources_list():iter() do if not yet[sourcename] then table.insert(sources, sourcename) yet[sourcename] = true @@ -173,7 +173,7 @@ local function e2_ls_project(arg) console.infof("digraph \"%s\" {\n", project.name()) for _, r in pairs(results) do local res = result.results[r] - local deps, re = res:depends_list():totable_sorted() + local deps, re = res:depends_list():totable() if not deps then error(re) end @@ -189,7 +189,7 @@ local function e2_ls_project(arg) console.infof(" \"%s\"\n", r) end if opts["dot-sources"] then - for src in res:sources_list():iter_sorted() do + for src in res:sources_list():iter() do if opts.swap then console.infof(" \"%s-src\" %s \"%s\"\n", src, arrow, r) else diff --git a/local/e2build.lua b/local/e2build.lua index 50cd1b9..79a5515 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -422,7 +422,7 @@ function e2build.build_process_class:_setup_chroot(res, return_flags) end local grp, path - for cgrpnm in res:chroot_list():iter_sorted() do + for cgrpnm in res:chroot_list():iter() do grp = chroot.groups_byname[cgrpnm] for f in grp:file_iter() do @@ -678,7 +678,7 @@ function e2build.build_process_class:_install_build_time_dependencies(res, retur info = e2tool.info() - for dependsname in dependslist:iter_sorted() do + for dependsname in dependslist:iter() do dep = result.results[dependsname] destdir = e2lib.join(res:build_config().T, "dep", dep:get_name()) @@ -697,7 +697,7 @@ function e2build.build_process_class:_install_sources(res, return_flags) bc = res:build_config() info = e2tool.info() - for sourcename in res:sources_list():iter_sorted() do + for sourcename in res:sources_list():iter() do e = err.new("installing source failed: %s", sourcename) destdir = e2lib.join(bc.T, "build") diff --git a/local/e2tool.lua b/local/e2tool.lua index 290dcb2..f517d20 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -582,7 +582,7 @@ function e2tool.dlist_recursive(resultv) deps = result.results[resultname]:depends_list() - for d in deps:iter_sorted() do + for d in deps:iter() do rc, re = visit(d) if not rc then return false, re @@ -595,7 +595,7 @@ function e2tool.dlist_recursive(resultv) return true end - for resultname in depends:iter_sorted() do + for resultname in depends:iter() do rc, re = visit(resultname) if not rc then return false, re diff --git a/local/result.lua b/local/result.lua index 741fc4b..da4a467 100644 --- a/local/result.lua +++ b/local/result.lua @@ -351,7 +351,7 @@ end function result.result_class:post_initialize() local e - for depname in self:depends_list():iter_sorted() do + for depname in self:depends_list():iter() do if not result.results[depname] then e = e or err.new("in result %s:", self:get_name()) e:append("dependency does not exist: %s", depname) @@ -452,7 +452,7 @@ function result.result_class:merged_env() e:merge(projenv.get_global_env(), false) -- Sources env - for sourcename in self._sources_list:iter_sorted() do + for sourcename in self._sources_list:iter() do local src = source.sources[sourcename] e:merge(src:get_env(), true) end @@ -486,7 +486,7 @@ function result.result_class:buildid() hash.hash_append(hc, self:get_type()) -- sources - for sourcename in self:sources_list():iter_sorted() do + for sourcename in self:sources_list():iter() do local src, sourceset src = source.sources[sourcename] @@ -501,7 +501,7 @@ function result.result_class:buildid() end -- chroot - for groupname in self:chroot_list():iter_sorted() do + for groupname in self:chroot_list():iter() do id, re = chroot.groups_byname[groupname]:chrootgroupid(info) if not id then return false, e:cat(re) @@ -526,7 +526,7 @@ function result.result_class:buildid() -- depends - for depname in self:depends_list():iter_sorted() do + for depname in self:depends_list():iter() do id, re = result.results[depname]:buildid() if not id then return false, re diff --git a/local/sl.lua b/local/sl.lua index 32d8b62..df03826 100644 --- a/local/sl.lua +++ b/local/sl.lua @@ -24,9 +24,6 @@ local err = require("err") local e2lib = require("e2lib") local strict = require("strict") --- TODO: remove _sorted from method names, --- insertion order methods were and should not be used - --- 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. @@ -123,7 +120,7 @@ end --- Iterate through the string list in alphabetical order. -- @return Iterator function. -function sl.sl:iter_sorted() +function sl.sl:iter() local t = {} local i = 0 @@ -150,13 +147,13 @@ end --- Concatenate the string list in alphabetical order. -- @param sep Separator, defaults to empty string. -- @return Concatenated string. -function sl.sl:concat_sorted(sep) +function sl.sl:concat(sep) assert(sep == nil or type(sep) == "string") local first = true local cat = "" sep = sep or "" - for e in self:iter_sorted() do + for e in self:iter() do if first then cat = e first = false @@ -170,7 +167,7 @@ end --- Return string list entries as an array. -- @return Sorted array. -function sl.sl:totable_sorted() +function sl.sl:totable() local t = {} self:_sort_if_needed() for _,v in ipairs(self._list) do @@ -183,7 +180,7 @@ end -- vectors, variadic functions, etc. -- @return All entries as individual return values, in sorted order. function sl.sl:unpack() - return unpack(self:totable_sorted()) + return unpack(self:totable()) end return strict.lock(sl) diff --git a/plugins/collect_project.lua b/plugins/collect_project.lua index 75837e3..9a36ad8 100644 --- a/plugins/collect_project.lua +++ b/plugins/collect_project.lua @@ -124,7 +124,7 @@ local function _build_collect_project(self, res, return_flags) end cp_depends:insert_table(rc) - for depname in cp_depends:iter_sorted() do + for depname in cp_depends:iter() do local dep = result.results[depname] if dep:get_type() ~= "result" then @@ -136,7 +136,7 @@ local function _build_collect_project(self, res, return_flags) cp_sources:insert_sl(dep:sources_list()) end - for sourcename in cp_sources:iter_sorted() do + for sourcename in cp_sources:iter() do local src = source.sources[sourcename] cp_licences:insert_sl(src:get_licences()) end @@ -183,7 +183,7 @@ local function _build_collect_project(self, res, return_flags) -- generate build driver file for each result -- project/chroot// - for g in cp_chroot:iter_sorted() do + for g in cp_chroot:iter() do e2lib.logf(3, "chroot group: %s", g) local grp = chroot.groups_byname[g] local destdir = e2lib.join(bc.T, "project/chroot", g) @@ -231,7 +231,7 @@ local function _build_collect_project(self, res, return_flags) end -- project/licences// - for licname in cp_licences:iter_sorted() do + for licname in cp_licences:iter() do local lic = licence.licences[licname] e2lib.logf(3, "licence: %s", lic:get_name()) local destdir = @@ -258,7 +258,7 @@ local function _build_collect_project(self, res, return_flags) end -- project/results// - for depname in cp_depends:iter_sorted() do + for depname in cp_depends:iter() do e2lib.logf(3, "result: %s", depname) local dep = result.results[depname] local depbc = dep:build_config() @@ -304,9 +304,9 @@ local function _build_collect_project(self, res, return_flags) -- generate config out = { string.format("### generated by e2factory for result %s ###\n", depname), - string.format("CHROOT='%s'\n", dep:chroot_list():concat_sorted(" ")), - string.format("DEPEND='%s'\n", dep:depends_list():concat_sorted(" ")), - string.format("SOURCE='%s'\n", dep:sources_list():concat_sorted(" ")), + string.format("CHROOT='%s'\n", dep:chroot_list():concat(" ")), + string.format("DEPEND='%s'\n", dep:depends_list():concat(" ")), + string.format("SOURCE='%s'\n", dep:sources_list():concat(" ")), } local config = e2lib.join(destdir, "config") @@ -316,7 +316,7 @@ local function _build_collect_project(self, res, return_flags) end end - for sourcename in cp_sources:iter_sorted() do + for sourcename in cp_sources:iter() do e2lib.logf(3, "source: %s", sourcename) local destdir = e2lib.join(bc.T, "project", e2tool.sourcedir(sourcename)) @@ -335,7 +335,7 @@ local function _build_collect_project(self, res, return_flags) -- write topologically sorted list of result local destdir = e2lib.join(bc.T, "project") local tsorted_results, re = - e2tool.dlist_recursive(cp_depends:totable_sorted()) + e2tool.dlist_recursive(cp_depends:totable()) if not tsorted_results then return false, e:cat(re) end diff --git a/plugins/cvs.lua b/plugins/cvs.lua index 6ac33b5..2c2fa3e 100644 --- a/plugins/cvs.lua +++ b/plugins/cvs.lua @@ -222,7 +222,7 @@ function cvs.cvs_source:sourceid(sourceset) hash.hash_append(hc, self._type) hash.hash_append(hc, self._env:id()) licences = self:get_licences() - for licencename in licences:iter_sorted() do + for licencename in licences:iter() do lid, re = licence.licences[licencename]:licenceid(info) if not lid then return false, re @@ -265,7 +265,7 @@ function cvs.cvs_source:display() table.insert(d, string.format("working = %s", self._working)) licences = self:get_licences() - for licencename in licences:iter_sorted() do + for licencename in licences:iter() do table.insert(d, string.format("licence = %s", licencename)) end @@ -476,7 +476,7 @@ function cvs.toresult(info, sourcename, sourceset, directory) local destdir = string.format("%s/licences", directory) local fname = string.format("%s/%s.licences", destdir, archive) local licenses = src:get_licences() - local licence_list = licenses:concat_sorted("\n").."\n" + local licence_list = licenses:concat("\n").."\n" rc, re = e2lib.mkdir_recursive(destdir) if not rc then diff --git a/plugins/files.lua b/plugins/files.lua index 2ca0dab..358b137 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -278,7 +278,7 @@ function files.files_source:sourceid(sourceset --[[always ignored for files]]) hash.hash_append(hc, self._env:id()) -- all licences - for licencename in self:get_licences():iter_sorted() do + for licencename in self:get_licences():iter() do local lid, re = licence.licences[licencename]:licenceid(info) if not lid then return false, re @@ -299,7 +299,7 @@ function files.files_source:sourceid(sourceset --[[always ignored for files]]) hash.hash_append(hc, tostring(f.copy)) -- per file licence list - for licencename in f.licences:iter_sorted() do + for licencename in f.licences:iter() do local lid, re = licence.licences[licencename]:licenceid(info) if not lid then return false, re @@ -323,13 +323,13 @@ function files.files_source:display() d = {} table.insert(d, string.format("type = %s", self:get_type())) table.insert(d, string.format("licences = %s", - self:get_licences():concat_sorted(" "))) + self:get_licences():concat(" "))) for f in self:file_iter() do s = string.format("file = %s:%s", f.server, f.location) table.insert(d, s) table.insert(d, string.format("licences = %s", - f.licences:concat_sorted(" "))) + f.licences:concat(" "))) end if self._sourceid then @@ -746,7 +746,7 @@ function files.toresult(info, sourcename, sourceset, directory) local destdir = string.format("%s/licences", directory) local fname = string.format("%s/%s.licences", destdir, e2lib.basename(file.location)) - local licence_list = file.licences:concat_sorted("\n") .. "\n" + local licence_list = file.licences:concat("\n") .. "\n" rc, re = e2lib.mkdir_recursive(destdir) if not rc then return false, e:cat(re) diff --git a/plugins/git.lua b/plugins/git.lua index 9d98489..70cc3c6 100644 --- a/plugins/git.lua +++ b/plugins/git.lua @@ -201,7 +201,7 @@ function git.git_source:sourceid(sourceset) hash.hash_append(hc, self._env:id()) licences = self:get_licences() - for licencename in licences:iter_sorted() do + for licencename in licences:iter() do local lid, re = licence.licences[licencename]:licenceid(info) if not lid then return false, re @@ -244,7 +244,7 @@ function git.git_source:display() table.insert(d, string.format("working = %s", self._working)) licences = self:get_licences() - for licencename in licences:iter_sorted() do + for licencename in licences:iter() do table.insert(d, string.format("licence = %s", licencename)) end @@ -713,7 +713,7 @@ function git.toresult(info, sourcename, sourceset, directory) local destdir = e2lib.join(directory, "licences") local fname = string.format("%s/%s.licences", destdir, archive) local licences = src:get_licences() - local licence_list = licences:concat_sorted("\n") .. "\n" + local licence_list = licences:concat("\n") .. "\n" rc, re = e2lib.mkdir_recursive(destdir) if not rc then return false, e:cat(re) diff --git a/plugins/svn.lua b/plugins/svn.lua index d88843e..1177740 100644 --- a/plugins/svn.lua +++ b/plugins/svn.lua @@ -281,7 +281,7 @@ function svn.svn_source:sourceid(sourceset) assert(type(info) == "table") licences = self:get_licences() - for licencename in licences:iter_sorted() do + for licencename in licences:iter() do lid, re = licence.licences[licencename]:licenceid(info) if not lid then return false, re @@ -349,7 +349,7 @@ function svn.svn_source:display() table.insert(d, string.format("working = %s", self._working)) licences = self:get_licences() - for licencename in licences:iter_sorted() do + for licencename in licences:iter() do table.insert(d, string.format("licence = %s", licencename)) end @@ -512,7 +512,7 @@ function svn.toresult(info, sourcename, sourceset, directory) local destdir = e2lib.join(directory, "licences") local fname = string.format("%s/%s.licences", destdir, archive) local licences = src:get_licences() - local licence_list = licences:concat_sorted("\n") .. "\n" + local licence_list = licences:concat("\n") .. "\n" rc, re = e2lib.mkdir_recursive(destdir) if not rc then return false, e:cat(re) -- 2.39.5