mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
... that can only optimize one thing: combine `| append: 'a' | append: 'b'` into a single `| append_all: ['a', 'b']` filter call. This avoids all the intermediate allocations caused by several `append`. Also introduce a new filter `append_all: [*items]`.
17 lines
390 B
Ruby
17 lines
390 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'test_helper'
|
|
|
|
class OptimizerUnitTest < Minitest::Test
|
|
include Liquid
|
|
|
|
def test_combines_append_filters
|
|
optimizer = Optimizer.new
|
|
var = Variable.new('hello | append: "a" | append: b', ParseContext.new)
|
|
var = optimizer.optimize(var)
|
|
assert_equal([
|
|
['append_all', ["a", VariableLookup.new("b")]]
|
|
], var.filters)
|
|
end
|
|
end
|