diff --git a/lib/puppet/file_collection.rb b/lib/puppet/file_collection.rb index 69f59ffdf..7db2600c0 100644 --- a/lib/puppet/file_collection.rb +++ b/lib/puppet/file_collection.rb @@ -1,28 +1,30 @@ # A simple way to turn file names into singletons, # so we don't have tons of copies of each file path around. class Puppet::FileCollection require 'puppet/file_collection/lookup' def self.collection @collection end def initialize @paths = [] + @inverse = {} end def index(path) - if @paths.include?(path) - return @paths.index(path) + if i = @inverse[path] + return i else @paths << path - return @paths.length - 1 + i = @inverse[path] = @paths.length - 1 + return i end end def path(index) @paths[index] end @collection = self.new end