]> git.eshelyaron.com Git - emacs.git/commit
editorconfig-core-handle.el: Reduce allocation in parser
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 18 Jun 2024 22:16:10 +0000 (18:16 -0400)
committerEshel Yaron <me@eshelyaron.com>
Fri, 21 Jun 2024 19:00:23 +0000 (21:00 +0200)
commit57706ea1f15ab1576090956975df141229aad17b
treebefcf51495d0e2a8052febc02b62bb41b7b1d2bc
parent59fa0d2b8c0843cdc0125f152c51f418c2f44820
editorconfig-core-handle.el: Reduce allocation in parser

* lisp/editorconfig-core-handle.el (editorconfig-core-handle--parse-file):
Return a `editorconfig-core-handle`.
(editorconfig-core-handle): Simplify accordingly.
(editorconfig-core-handle--parse-file): Push `sections` and `props`
in reverse order to avoid the usual O(N²) complexity.
Work directly in the buffer instead of extracting "lines" from it, so
as to reduce memory allocation.  Similarly, use careful regexps so we
can extract trimmed strings without an explicit trim operation.
Use `eobp`.
(editorconfig-core-handle--string-trim): Delete function, not used any more.

(cherry picked from commit 833b500a0e788a95c189a5b2bfa95494a3a7429e)
lisp/editorconfig-core-handle.el