Skip to content

Commit

Permalink
Avoid allocating new option has for each row
Browse files Browse the repository at this point in the history
This just passes the worksheet options hash through to the row unchanged
and also makes it optional.
  • Loading branch information
felixbuenemann committed Sep 14, 2017
1 parent d6fd07a commit b3633f4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/xlsxtream/worksheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

module Xlsxtream
class Worksheet
def initialize(io, options)
def initialize(io, options = {})
@io = io
@rownum = 1
@sst = options[:sst]
@auto_format = options[:auto_format]
@options = options

write_header
end

def <<(row)
@io << Row.new(row, @rownum, :sst => @sst, :auto_format => @auto_format).to_xml
@io << Row.new(row, @rownum, @options).to_xml
@rownum += 1
end
alias_method :add_row, :<<
Expand Down

0 comments on commit b3633f4

Please sign in to comment.