Improve performance for cd/ls for containers with a large number of
authorMahlon E. Smith <mahlon@laika.com>
Thu, 17 Feb 2011 18:00:55 -0800
changeset 8 38aaae38427a
parent 7 44ab209b2a3b
child 9 cb5e528f7ff2
Improve performance for cd/ls for containers with a large number of entries. Patch from Yann Cezard <yann.cezard@univ-pau.fr>.
shelldap
--- a/shelldap	Thu Feb 17 13:17:19 2011 -0800
+++ b/shelldap	Thu Feb 17 18:00:55 2011 -0800
@@ -996,7 +996,7 @@
 	$self->base( $newbase );
 
 	# get new 'cwd' listing
-	my $s = $self->search({ scope => 'one' });
+	my $s = $self->search({ scope => 'one', attrs => ['dn'] });
 	if ( $s->{'code'} ) {
 		print "$s->{'message'}\n";
 		return;
@@ -1398,6 +1398,7 @@
 	my $self	= shift;
 	my @filters = @_;
 	my $base	= $self->base();
+	my $attrs 	= [ 'dn', 'hasSubordinates' ];
 
 	# setup filters
 	my ( $flags, $filter );
@@ -1415,13 +1416,16 @@
 	if ( $flags ) {
 		$recurse = $flags =~ /R/;
 		$long	= $flags =~ /l/;
+		if ($long) {
+			$attrs = [ '*', 'hasSubordinates' ];
+		}
 	}
 
 	my $s = $self->search({
 		scope  => $recurse ? 'sub' : 'one',
 		vals   => 1,
 		filter => $filter,
-		attrs  => [ '*', 'hasSubordinates' ]
+		attrs  => $attrs
 	});
 	if ( $s->{'code'} ) {
 		print "$s->{'message'}\n";