mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 02:40:41 -07:00
Add performance rubocop and fixes
This commit is contained in:
@@ -65,7 +65,7 @@ module Liquid
|
||||
end
|
||||
|
||||
def render(context)
|
||||
render_to_output_buffer(context, ''.dup)
|
||||
render_to_output_buffer(context, +'')
|
||||
end
|
||||
|
||||
def render_to_output_buffer(context, output)
|
||||
@@ -81,7 +81,7 @@ module Liquid
|
||||
when Variable
|
||||
render_node(context, output, node)
|
||||
when Block
|
||||
render_node(context, node.blank? ? ''.dup : output, node)
|
||||
render_node(context, node.blank? ? +'' : output, node)
|
||||
break if context.interrupt? # might have happened in a for-block
|
||||
when Continue, Break
|
||||
# If we get an Interrupt that means the block must stop processing. An
|
||||
|
||||
@@ -7,7 +7,7 @@ module Liquid
|
||||
attr_accessor :markup_context
|
||||
|
||||
def to_s(with_prefix = true)
|
||||
str = ''.dup
|
||||
str = +''
|
||||
str << message_prefix if with_prefix
|
||||
str << super()
|
||||
|
||||
@@ -22,7 +22,7 @@ module Liquid
|
||||
private
|
||||
|
||||
def message_prefix
|
||||
str = ''.dup
|
||||
str = +''
|
||||
str << if is_a?(SyntaxError)
|
||||
'Liquid syntax error'
|
||||
else
|
||||
|
||||
@@ -70,7 +70,7 @@ module Liquid
|
||||
end
|
||||
|
||||
def argument
|
||||
str = ''.dup
|
||||
str = +''
|
||||
# might be a keyword argument (identifier: expression)
|
||||
str << consume << consume << ' ' if look(:id) && look(:colon, 1)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ module Liquid
|
||||
class Ifchanged < Block
|
||||
def render_to_output_buffer(context, output)
|
||||
context.stack do
|
||||
block_output = ''.dup
|
||||
block_output = +''
|
||||
super(context, block_output)
|
||||
|
||||
if block_output != context.registers[:ifchanged]
|
||||
|
||||
@@ -12,7 +12,7 @@ module Liquid
|
||||
end
|
||||
|
||||
def parse(tokens)
|
||||
@body = ''.dup
|
||||
@body = +''
|
||||
while (token = tokens.shift)
|
||||
if token =~ FULL_TOKEN_POSSIBLY_INVALID
|
||||
@body << Regexp.last_match(1) if Regexp.last_match(1) != ''
|
||||
|
||||
@@ -204,7 +204,7 @@ module Liquid
|
||||
# render the nodelist.
|
||||
# for performance reasons we get an array back here. join will make a string out of it.
|
||||
with_profiling(context) do
|
||||
@root.render_to_output_buffer(context, output || ''.dup)
|
||||
@root.render_to_output_buffer(context, output || +'')
|
||||
end
|
||||
rescue Liquid::MemoryError => e
|
||||
context.handle_error(e)
|
||||
|
||||
Reference in New Issue
Block a user