Skip to content

Commit

Permalink
r35304@mtl (orig r239): clkao | 2004-11-10 22:51:39 +0800
Browse files Browse the repository at this point in the history
 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 committed Sep 8, 2008
1 parent bd00ea0 commit 8a3d76e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions trunk/CHANGES
@@ -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.
Expand Down
14 changes: 9 additions & 5 deletions trunk/Hierarchy.pm
@@ -1,5 +1,5 @@
package Data::Hierarchy;
$VERSION = '0.20';
$VERSION = '0.21';
use strict;
use Clone qw(clone);

Expand Down Expand Up @@ -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+$//;
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion trunk/META.yml
@@ -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:
Expand Down

0 comments on commit 8a3d76e

Please sign in to comment.