8000 Speed up HTML encoder for 1.2 by korny · Pull Request #153 · rubychan/coderay · GitHub
[go: up one dir, main page]

Skip to content

Speed up HTML encoder for 1.2 #153

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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
speedup plugin lookup
  • Loading branch information
korny committed Jun 12, 2016
commit 122dd5feef0e61ae10879f11e0fd40fdac7c3d26
20 changes: 15 additions & 5 deletions lib/coderay/helpers/plugin_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,21 @@ def load_all
# Example:
# yaml_plugin = MyPluginHost[:yaml]
def [] id, *args, &blk
plugin = validate_id(id)
begin
plugin = plugin_hash.[](plugin, *args, &blk)
end while plugin.is_a? String
plugin
if !args.empty? || blk
plugin = validate_id(id)
begin
plugin = plugin_hash.[](plugin, *args, &blk)
end while plugin.is_a? String
plugin
else
(@cache ||= Hash.new do |cache, key|
plugin = validate_id(key)
begin
plugin = plugin_hash.[](plugin)
end while plugin.is_a? String
cache[key] = plugin
end)[id]
end
end

alias load []
Expand Down
0