зеркало из https://github.com/github/ruby.git
[ruby/pp] Use .class.members for pretty printing Data
* Data#members might not be defined, instead it might be defined on Data subclasses or a module included there. This is notably the case on TruffleRuby which defines it there for optimization purposes. In fact the mere presence of Data#members implies a megamorphic call inside, so it seems best to avoid relying on its existence. https://github.com/ruby/pp/commit/6a97d36fbb
This commit is contained in:
Родитель
3b9cc22536
Коммит
62382a4345
|
@ -423,7 +423,7 @@ end
|
||||||
class Data # :nodoc:
|
class Data # :nodoc:
|
||||||
def pretty_print(q) # :nodoc:
|
def pretty_print(q) # :nodoc:
|
||||||
q.group(1, sprintf("#<data %s", PP.mcall(self, Kernel, :class).name), '>') {
|
q.group(1, sprintf("#<data %s", PP.mcall(self, Kernel, :class).name), '>') {
|
||||||
q.seplist(PP.mcall(self, Data, :members), lambda { q.text "," }) {|member|
|
q.seplist(PP.mcall(self, Kernel, :class).members, lambda { q.text "," }) {|member|
|
||||||
q.breakable
|
q.breakable
|
||||||
q.text member.to_s
|
q.text member.to_s
|
||||||
q.text '='
|
q.text '='
|
||||||
|
|
Загрузка…
Ссылка в новой задаче