Skip to content

Commit

Permalink
Cache up to 20% of objects
Browse files Browse the repository at this point in the history
  • Loading branch information
yob committed Feb 6, 2012
1 parent 2b8a00d commit e71cd17
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/pdf/reader/object_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ObjectCache # nodoc

def initialize(lru_size = 1000)
@objects = {}
@lru_cache = LRUCache.new(:max_size => lru_size)
@lru_cache = LRUCache.new(:max_size => lru_size.to_i)
end

def [](key)
Expand Down
3 changes: 2 additions & 1 deletion lib/pdf/reader/object_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def initialize(input, opts = {})
@pdf_version = read_version
@xref = PDF::Reader::XRef.new(@io)
@trailer = @xref.trailer
@cache = PDF::Reader::ObjectCache.new
# cache up to 20% of objects. Should this be configurable?
@cache = PDF::Reader::ObjectCache.new(@xref.size * 0.2)
@sec_handler = build_security_handler(opts)
end

Expand Down

0 comments on commit e71cd17

Please sign in to comment.