Permalink
Browse files

r35304@mtl (orig r239): clkao | 2004-11-10 22:51:39 +0800

 Data::Hierarchy 0.21.
 
 


git-svn-id: svn://svn.bestpractical.com/Data-Hierarchy@15803 e417ac7c-1bcc-0310-8ffa-8f5827389a85
  • Loading branch information...
Chia-liang Kao
Chia-liang Kao committed Sep 8, 2008
1 parent bd00ea0 commit 8a3d76e21d25911d8516e12375506f9db6e7d075
Showing with 15 additions and 6 deletions.
  1. +5 −0 trunk/CHANGES
  2. +9 −5 trunk/Hierarchy.pm
  3. +1 −1 trunk/META.yml
View
@@ -1,3 +1,8 @@
+[Changes for 0.21 - Nov 10, 2004]
+
+* fix store_recursively for empty key, which should find
+ all descendents. [Autrijus]
+
[Changes for 0.20 - Sep 18, 2004]
* Make store_fast faster.
View
@@ -1,5 +1,5 @@
package Data::Hierarchy;
-$VERSION = '0.20';
+$VERSION = '0.21';
use strict;
use Clone qw(clone);
@@ -47,9 +47,10 @@ sub new {
}
sub key_safe {
- use Carp;
- confess 'key unsafe'
- if length ($_[1]) > 1 and rindex($_[1], $_[0]->{sep}) == length ($_[1]);
+ if (length ($_[1]) > 1 and rindex($_[1], $_[0]->{sep}) == length ($_[1])) {
+ require Carp;
+ Carp::confess('key unsafe');
+ }
$_[1] =~ s/\Q$_[0]->{sep}\E+$//;
}
@@ -100,13 +101,16 @@ sub merge {
sub _descendents {
my ($self, $hash, $key) = @_;
+
+ # If finding for everything, don't bother grepping
+ return sort keys %$hash unless length($key);
+
return sort grep {index($_.$self->{sep}, $key.$self->{sep}) == 0}
keys %$hash;
}
sub descendents {
my ($self, $key) = @_;
- use Carp;
my $both = {%{$self->{hash}}, %{$self->{sticky} || {}}};
# If finding for everything, don't bother grepping
View
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Data-Hierarchy
-version: 0.20
+version: 0.21
version_from: Hierarchy.pm
installdirs: site
requires:

0 comments on commit 8a3d76e

Please sign in to comment.