Skip to content

Rewrite parser more readable, little faster #8

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 2 commits into
base: master
Choose a base branch
from

Conversation

unix1
Copy link
Contributor

@unix1 unix1 commented Mar 29, 2014

@benoitc let me know if you are open to this kind of parser rewrite. Some notes:

  • marginal performance improvement, around 10%
  • more readable (I think, unless you don't like regex)
  • couldn't get multiline values to work in existing implementation, so I left it out (I can add it if needed)
  • passes all current tests
  • possible further speed improvements with compiled regex

Please let me know your thoughts.

@unix1
Copy link
Contributor Author

unix1 commented Apr 3, 2014

@benoitc thumbs up/down - making things better, or uninteresting? Please let me know when you get a chance.

@benoitc
Copy link
Owner

benoitc commented Apr 24, 2014

@unix1 sorry I missed this change.... will have a look later in the day.

@unix1
Copy link
Contributor Author

unix1 commented May 1, 2014

@benoitc, any luck? Feedback? I'm all ears.

@unix1
Copy link
Contributor Author

unix1 commented Oct 7, 2014

@benoitc ping?

@benoitc
Copy link
Owner

benoitc commented Jun 23, 2015

I completely forgot that change... Sorry for that ... I will look at it now.

@benoitc
Copy link
Owner

benoitc commented Nov 6, 2015

more than one year later... Sorry for that... Just if you remember, can you tell me what you meant by couldn't get multiline values to work in existing implementation, so I left it out (I can add it if needed)? Is this something missing in current master ?

@benoitc
Copy link
Owner

benoitc commented Nov 7, 2015

@unix1 i guess i see the point. I tested your implementation and it mostly worked. See comments. I know it's a little late to ask, but in case of what was your idea to add support for multilines values?

@@ -535,65 +534,36 @@ parse_ini_file(ConfName, IniFile) ->
Msg = list_to_binary(io_lib:format(Fmt, [IniFilename])),
throw({startup_error, Msg})
end,
{match, Sections} = parse_ini_bin_to_sections(IniBin),
Copy link
Owner

Choose a reason for hiding this comment

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

the case where there are no sections in the file should be handled here. It's useful when you need to pass a local file that will contains the updates.

@unix1
Copy link
Contributor Author

unix1 commented Nov 10, 2015

@benoitc thanks for looking and providing feedback. I'll probably have time to look at this this weekend.

As for multiline values, I remember I couldn't find a standard way of doing it (people do it their own ways when they think they need it, and current master didn't support it) - that's why I didn't put it in. I don't have a use case; unless you have one, I don't think it should be there.

In the hypothetical future where it's needed, we could say:

any config value that ends with a backslash continues on next line:

[letter]
message = Hello,\
          This is a message\
          Bye
from = Foo

or any non-config non-section non-comment non-empty line:

[letter]
message = Hello,
          This is a message
          Bye
from = Foo

But it gets ugly fast; and again, unless you have a use case, I'd keep it out for now.

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.

2 participants