From f04b02b27fac9c409d0da5628026648f8329a99b Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Sat, 29 Oct 2016 16:03:25 +0300 Subject: Improve performance of manif_core.get_versions To get all installed versions of a package using deps_mode, instead of deeply merging all manifests of corresponding trees, shallowly merge only tables related to that package. This affects speed of manifest manipulation and dependency resolution. Minimal performance testing suggests 3x-4x speed-up on reinstallation of a package using `luarocks make`. --- src/luarocks/manif_core.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/luarocks/manif_core.lua b/src/luarocks/manif_core.lua index 5c8928d4..82e7ea4d 100644 --- a/src/luarocks/manif_core.lua +++ b/src/luarocks/manif_core.lua @@ -88,20 +88,19 @@ end function manif_core.get_versions(name, deps_mode) assert(type(name) == "string") assert(type(deps_mode) == "string") - - local manifest = {} + + local version_set = {} path.map_trees(deps_mode, function(tree) - local loaded = manif_core.load_local_manifest(path.rocks_dir(tree)) - if loaded then - util.deep_merge(manifest, loaded) + local manifest = manif_core.load_local_manifest(path.rocks_dir(tree)) + + if manifest and manifest.repository[name] then + for version in pairs(manifest.repository[name]) do + version_set[version] = true + end end end) - - local item = next(manifest) and manifest.repository[name] - if item then - return util.keys(item) - end - return {} + + return util.keys(version_set) end return manif_core -- cgit v1.2.3-55-g6feb