From 6c2fde5eeacbc6bde5f006217cefef9479a0c163 Mon Sep 17 00:00:00 2001 From: Tom Burns Date: Mon, 22 Oct 2012 17:23:36 -0400 Subject: [PATCH] Instantiate blank string once instead of at every comparison --- lib/liquid/drop.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/liquid/drop.rb b/lib/liquid/drop.rb index c1914dc..ee2a4d7 100644 --- a/lib/liquid/drop.rb +++ b/lib/liquid/drop.rb @@ -22,6 +22,8 @@ module Liquid class Drop attr_writer :context + EMPTY_STRING = ''.freeze + # Catch all for the method def before_method(method) nil @@ -29,7 +31,7 @@ module Liquid # called by liquid to invoke a drop def invoke_drop(method_or_key) - if method_or_key && method_or_key != '' && self.class.public_method_defined?(method_or_key.to_s.to_sym) + if method_or_key && method_or_key != EMPTY_STRING && self.class.public_method_defined?(method_or_key.to_s.to_sym) send(method_or_key.to_s.to_sym) else before_method(method_or_key)