If the user's path has duplicate entries, we end up looking at them
multiple times.  This has bitten people in the past in that if you get a
lot of duplication it can make autloading a lot slower.  Really the user
shouldn't be duplicating their path, but since we can't control that,
this is a safe fix to prevent them from having autoload slowness.

Paired-with: Max Martin <m...@puppetlabs.com>
Signed-off-by: Matt Robinson <m...@puppetlabs.com>
---
Local-branch: ticket/2.7rc/maint-faces_docs_spec_fixes
 lib/puppet/util/autoload.rb     |    2 +-
 spec/unit/util/autoload_spec.rb |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb
index f0dd0a5..0e7025a 100644
--- a/lib/puppet/util/autoload.rb
+++ b/lib/puppet/util/autoload.rb
@@ -124,7 +124,7 @@ class Puppet::Util::Autoload
 
   # The list of directories to search through for loadable plugins.
   def searchpath(env=nil)
-    search_directories(env).collect { |d| File.join(d, @path) }.find_all { |d| 
FileTest.directory?(d) }
+    search_directories(env).uniq.collect { |d| File.join(d, @path) }.find_all 
{ |d| FileTest.directory?(d) }
   end
 
   def module_directories(env=nil)
diff --git a/spec/unit/util/autoload_spec.rb b/spec/unit/util/autoload_spec.rb
index 512f06c..d61b768 100755
--- a/spec/unit/util/autoload_spec.rb
+++ b/spec/unit/util/autoload_spec.rb
@@ -51,9 +51,9 @@ describe Puppet::Util::Autoload do
       @autoload.search_directories.should == %w{/one /two /libdir1 
/lib/dir/two /third/lib/dir} + $LOAD_PATH
     end
 
-    it "should include in its search path all of the search directories that 
have a subdirectory matching the autoload path" do
+    it "should include in its search path all of the unique search directories 
that have a subdirectory matching the autoload path" do
       @autoload = Puppet::Util::Autoload.new("foo", "loaddir")
-      @autoload.expects(:search_directories).returns %w{/one /two /three}
+      @autoload.expects(:search_directories).returns %w{/one /two /three 
/three}
       FileTest.expects(:directory?).with("/one/loaddir").returns true
       FileTest.expects(:directory?).with("/two/loaddir").returns false
       FileTest.expects(:directory?).with("/three/loaddir").returns true
-- 
1.7.3.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to