Skip to content

Commit b35ca66

Browse files
authored
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
1 parent 4391aa8 commit b35ca66

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@
1616

1717
#### Bug fixes
1818

19+
* Do not capture unused Proc objects in Text helper methods `no_color` and `no_paging`,
20+
for performance reasons. Improve the documentation of both methods.
21+
22+
See pull request [#1691](https://github.com/pry/pry/pull/1691).
23+
1924
* Fix `String#pp` output color.
20-
[#1674](https://github.com/pry/pry/pull/1674)
25+
26+
See pull request [#1674](https://github.com/pry/pry/pull/1674).
2127

2228
### 0.11.0
2329

lib/pry/helpers/text.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,27 @@ def default(text)
6262
end
6363
alias_method :bright_default, :bold
6464

65-
# Executes the block with `Pry.config.color` set to false.
65+
#
6666
# @yield
67+
# Yields a block with color turned off.
68+
#
6769
# @return [void]
68-
def no_color(&block)
70+
#
71+
def no_color
6972
boolean = Pry.config.color
7073
Pry.config.color = false
7174
yield
7275
ensure
7376
Pry.config.color = boolean
7477
end
7578

76-
# Executes the block with `Pry.config.pager` set to false.
79+
#
7780
# @yield
81+
# Yields a block with paging turned off.
82+
#
7883
# @return [void]
79-
def no_pager(&block)
84+
#
85+
def no_pager
8086
boolean = Pry.config.pager
8187
Pry.config.pager = false
8288
yield
@@ -108,4 +114,3 @@ def indent(text, chars)
108114
end
109115
end
110116
end
111-

0 commit comments

Comments
 (0)