From 8178eb5602056b5443ef71033428058871c1e7b7 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 17 Apr 2012 00:37:44 -0700 Subject: [PATCH] Use set in filewatcher --- .../lib/middleman-core/core_extensions/file_watcher.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb index 8348d8ad..b165a1b1 100644 --- a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb +++ b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb @@ -1,5 +1,6 @@ require "find" require "middleman-core/watcher" +require "set" # API for watching file change events module Middleman::CoreExtensions::FileWatcher @@ -54,7 +55,7 @@ module Middleman::CoreExtensions::FileWatcher # Initialize api and internal path cache def initialize - self.known_paths = [] + self.known_paths = Set.new end # Add callback to be run on file change @@ -83,7 +84,7 @@ module Middleman::CoreExtensions::FileWatcher # @return [void] def did_change(path) puts "== File Change: #{path}" if instance.logging? && !::Middleman::Watcher.ignore_list.any? { |r| path.match(r) } - self.known_paths << path unless self.known_paths.include?(path) + self.known_paths << path self.run_callbacks(path, :changed) end @@ -93,7 +94,7 @@ module Middleman::CoreExtensions::FileWatcher # @return [void] def did_delete(path) puts "== File Deletion: #{path}" if instance.logging? && !::Middleman::Watcher.ignore_list.any? { |r| path.match(r) } - self.known_paths.delete(path) if self.known_paths.include?(path) + self.known_paths.delete(path) self.run_callbacks(path, :deleted) end @@ -132,4 +133,4 @@ module Middleman::CoreExtensions::FileWatcher end end end -end \ No newline at end of file +end