[padb-devel] [padb] r258 committed - Improve the rng_create_from_array() function to sort the contents of t...
codesite-noreply at google.com
codesite-noreply at google.com
Tue Sep 15 18:52:24 BST 2009
Revision: 258
Author: apittman
Date: Tue Sep 15 10:51:47 2009
Log: Improve the rng_create_from_array() function to sort the contents of
the array
before processing them so that the subsequent rng_add_value() calls are
faster.
http://code.google.com/p/padb/source/detail?r=258
Modified:
/branches/cleanup/src/padb
=======================================
--- /branches/cleanup/src/padb Tue Sep 15 09:40:38 2009
+++ /branches/cleanup/src/padb Tue Sep 15 10:51:47 2009
@@ -4152,8 +4152,12 @@
sub rng_create_from_array {
my (@r) = @_;
- my $rng = rng_convert_from_user( shift @r );
- while ( defined( my $v = shift @r ) ) {
+ my $rng = rng_create_empty();
+
+ # Sort the array into numerical order so that the add_value calls
+ # can be fast.
+
+ foreach my $v (sort {$a <=> $b} @r) {
rng_add_value( $rng, $v );
}
return $rng;
More information about the padb-devel
mailing list