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

Eliminate some o n2 #351

Merged
merged 7 commits into from
Jul 28, 2024
Merged

Eliminate some o n2 #351

merged 7 commits into from
Jul 28, 2024

Conversation

monnier
Copy link
Collaborator

@monnier monnier commented Jul 19, 2024

This tries to improve a bit the code of editorconfig-fnmatch and editorconfig-core-handle--parse-file.

monnier added 4 commits July 19, 2024 10:42
* editorconfig-core-handle.el: Change copyright to the FSF since all
the contributors have signed the corresponding paperwork.
(editorconfig-core-handle--parse-file): Directly return
a `editorconfig-core-handle`; parse the buffer directly rather than
matching on strings extracted from the buffer; avoid O(N²) complexity
by constructing the lists in reverse and using `nreverse` at the end.
(editorconfig-core-handle): Simplify accordingly.
(editorconfig-core-handle--string-trim): Delete function, not used any more.
* editorconfig-fnmatch.el: Change copyright to the FSF since all
the contributors have signed the corresponding paperwork.
(editorconfig-fnmatch-p): Remove autoload cookie since all users do
`require` anyway.
(editorconfig-fnmatch--do-translate): Push in reverse order and `reverse`
at the end to avoid the usual O(N²) complexity.
* editorconfig-fnmatch.el (editorconfig-fnmatch--do-translate):
Consolidate the `push`s outside of `cl-case`.  Use `regexp-opt`.
This fixes the failures I see in

    155: semicolon_or_hash_in_property
    156: backslashed_semicolon_or_hash_in_property
    164: min_supported_key_length
    165: min_supported_value_length

* editorconfig-core-handle.el (editorconfig-core-handle--parse-file):
Bump limits beyond the spec's minimum.

* editorconfig-core.el (editorconfig-core-get-properties): Sort the
result so it doesn't depend on arbitrary hash-table implementation choices.
@monnier
Copy link
Collaborator Author

monnier commented Jul 20, 2024

There are some failures in the core-tests, but that's because we need to update the reference to the editorconfig-core-test.git: the patch obeys the new comment rules.

monnier added 3 commits July 21, 2024 10:21
…into eliminate-some-O-n2

* editorconfig-core-handle.el (editorconfig-core-handle--parse-file):
Remove the limits altogether.
@monnier
Copy link
Collaborator Author

monnier commented Jul 21, 2024

I have now included an update to core-test as well as merged the corresponding fix-4-core-test-failures branch.

@10sr
Copy link
Member

10sr commented Jul 28, 2024

Thank you so much!

@10sr 10sr merged commit fbd078a into master Jul 28, 2024
12 checks passed
@10sr 10sr deleted the eliminate-some-O-n2 branch July 28, 2024 17:14
@10sr 10sr mentioned this pull request Jul 29, 2024
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