From 4d3e4bb38e939a5378f4796a88abd51c79f0b4f2 Mon Sep 17 00:00:00 2001 From: espie Date: Mon, 16 Apr 2007 14:36:25 +0000 Subject: [PATCH] shrink memory used by building only one single list per set of pkgnames. Also use a simple `seen' cache for files only used by one package, since they cannot participate in actual conflicts. Shrinks memory for 250M to 190M, with no negative speed effects. --- infrastructure/package/find-all-conflicts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/infrastructure/package/find-all-conflicts b/infrastructure/package/find-all-conflicts index 423094082c6..a83b6975b29 100644 --- a/infrastructure/package/find-all-conflicts +++ b/infrastructure/package/find-all-conflicts @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $OpenBSD: find-all-conflicts,v 1.13 2007/04/10 21:36:26 espie Exp $ +# $OpenBSD: find-all-conflicts,v 1.14 2007/04/16 14:36:25 espie Exp $ # Copyright (c) 2000-2005 # Marc Espie. All rights reserved. # Redistribution and use in source and binary forms, with or without @@ -45,12 +45,30 @@ sub register package OpenBSD::PackingElement::FileBase; +my $pkg_list = {}; +my $seen = {}; + sub register { my ($self, $all_conflict, $all_deps, $pkgname) = @_; my $file= File::Spec->canonpath($self->fullname()); - push @{$all_conflict->{$file}}, $pkgname; + # build one single list for each pkgnames combination + if (exists $all_conflict->{$file}) { + $pkg_list->{$all_conflict->{$file}}->{$pkgname} ||= + [@{$all_conflict->{$file}}, $pkgname ]; + $all_conflict->{$file} = + $pkg_list->{$all_conflict->{$file}}->{$pkgname}; + } elsif (exists $seen->{$file}) { + $pkg_list->{$seen->{$file}}->{$pkgname} ||= + [ @{$seen->{$file}}, $pkgname ]; + $all_conflict->{$file} = + $pkg_list->{$seen->{$file}}->{$pkgname}; + delete $seen->{$file}; + } else { + $pkg_list->{$pkgname} ||= [$pkgname]; + $seen->{$file} = $pkg_list->{$pkgname}; + } } package OpenBSD::PackingElement::Depend;