diff options
author | r-obert <r-obert@users.noreply.github.com> | 2017-11-10 16:26:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-10 16:26:00 +0100 |
commit | b35ca66cae7ab7989fbc0744f79962b734d354a9 (patch) | |
tree | 53006e1936d421c50570fad51e08841d02457f1d | |
parent | 4391aa863e5f54f48083778f06aa859c434f9b7f (diff) | |
download | pry-b35ca66cae7ab7989fbc0744f79962b734d354a9.tar.gz |
do not capture a Proc in Text helper methods. (#1691)
The &block we were capturing is not used or passed anywhere. For performance,
we shouldn't capture a Proc that we do not use. Improve documentation of both
methods.
* update CHANGELOG.md
-rw-r--r-- | CHANGELOG.md | 8 | ||||
-rw-r--r-- | lib/pry/helpers/text.rb | 15 |
2 files changed, 17 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2be44372..205b84c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,14 @@ #### Bug fixes +* Do not capture unused Proc objects in Text helper methods `no_color` and `no_paging`, + for performance reasons. Improve the documentation of both methods. + +See pull request [#1691](https://github.com/pry/pry/pull/1691). + * Fix `String#pp` output color. -[#1674](https://github.com/pry/pry/pull/1674) + +See pull request [#1674](https://github.com/pry/pry/pull/1674). ### 0.11.0 diff --git a/lib/pry/helpers/text.rb b/lib/pry/helpers/text.rb index 6c171da7..a2df6f6b 100644 --- a/lib/pry/helpers/text.rb +++ b/lib/pry/helpers/text.rb @@ -62,10 +62,13 @@ class Pry end alias_method :bright_default, :bold - # Executes the block with `Pry.config.color` set to false. + # # @yield + # Yields a block with color turned off. + # # @return [void] - def no_color(&block) + # + def no_color boolean = Pry.config.color Pry.config.color = false yield @@ -73,10 +76,13 @@ class Pry Pry.config.color = boolean end - # Executes the block with `Pry.config.pager` set to false. + # # @yield + # Yields a block with paging turned off. + # # @return [void] - def no_pager(&block) + # + def no_pager boolean = Pry.config.pager Pry.config.pager = false yield @@ -108,4 +114,3 @@ class Pry end end end - |