Permalink
Browse files

ubuntu: Don't reference all packages, just the ones we need (langpacks)

  • Loading branch information...
1 parent 8b9d17a commit 2636be346654920c21eb9baf14cb9f0432fb3749 @iainlane committed Sep 20, 2016
Showing with 25 additions and 13 deletions.
  1. +8 −5 source/backends/ubuntu/ubupkg.d
  2. +17 −8 source/backends/ubuntu/ubupkgindex.d
@@ -39,12 +39,12 @@ extern (C) char *bindtextdomain (const char *domainname, const char *dirName) no
class UbuntuPackage : DebPackage
{
- this (string pname, string pver, string parch, string globalTmpDir, ref Array!Package allPackages)
+ this (string pname, string pver, string parch, string globalTmpDir, ref Array!Package langpacks)
{
this.globalTmpDir = globalTmpDir;
this.langpackDir = buildPath (globalTmpDir, "langpacks");
this.localeDir = buildPath (langpackDir, "locales");
- this.allPackages = allPackages;
+ this.langpacks = langpacks;
super (pname, pver, parch);
}
@@ -78,7 +78,7 @@ private:
string langpackDir;
string localeDir;
string[] langpackLocales;
- Array!Package allPackages;
+ Array!Package langpacks;
private void extractLangpacks ()
{
@@ -97,8 +97,8 @@ private:
langpackDir.mkdirRecurse ();
- foreach (pkg; allPackages) {
- if (!pkg.name.startsWith ("language-pack") || pkg.name in extracted)
+ foreach (ref pkg; langpacks) {
+ if (pkg.name in extracted)
continue;
auto upkg = to!UbuntuPackage (pkg);
@@ -109,6 +109,9 @@ private:
extracted[pkg.name] = true;
}
+ /* get back the memory */
+ langpacks.clear;
+
auto supportedd = buildPath (langpackDir, "var", "lib", "locales", "supported.d");
localeDir.mkdirRecurse ();
@@ -30,34 +30,43 @@ class UbuntuPackageIndex : DebianPackageIndex
{
private:
- Array!Package allPackages;
+ Array!Package langpacks;
public:
this (string dir)
{
/*
* UbuntuPackage needs to extract the langpacks, so we give it an array
- * of all packages. We don't do this here, as you migh think makes
- * sense, because it is a very expensive operation and we want to avoid
- * doing it if it's not necessary (when no packages being processed are
- * using langpacks).
+ * of langpacks. There is a small overhead when computing this array
+ * which might be unnecessary if no processed packages are using
+ * langpacks, but otherwise we need to keep a reference to all packages
+ * around, which is very expensive.
*/
- allPackages = make!(Array!Package);
+ langpacks = make!(Array!Package);
super (dir);
}
override
DebPackage newPackage (string name, string ver, string arch)
{
- return new UbuntuPackage (name, ver, arch, tmpDir, allPackages);
+ return new UbuntuPackage (name, ver, arch, tmpDir, langpacks);
}
override
Package[] packagesFor (string suite, string section, string arch)
{
+ import std.string : startsWith;
+
auto pkgs = super.packagesFor (suite, section, arch);
+ auto pkgslangpacks = appender!(Package[]);
+
+ foreach (ref pkg; pkgs) {
+ if (pkg.name.startsWith ("language-pack-"))
+ pkgslangpacks ~= pkg;
+ }
+
+ langpacks ~= pkgslangpacks.data;
- allPackages ~= pkgs;
return pkgs;
}
}

0 comments on commit 2636be3

Please sign in to comment.