[Bps-public-commit] r15798 - Data-Hierarchy/trunk

clkao at bestpractical.com clkao at bestpractical.com
Mon Sep 8 06:52:23 EDT 2008


Author: clkao
Date: Mon Sep  8 06:52:23 2008
New Revision: 15798

Modified:
   Data-Hierarchy/trunk/   (props changed)
   Data-Hierarchy/trunk/Hierarchy.pm

Log:
 r35255 at mtl (orig r190):  clkao | 2004-09-14 05:19:32 +0800
 New API: store_fast.


Modified: Data-Hierarchy/trunk/Hierarchy.pm
==============================================================================
--- Data-Hierarchy/trunk/Hierarchy.pm	(original)
+++ Data-Hierarchy/trunk/Hierarchy.pm	Mon Sep  8 06:52:23 2008
@@ -129,14 +129,22 @@
     }
 }
 
+# use store_fast to avoid trimming duplicated value with ancestors
+sub store_fast {
+    my $self = shift;
+    $self->store (@_, 1);
+}
+
 sub store {
-    my ($self, $key, $value) = @_;
+    my ($self, $key, $value, $fast) = @_;
 
-    my $ovalue = $self->get ($key);
-    for (keys %$value) {
-	next unless defined $value->{$_};
-	delete $value->{$_}
-	    if exists $ovalue->{$_} && $ovalue->{$_} eq $value->{$_};
+    unless ($fast) {
+	my $ovalue = $self->get ($key);
+	for (keys %$value) {
+	    next unless defined $value->{$_};
+	    delete $value->{$_}
+		if exists $ovalue->{$_} && $ovalue->{$_} eq $value->{$_};
+	}
     }
     return unless keys %$value;
     $self->_store_recursively ($key, $value, $self->{hash});



More information about the Bps-public-commit mailing list