From 15c8b888c52a9bcad498c4281004969fda6f87eb Mon Sep 17 00:00:00 2001 From: kk-ds-000 <109396253+kk-ds-000@users.noreply.github.com> Date: Thu, 18 Aug 2022 03:48:07 -0700 Subject: [PATCH] Avoid string allocations when generating object name --- lib/yard/code_objects/base.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/yard/code_objects/base.rb b/lib/yard/code_objects/base.rb index 5a724cf24..27b37e549 100644 --- a/lib/yard/code_objects/base.rb +++ b/lib/yard/code_objects/base.rb @@ -434,7 +434,10 @@ def docstring=(comments) # # @return [Symbol] the type of code object this represents def type - self.class.name.split('::').last.gsub(/Object$/, '').downcase.to_sym + obj_name = self.class.name.split('::').last + obj_name.gsub!(/Object$/, '') + obj_name.downcase! + obj_name.to_sym end # Represents the unique path of the object. The default implementation