mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Avoid using iterators and throw-away heap allocations
This commit is contained in:
		
							parent
							
								
									b7bb282b99
								
							
						
					
					
						commit
						73e97ac42e
					
				
					 1 changed files with 4 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -4,11 +4,13 @@ class Ameba::Source
 | 
			
		|||
  # This class takes source code and rewrites it based
 | 
			
		||||
  # on the different correction actions supplied.
 | 
			
		||||
  class Corrector
 | 
			
		||||
    @line_sizes : Array(Int32)
 | 
			
		||||
    @line_sizes = [] of Int32
 | 
			
		||||
 | 
			
		||||
    def initialize(code : String)
 | 
			
		||||
      code.each_line(chomp: false) do |line|
 | 
			
		||||
        @line_sizes << line.size
 | 
			
		||||
      end
 | 
			
		||||
      @rewriter = Rewriter.new(code)
 | 
			
		||||
      @line_sizes = code.each_line(chomp: false).map(&.size).to_a
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Replaces the code of the given range with *content*.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue