From 6abce2df03f7b5943de52440b829b6d1c75a3b4d Mon Sep 17 00:00:00 2001 From: "Szu-Kai Hsu (brucehsu)" Date: Thu, 26 Jan 2017 15:35:13 +0800 Subject: [PATCH 1/2] Avoid calling [] method multiple times --- lib/grape/util/stackable_values.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/grape/util/stackable_values.rb b/lib/grape/util/stackable_values.rb index 72612af5e..a6c8179bd 100644 --- a/lib/grape/util/stackable_values.rb +++ b/lib/grape/util/stackable_values.rb @@ -15,8 +15,8 @@ def [](name) return @frozen_values[name] if @frozen_values.key? name value = [] - value.concat(@inherited_values[name]) if @inherited_values[name] - value.concat(@new_values[name]) if @new_values[name] + value.concat(@inherited_values[name] || []) + value.concat(@new_values[name] || []) value end From 882eb65100a90bfc44d3876be74cca006ac17329 Mon Sep 17 00:00:00 2001 From: "Szu-Kai Hsu (brucehsu)" Date: Thu, 26 Jan 2017 16:23:55 +0800 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c7b78cdf..7862a5479 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * [#1559](https://github.com/ruby-grape/grape/pull/1559): You can once again pass `nil` to optional attributes with `values` validation set - [@ghiculescu](https://github.com/ghiculescu). * [#1562](https://github.com/ruby-grape/grape/pull/1562): Fix rainbow gem installation failure above ruby 2.3.3 on travis-ci - [@brucehsu](https://github.com/brucehsu). +* [#1561](https://github.com/ruby-grape/grape/pull/1561): Fix performance issue introduced by duplicated calls in StackableValue#[] - [@brucehsu](https://github.com/brucehsu). ### 0.19.1 (1/9/2017)