Skip to content

Commit

Permalink
use set for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
codylerum committed Jul 7, 2012
1 parent 217ab62 commit 0c418f3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/awestruct/extensions/sitemap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ module Extensions
class Sitemap

def initialize
@excluded_files = [ '.htaccess', 'robots.txt' ]
@excluded_extensions = ['.atom', '.scss', '.css', '.png', '.jpg', '.gif', '.js' ]
@excluded_files = [ '.htaccess', 'robots.txt' ].to_set
@excluded_extensions = ['.atom', '.scss', '.css', '.png', '.jpg', '.gif', '.js' ].to_set
end

def execute( site )

# Add additional excludes from _config/sitemap.yml

if site.sitemap["excluded_files"]
@excluded_files = @excluded_files + site.sitemap.excluded_files
@excluded_files.merge(site.sitemap.excluded_files)
end
if site.sitemap["excluded_extensions"]
@excluded_extensions = @excluded_extensions + site.sitemap.excluded_extensions
@excluded_extensions.merge(site.sitemap.excluded_extensions)
end

# Go through all of the site's pages and add sitemap metadata
Expand Down Expand Up @@ -81,7 +81,7 @@ def munge_date( page )
end

def valid_sitemap_entry( page )
@excluded_files.index(page.output_filename) == nil && @excluded_extensions.index(page.output_extension) == nil
!@excluded_files.member?(page.output_filename) && !@excluded_extensions.member?(page.output_extension)
end

end
Expand Down

0 comments on commit 0c418f3

Please sign in to comment.