Skip to content

Commit

Permalink
Merge pull request #120 from jpmckinney/speed_blank
Browse files Browse the repository at this point in the history
Avoid using #blank? if unnecessary
  • Loading branch information
pezholio committed Feb 9, 2015
2 parents 08ab3af + 16aafbe commit 604ef4d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/csvlint/validate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ def parse_csv(io)
@data << row
if row
if current_line == 1 && header?
row = row.reject {|r| r.blank? }
row = row.reject{|col| col.nil? || col.empty?}
validate_header(row)
@col_counts << row.size
else
build_formats(row)
@col_counts << row.reject {|r| r.blank? }.size
@col_counts << row.reject{|col| col.nil? || col.empty?}.size
@expected_columns = row.size unless @expected_columns != 0

build_errors(:blank_rows, :structure, current_line, nil, wrapper.line) if row.reject{ |c| c.nil? || c.empty? }.size == 0
Expand Down Expand Up @@ -197,7 +197,7 @@ def dialect_to_csv_options(dialect)

def build_formats(row)
row.each_with_index do |col, i|
next if col.blank?
next if col.nil? || col.empty?
@formats[i] ||= Hash.new(0)

format = if col.strip[FORMATS[:numeric]]
Expand Down

0 comments on commit 604ef4d

Please sign in to comment.