From 3efb683d665be59c0247f538832b286cafd295e7 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Wed, 4 Mar 2020 12:36:42 +0530 Subject: [PATCH] Simplify Jekyll::Hooks.trigger logic --- lib/jekyll/hooks.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/hooks.rb b/lib/jekyll/hooks.rb index a6fbc74370f..47cdae4c613 100644 --- a/lib/jekyll/hooks.rb +++ b/lib/jekyll/hooks.rb @@ -91,11 +91,8 @@ def self.insert_hook(owner, event, priority, &block) # interface for Jekyll core components to trigger hooks def self.trigger(owner, event, *args) # proceed only if there are hooks to call - return unless @registry[owner] - return unless @registry[owner][event] - - # hooks to call for this owner and event - hooks = @registry[owner][event] + hooks = @registry.dig(owner, event) + return if hooks.nil? || hooks.empty? # sort and call hooks according to priority and load order hooks.sort_by { |h| @hook_priority[h] }.each do |hook|