Skip to content

Commit

Permalink
Merge pull request #536 from jhawthorn/faster_octicon_cache
Browse files Browse the repository at this point in the history
Make octicon helper slightly faster
  • Loading branch information
edokoa committed Feb 4, 2021
2 parents e0e204f + af7c6fc commit 1be3275
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/octicons_gem/lib/octicons/octicon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(symbol, options = {})
@width = octicon["width"]
@height = octicon["height"]
@keywords = octicon["keywords"]
@options = options
@options = options.dup
@options.merge!({
class: classes,
viewBox: viewbox,
Expand Down
6 changes: 3 additions & 3 deletions lib/octicons_helper/lib/octicons_helper/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ module OcticonsHelper
def octicon(symbol, options = {})
return "" if symbol.nil?

cache_key = [symbol, options].to_s
cache_key = [symbol, options]

if octicons_helper_cache[cache_key]
octicons_helper_cache[cache_key]
if tag = octicons_helper_cache[cache_key]
tag
else
icon = Octicons::Octicon.new(symbol, options)

Expand Down

0 comments on commit 1be3275

Please sign in to comment.