aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-10-29 16:03:25 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-10-29 17:08:51 +0300
commitf04b02b27fac9c409d0da5628026648f8329a99b (patch)
tree6b65e051d68e6be0a3f462328c52847384e77354
parent650755f9b82b678ebb1f14242e5249c5f9e6c36f (diff)
downloadluarocks-f04b02b27fac9c409d0da5628026648f8329a99b.tar.gz
luarocks-f04b02b27fac9c409d0da5628026648f8329a99b.tar.bz2
luarocks-f04b02b27fac9c409d0da5628026648f8329a99b.zip
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`.
-rw-r--r--src/luarocks/manif_core.lua21
1 files 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
88function manif_core.get_versions(name, deps_mode) 88function manif_core.get_versions(name, deps_mode)
89 assert(type(name) == "string") 89 assert(type(name) == "string")
90 assert(type(deps_mode) == "string") 90 assert(type(deps_mode) == "string")
91 91
92 local manifest = {} 92 local version_set = {}
93 path.map_trees(deps_mode, function(tree) 93 path.map_trees(deps_mode, function(tree)
94 local loaded = manif_core.load_local_manifest(path.rocks_dir(tree)) 94 local manifest = manif_core.load_local_manifest(path.rocks_dir(tree))
95 if loaded then 95
96 util.deep_merge(manifest, loaded) 96 if manifest and manifest.repository[name] then
97 for version in pairs(manifest.repository[name]) do
98 version_set[version] = true
99 end
97 end 100 end
98 end) 101 end)
99 102
100 local item = next(manifest) and manifest.repository[name] 103 return util.keys(version_set)
101 if item then
102 return util.keys(item)
103 end
104 return {}
105end 104end
106 105
107return manif_core 106return manif_core