mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
For loops support a range syntax for iterating a fixed number of times,
which looks like this.
```liquid
{% for i in range (1..100) %}
...
{% endfor %}
```
Previously, we converted these ranges to arrays using `to_a`, which
initialized an array containing each number in the range. Since all we
use these ranges for is iteration, this is far less efficient than
using a range iterator.
Doing this means that iterating over ranges now takes O(1) rather than O(n)
memory. See the PR for more benchmarks.
* Remove to_a cast on ranges
* Add ReversableRange iterator
* Add custom range-specific slicing logic
24 lines
429 B
Ruby
24 lines
429 B
Ruby
source 'https://rubygems.org'
|
|
git_source(:github) do |repo_name|
|
|
"https://github.com/#{repo_name}.git"
|
|
end
|
|
|
|
gemspec
|
|
|
|
group :benchmark, :test do
|
|
gem 'benchmark-ips'
|
|
gem 'memory_profiler'
|
|
|
|
install_if -> { RUBY_PLATFORM !~ /mingw|mswin|java/ } do
|
|
gem 'stackprof'
|
|
end
|
|
end
|
|
|
|
group :test do
|
|
gem 'rubocop', '~> 0.53.0'
|
|
|
|
platform :mri do
|
|
gem 'liquid-c', github: 'Shopify/liquid-c', ref: 'reversable-range'
|
|
end
|
|
end
|