[padb-devel] [padb] r183 committed - Simplify rng_convert_to_user by using map to create the range list.

codesite-noreply at google.com codesite-noreply at google.com
Sat Sep 5 19:43:17 BST 2009


Revision: 183
Author: apittman
Date: Sat Sep  5 11:42:29 2009
Log: Simplify rng_convert_to_user by using map to create the range list.

http://code.google.com/p/padb/source/detail?r=183

Modified:
  /branches/cleanup/src/padb

=======================================
--- /branches/cleanup/src/padb	Fri Sep  4 17:28:14 2009
+++ /branches/cleanup/src/padb	Sat Sep  5 11:42:29 2009
@@ -1965,7 +1965,9 @@
          my %this;
          $this{txt} = $lines->{$tag}[$l];
          @{ $this{vps} } = ( $tag, @identical );
-        $this{vpspec} = compress( @identical, $tag );
+
+        $this{vpspec} =
+          rng_convert_to_user( rng_create_from_array( @{ $this{vps} } ) );

          if ( defined $prev ) {
              push @{ $prev->{children} }, \%this;
@@ -3890,15 +3892,8 @@
  sub rng_convert_to_user {
      my ($rg) = @_;

-    my @entries;
-    foreach my $part ( @{$rg} ) {
-        if ( $part->{l} == $part->{u} ) {
-            push @entries, $part->{l};
-        } else {
-            push @entries, "$part->{l}-$part->{u}";
-        }
-    }
-    my $range = join( ",", @entries );
+    my $range = join q{,},
+      map { $_->{l} == $_->{u} ? $_->{l} : $_->{l} . q{-} . $_->{u} }  
@{$rg};
      return "[$range]";
  }





More information about the padb-devel mailing list