-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
c39150e
to
2c63e43
Compare
2c63e43
to
c2922c2
Compare
c2922c2
to
91a025f
Compare
Why close @j8r? |
101a615
to
39d8861
Compare
One review left before becoming mergeable |
84a5a4a
to
6174d60
Compare
src/ini.cr
Outdated
@@ -52,8 +52,7 @@ class INI | |||
end | |||
end | |||
|
|||
ini.delete_if { |_, v| v.empty? } | |||
ini | |||
ini[""].empty? ? ini.reject("") : ini |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
23fc875
to
475aceb
Compare
475aceb
to
bd4d261
Compare
Parsing an INI file with only
[section]
returns now{"section" => {}}
instead of an empty Hash.