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

Keep empty sections when parsing INI #5718

Merged
merged 1 commit into from Apr 9, 2018

Conversation

j8r
Copy link
Contributor

@j8r j8r commented Feb 13, 2018

Parsing an INI file with only [section] returns now {"section" => {}} instead of an empty Hash.

spec/std/ini_spec.cr Outdated Show resolved Hide resolved
spec/std/ini_spec.cr Outdated Show resolved Hide resolved
src/ini.cr Outdated
raise ParseException.new("unterminated section", lineno, line.size)
elsif end_idx != line.size - 1
raise ParseException.new("data after section", lineno, end_idx + 1)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Why has this section been changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might be more efficient?

Copy link
Contributor

Choose a reason for hiding this comment

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

No it's exactly the same

@j8r j8r closed this Feb 13, 2018
@j8r j8r reopened this Feb 13, 2018
@j8r j8r force-pushed the keep_empty_ini_sections branch 2 times, most recently from c39150e to 2c63e43 Compare February 13, 2018 18:28
src/ini.cr Outdated Show resolved Hide resolved
@j8r j8r closed this Feb 28, 2018
@bew
Copy link
Contributor

bew commented Feb 28, 2018

Why close @j8r?

@j8r j8r reopened this Feb 28, 2018
@j8r j8r force-pushed the keep_empty_ini_sections branch 2 times, most recently from 101a615 to 39d8861 Compare March 1, 2018 11:38
@j8r
Copy link
Contributor Author

j8r commented Apr 6, 2018

One review left before becoming mergeable

src/ini.cr Outdated Show resolved Hide resolved
@j8r j8r force-pushed the keep_empty_ini_sections branch 2 times, most recently from 84a5a4a to 6174d60 Compare April 7, 2018 14:02
src/ini.cr Outdated
@@ -52,8 +52,7 @@ class INI
end
end

ini.delete_if { |_, v| v.empty? }
ini
ini[""].empty? ? ini.reject("") : ini
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't be clearer to rewrite it as below?

ini.delete("") if ini[""].empty?
ini

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've thinked so before, but is it better performance wise to do return ini.reject("") instead of ini.delete(""); ini ?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, reject will have to create a copy, whereas delete can just modify the existing one.

@j8r j8r force-pushed the keep_empty_ini_sections branch 2 times, most recently from 23fc875 to 475aceb Compare April 7, 2018 22:28
spec/std/ini_spec.cr Outdated Show resolved Hide resolved
@j8r j8r force-pushed the keep_empty_ini_sections branch from 475aceb to bd4d261 Compare April 8, 2018 00:18
@RX14 RX14 added this to the Next milestone Apr 9, 2018
@RX14 RX14 merged commit b1c30c2 into crystal-lang:master Apr 9, 2018
@j8r j8r deleted the keep_empty_ini_sections branch April 14, 2018 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants