File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed
Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -133,9 +133,9 @@ def full_gem_path
133133
134134 def full_name
135135 if platform == Gem ::Platform ::RUBY || platform . nil?
136- "#{ name } -#{ version } " . dup . tap ( &Gem ::UNTAINT )
136+ ( + "#{ name } -#{ version } " ) . tap ( &Gem ::UNTAINT )
137137 else
138- "#{ name } -#{ version } -#{ platform } " . dup . tap ( &Gem ::UNTAINT )
138+ ( + "#{ name } -#{ version } -#{ platform } " ) . tap ( &Gem ::UNTAINT )
139139 end
140140 end
141141
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ class StubLine # :nodoc: all
3535
3636 def initialize ( data , extensions )
3737 parts = data [ PREFIX . length ..-1 ] . split ( " " , 4 )
38- @name = parts [ 0 ] . freeze
38+ @name = - parts [ 0 ]
3939 @version = if Gem ::Version . correct? ( parts [ 1 ] )
4040 Gem ::Version . new ( parts [ 1 ] )
4141 else
@@ -113,14 +113,19 @@ def data
113113
114114 Gem . open_file loaded_from , OPEN_MODE do |file |
115115 file . readline # discard encoding line
116- stubline = file . readline . chomp
116+ stubline = file . readline
117117 if stubline . start_with? ( PREFIX )
118- extensions = if /\A #{ PREFIX } / =~ file . readline . chomp
119- $'. split "\0 "
120- else
121- StubLine ::NO_EXTENSIONS
122- end
118+ extline = file . readline
123119
120+ extensions =
121+ if extline . delete_prefix! ( PREFIX )
122+ extline . chomp!
123+ extline . split "\0 "
124+ else
125+ StubLine ::NO_EXTENSIONS
126+ end
127+
128+ stubline . chomp! # readline(chomp: true) allocates 3x as much as .readline.chomp!
124129 @data = StubLine . new stubline , extensions
125130 end
126131 rescue EOFError
You can’t perform that action at this time.
0 commit comments