mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Reorder indexable checks to defer calling size
This commit is contained in:
		@@ -216,18 +216,18 @@ module Linguist
 | 
			
		||||
    #
 | 
			
		||||
    # Return true or false
 | 
			
		||||
    def indexable?
 | 
			
		||||
      if size > 100 * 1024
 | 
			
		||||
        false
 | 
			
		||||
      elsif !text?
 | 
			
		||||
        false
 | 
			
		||||
      elsif generated?
 | 
			
		||||
      if !text?
 | 
			
		||||
        false
 | 
			
		||||
      elsif ['.po', '.sql'].include?(pathname.extname)
 | 
			
		||||
        false
 | 
			
		||||
      elsif Language.find_by_extension(pathname.extname)
 | 
			
		||||
        true
 | 
			
		||||
      else
 | 
			
		||||
      elsif !Language.find_by_extension(pathname.extname)
 | 
			
		||||
        false
 | 
			
		||||
      elsif generated?
 | 
			
		||||
        false
 | 
			
		||||
      elsif size > 100 * 1024
 | 
			
		||||
        false
 | 
			
		||||
      else
 | 
			
		||||
        true
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										0
									
								
								test/fixtures/blob/file.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								test/fixtures/blob/file.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -172,7 +172,7 @@ class TestBlob < Test::Unit::TestCase
 | 
			
		||||
 | 
			
		||||
  def test_indexable
 | 
			
		||||
    assert blob("file.txt").indexable?
 | 
			
		||||
    assert blob("file.rb").indexable?
 | 
			
		||||
    assert blob("foo.rb").indexable?
 | 
			
		||||
    assert !blob("defun.kt").indexable?
 | 
			
		||||
    assert !blob("github.po").indexable?
 | 
			
		||||
    assert !blob("dump.sql").indexable?
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user