Skip to content

Fix high memory usage regression due to namespaces #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions lib/creek/sheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,15 @@ def rows_generator(include_meta_data = false, use_simple_rows_format = false)
name_v = 'v'
name_t = 't'
Nokogiri::XML::Reader.from_io(xml).each do |node|
if prefix.empty? && node.namespaces.any?
namespace = node.namespaces.detect { |_key, uri| uri == SPREADSHEETML_URI }
prefix = if namespace && namespace[0].start_with?('xmlns:')
namespace[0].delete_prefix('xmlns:') + ':'
else
''
end
name_row = "#{prefix}row"
name_c = "#{prefix}c"
name_v = "#{prefix}v"
name_t = "#{prefix}t"
next unless node.namespace_uri == SPREADSHEETML_URI
if prefix.empty? && node.prefix
prefix = node.prefix
name_row = "#{prefix}:row"
name_c = "#{prefix}:c"
name_v = "#{prefix}:v"
name_t = "#{prefix}:t"
end

if node.name == name_row && node.node_type == opener
row = node.attributes
row['cells'] = {}
Expand Down