From 34872e90d44bdde64e18b7774cf09495ec043e24 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 29 Oct 2018 11:55:49 +0900 Subject: Re-implement `Array#_inspect` and `Hash#_inspect` without blocks. To reduce the env object allocation; ref #4143 --- mrblib/array.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'mrblib/array.rb') diff --git a/mrblib/array.rb b/mrblib/array.rb index ae0868410..53d880660 100644 --- a/mrblib/array.rb +++ b/mrblib/array.rb @@ -84,8 +84,15 @@ class Array end def _inspect - return "[]" if self.size == 0 - "["+self.map{|x|x.inspect}.join(", ")+"]" + size = self.size + return "[]" if size == 0 + ary=[] + i=0 + while i