Skip to content
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

Limit object allocations #115

Merged
merged 2 commits into from
May 3, 2023
Merged

Limit object allocations #115

merged 2 commits into from
May 3, 2023

Conversation

ThomasSevestre
Copy link
Contributor

This is an attempt to fix #111

Comment on lines 107 to 108
if prefix.empty? && node.namespaces.any?
namespace = node.namespaces.detect{|_key, uri| uri == SPREADSHEETML_URI }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case that prefix has not been set and there are namespaces that are not SPREADSHEETML_URI, the code is still going to repeatedly set the name_* variables.

Perhaps this would make sense?

Suggested change
if prefix.empty? && node.namespaces.any?
namespace = node.namespaces.detect{|_key, uri| uri == SPREADSHEETML_URI }
if prefix.empty? && (namespace = node.namespaces.detect{|_key, uri| uri == SPREADSHEETML_URI }).present?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that suggestion leaves some quirks around the if namespace && ... check below...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case that prefix has not been set and there are namespaces that are not SPREADSHEETML_URI, the code is still going to repeatedly set the name_* variables.

Perhaps this would make sense?

I don't know if this is a common usecase.

If it is, we need to track prefix changes in order to handle new prefix and prefix reset :

if prefix != old_prefix
  name_row = "#{prefix}row"
  name_c = "#{prefix}c"
  name_v = "#{prefix}v"
  name_t = "#{prefix}t"
end

@pythonicrubyist
Copy link
Owner

Will test and merge tonight. Thanks

@pythonicrubyist pythonicrubyist merged commit 9462de1 into pythonicrubyist:master May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Excessive Memory Allocation Loading Worksheet Rows
3 participants