From: tla Date: Sat, 25 Aug 2012 20:00:33 +0000 (+0200) Subject: cannot rely on Set::Scalar comparisons X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1e4b66f44b4900cd91ee3f738577eb06f13fc846;p=scpubgit%2Fstemmatology.git cannot rely on Set::Scalar comparisons --- diff --git a/lib/Text/Tradition/Analysis/Result.pm b/lib/Text/Tradition/Analysis/Result.pm index ba5c60b..43c842b 100644 --- a/lib/Text/Tradition/Analysis/Result.pm +++ b/lib/Text/Tradition/Analysis/Result.pm @@ -179,7 +179,7 @@ sub record_grouping { # correct spot in our groupinglist. my $idx = 0; foreach my $set ( $self->sets ) { - if( $set->is_subset( $group ) ) { + if( _is_subset( $set, $group ) ) { $self->_set_grouping( $idx, $group ); last; } @@ -190,6 +190,17 @@ sub record_grouping { } } +sub _is_subset { + # A replacement for the stupid Set::Scalar::is_subset + my( $set1, $set2 ) = @_; + my %all; + map { $all{$_} = 1 } $set2->members; + foreach my $m ( $set1->members ) { + return 0 unless $all{$m}; + } + return 1; +} + # A request string is the graph followed by the groups, which should form a unique # key for the result. sub object_key {