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

Remove unused &block argument #1776

Closed

Conversation

chopraanmol1
Copy link
Contributor

Removing unused &block argument will prevent creating unnecessary proc.

Example:

Script:

xml_file = "test/files/staff.xml"
xml = Nokogiri::XML(File.read(xml_file), xml_file)
employees = xml.search("//employee")
MemoryProfiler.report{ employees.collect{|emp| emp.children.collect{|a| a.name}} }.pretty_print

Master:


Total allocated: 5280 bytes (93 objects)
Total retained:  0 bytes (0 objects)

allocated memory by class
-----------------------------------
      2600  String
      1400  Array
       960  Proc
       320  Nokogiri::XML::NodeSet

allocated objects by class
-----------------------------------
        65  String
        12  Proc
        11  Array
         5  Nokogiri::XML::NodeSet

After Changes:


Total allocated: 4320 bytes (81 objects)
Total retained:  0 bytes (0 objects)

allocated memory by class
-----------------------------------
      2600  String
      1400  Array
       320  Nokogiri::XML::NodeSet

allocated objects by class
-----------------------------------
        65  String
        11  Array
         5  Nokogiri::XML::NodeSet

Removing unused &block argument will prevent creating unnecessary proc.

Example:

Script:
	xml_file = "test/files/staff.xml"
	xml = Nokogiri::XML(File.read(xml_file), xml_file)
	employees = xml.search("//employee")
	MemoryProfiler.report{ employees.collect{|emp| emp.children.collect{|e| e.name}} }.pretty_print

Master:

Total allocated: 5280 bytes (93 objects)
Total retained:  0 bytes (0 objects)

allocated memory by class
-----------------------------------
      2600  String
      1400  Array
       960  Proc
       320  Nokogiri::XML::NodeSet

allocated objects by class
-----------------------------------
        65  String
        12  Proc
        11  Array
         5  Nokogiri::XML::NodeSet


After Changes:

Total allocated: 4320 bytes (81 objects)
Total retained:  0 bytes (0 objects)

allocated memory by class
-----------------------------------
      2600  String
      1400  Array
       320  Nokogiri::XML::NodeSet

allocated objects by class
-----------------------------------
        65  String
        11  Array
         5  Nokogiri::XML::NodeSet
@chopraanmol1 chopraanmol1 changed the title Remove unused &block Remove unused &block argument Jul 5, 2018
@flavorjones
Copy link
Member

@chopraanmol1 Thank you so much for submitting this! I'll take care of the merge conflicts, and will get this into an upcoming release, likely v1.10.x.

@flavorjones flavorjones added this to the v1.10.x patch releases milestone Jan 6, 2019
@flavorjones
Copy link
Member

I've merged this manually! Thanks again, I've credited you in the CHANGELOG.

@chopraanmol1 chopraanmol1 deleted the remove_unused_block branch January 11, 2019 10:55
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.

None yet

2 participants