tap: cache dir path to avoid duplicated Pathname operations
As discovered in Homebrew/homebrew#50256, this becomes a performance bottleneck as we are repeating construct same Pathname object. At the same, this commit makes the behaviors between Tap and CoreTap more consistence.
This commit is contained in:
		
							parent
							
								
									760c596a8e
								
							
						
					
					
						commit
						6e27e2db74
					
				@ -71,6 +71,7 @@ class Tap
 | 
				
			|||||||
    @remote = nil
 | 
					    @remote = nil
 | 
				
			||||||
    @formula_dir = nil
 | 
					    @formula_dir = nil
 | 
				
			||||||
    @formula_files = nil
 | 
					    @formula_files = nil
 | 
				
			||||||
 | 
					    @alias_dir = nil
 | 
				
			||||||
    @alias_files = nil
 | 
					    @alias_files = nil
 | 
				
			||||||
    @aliases = nil
 | 
					    @aliases = nil
 | 
				
			||||||
    @alias_table = nil
 | 
					    @alias_table = nil
 | 
				
			||||||
@ -298,7 +299,7 @@ class Tap
 | 
				
			|||||||
  # path to the directory of all alias files for this {Tap}.
 | 
					  # path to the directory of all alias files for this {Tap}.
 | 
				
			||||||
  # @private
 | 
					  # @private
 | 
				
			||||||
  def alias_dir
 | 
					  def alias_dir
 | 
				
			||||||
    path/"Aliases"
 | 
					    @alias_dir ||= path/"Aliases"
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # an array of all alias files of this {Tap}.
 | 
					  # an array of all alias files of this {Tap}.
 | 
				
			||||||
@ -500,12 +501,12 @@ class CoreTap < Tap
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  # @private
 | 
					  # @private
 | 
				
			||||||
  def formula_dir
 | 
					  def formula_dir
 | 
				
			||||||
    HOMEBREW_LIBRARY/"Formula"
 | 
					    @formula_dir ||= HOMEBREW_LIBRARY/"Formula"
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # @private
 | 
					  # @private
 | 
				
			||||||
  def alias_dir
 | 
					  def alias_dir
 | 
				
			||||||
    HOMEBREW_LIBRARY/"Aliases"
 | 
					    @alias_dir ||= HOMEBREW_LIBRARY/"Aliases"
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # @private
 | 
					  # @private
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user