Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master perf proper #510

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/sprockets/cache.rb
Expand Up @@ -67,7 +67,8 @@ def self.default_logger
# cache - A compatible backend cache store instance.
def initialize(cache = nil, logger = self.class.default_logger)
@cache_wrapper = get_cache_wrapper(cache)
@fetch_cache = Cache::MemoryStore.new(1024)
fetch_cache_size = cache.respond_to?(:max_size) ? cache.max_size / 1000 : 1024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why divide by 1000? Why not just have them input the number that they want?

Also dividing an integer by an integer will give us a bad value 1/1000 # => 0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have new patches, need to cleanup and a new pull request will follow, maybe next week.

@fetch_cache = Cache::MemoryStore.new(fetch_cache_size)
@logger = logger
end

Expand Down
3 changes: 3 additions & 0 deletions lib/sprockets/cache/file_store.rb
Expand Up @@ -22,6 +22,9 @@ class FileStore
DEFAULT_MAX_SIZE = 25 * 1024 * 1024
EXCLUDED_DIRS = ['.', '..'].freeze
GITKEEP_FILES = ['.gitkeep', '.keep'].freeze

attr_reader :max_size

# Internal: Default standard error fatal logger.
#
# Returns a Logger.
Expand Down
4 changes: 2 additions & 2 deletions lib/sprockets/uri_utils.rb
Expand Up @@ -48,8 +48,8 @@ def split_file_uri(uri)
path = URI::Generic::DEFAULT_PARSER.unescape(path)
path.force_encoding(Encoding::UTF_8)

# Hack for parsing Windows "file:///C:/Users/IEUser" paths
path.gsub!(/^\/([a-zA-Z]:)/, '\1'.freeze)
# Hack for parsing Windows "/C:/Users/IEUser" paths
path = path[1..-1] if File::ALT_SEPARATOR

[scheme, host, path, query]
end
Expand Down