Skip to content

Commit

Permalink
perf: prevent multiple case evaluations
Browse files Browse the repository at this point in the history
  • Loading branch information
mastodon0 authored and harttle committed Jan 10, 2020
1 parent a9afc97 commit 807e840
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/builtin/tags/case.ts
Expand Up @@ -26,10 +26,10 @@ export default {

render: function * (ctx: Context, hash: Hash, emitter: Emitter) {
const r = this.liquid.renderer
const cond = yield new Expression(this.cond).value(ctx)
for (let i = 0; i < this.cases.length; i++) {
const branch = this.cases[i]
const val = yield new Expression(branch.val).value(ctx)
const cond = yield new Expression(this.cond).value(ctx)
if (val === cond) {
yield r.renderTemplates(branch.templates, ctx, emitter)
return
Expand Down

0 comments on commit 807e840

Please sign in to comment.