Reorder indexable checks to defer calling size

This commit is contained in:
Joshua Peek
2011-05-27 14:28:37 -05:00
parent b1eba0e070
commit 817a234ab7
3 changed files with 9 additions and 9 deletions

View File

@@ -216,18 +216,18 @@ module Linguist
# #
# Return true or false # Return true or false
def indexable? def indexable?
if size > 100 * 1024 if !text?
false
elsif !text?
false
elsif generated?
false false
elsif ['.po', '.sql'].include?(pathname.extname) elsif ['.po', '.sql'].include?(pathname.extname)
false false
elsif Language.find_by_extension(pathname.extname) elsif !Language.find_by_extension(pathname.extname)
true
else
false false
elsif generated?
false
elsif size > 100 * 1024
false
else
true
end end
end end

0
test/fixtures/blob/file.txt vendored Normal file
View File

View File

@@ -172,7 +172,7 @@ class TestBlob < Test::Unit::TestCase
def test_indexable def test_indexable
assert blob("file.txt").indexable? assert blob("file.txt").indexable?
assert blob("file.rb").indexable? assert blob("foo.rb").indexable?
assert !blob("defun.kt").indexable? assert !blob("defun.kt").indexable?
assert !blob("github.po").indexable? assert !blob("github.po").indexable?
assert !blob("dump.sql").indexable? assert !blob("dump.sql").indexable?