Shopify/liquid — pull request #466 by dylanahsmith (2014-10-18 18:57:46+00:00)
Title: Remove expression cache

@pushrax & @jasonhl for review

## Problem

Pull request #391 separated `Context#[]` which parsed and rendered expressions into `Expression.parse` and `context.evaluate` to avoid memoize expression parsing. However, parsing was still happening during rendering, which prevents us from caching the parsed expression along with the parsed template in memcache.

## Solution

Use `Expression.parse` and `Context#evaluate` in all the tags instead of `Context#[]`, then remove the expression cache, since we each expression will only be cached once.

## Benchmark

Just like with pull #443 the parse and render time does increase a bit, but is still faster than before we added the expression cache. This is because the expression cache was allowing us to re-use expression objects when an expression is repeated in a template.

Here is the benchmark this branch:

```
parse: 17.8 (±11.2%) i/s - 1052 in 60.025052s
parse & run: 10.9 (±9.2%) i/s - 648 in 60.030118s
```

Here is the benchmark on master:

```
parse: 20.1 (±14.9%) i/s - 1185 in 59.993718s
parse & run: 11.1 (±9.0%) i/s - 662 in 60.003203s
```

## Future Work

The strict parser has been parsing expressions then converting them back into strings to use with `Context#[]`. This refactoring will make it easier to just parse the expression once in the strict parser.