[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold 8f1f182b40 307/417: perf: Speed up count matc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold 8f1f182b40 307/417: perf: Speed up count matches (#88) |
Date: |
Mon, 1 Jul 2024 10:02:47 -0400 (EDT) |
branch: elpa/treesit-fold
commit 8f1f182b40a4168352b60132bf9c9b9f8a5549c9
Author: Jen-Chieh Shen <jcs090218@gmail.com>
Commit: GitHub <noreply@github.com>
perf: Speed up count matches (#88)
* perf: Speed up count matches
* fix docstr
---
ts-fold-util.el | 6 ++++++
ts-fold.el | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/ts-fold-util.el b/ts-fold-util.el
index 7704f6bab1..d4588c769b 100644
--- a/ts-fold-util.el
+++ b/ts-fold-util.el
@@ -33,6 +33,12 @@
"Convert OBJ to string."
(format "%s" obj))
+(defun ts-fold--count-matches (pattern str)
+ "Count occurrences of PATTERN in STR.
+
+Like function `s-count-matches' but faster."
+ (max 0 (1- (length (split-string str pattern)))))
+
;;
;; (@* "Cons" )
;;
diff --git a/ts-fold.el b/ts-fold.el
index cddd2f3c9a..d35407adf7 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -450,12 +450,12 @@ in backward direction."
(while (and iter-node (not break))
(setq text (tsc-node-text iter-node)
line (car (tsc-node-start-point iter-node))
- line-range (1+ (s-count-matches "\n" text))
+ line-range (1+ (ts-fold--count-matches "\n" text))
max-line-range (max line-range last-line-range))
(if (and (ts-fold--in-range-p line (- last-line max-line-range) (+
last-line max-line-range))
(string-prefix-p prefix text))
(setq last-node iter-node last-line line
- last-line-range (1+ (s-count-matches "\n" text)))
+ last-line-range (1+ (ts-fold--count-matches "\n" text)))
(setq break t))
(setq iter-node (ts-fold--next-prev-node-skip-newline iter-node next)))
last-node))
- [nongnu] elpa/treesit-fold 68d16a9bc9 166/417: Rename to ts-fold, (continued)
- [nongnu] elpa/treesit-fold 68d16a9bc9 166/417: Rename to ts-fold, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d556beb204 172/417: Merge pull request #4 from rynffoll/feature/add-support-evil-toggle-fold, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 52d36972ef 218/417: chore(list): sort language alphabetically (#12), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold ea554f10e7 220/417: Fix a minor typo in ts-fold-parsers.el (#14), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a7c29941c2 225/417: OCaml parser and first functions added (#21), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 1d690b8d06 267/417: feat(python): Support assignment string, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 78f0b0437f 278/417: docs(README.md): Mention Noir in TODO, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold c36f3ad85c 279/417: feat: Add Perl support (#66), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold be2b3dd211 275/417: feat: Add Elisp support (#63), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 323e252cf5 284/417: feat: Add Kotlin support (#70), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 8f1f182b40 307/417: perf: Speed up count matches (#88),
ELPA Syncer <=
- [nongnu] elpa/treesit-fold c4aaf00303 326/417: fix: Render it's own window, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 0d2b177527 381/417: fix: Update rust line comment rule, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold cc31fb573b 399/417: docs: Update line-reminder config, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6bb13a51ce 401/417: docs: Changelog, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold ef32910994 379/417: Update package desc, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2d175b74ad 375/417: chore: Expose overlay's priority, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold b8ac9a81ca 387/417: fix: Ensure return t, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 930c5cd6de 333/417: feat: Add Mermaid support, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 21bba126be 321/417: fix: Ensure refresh when window size changes, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 665e3f074c 376/417: feat: Support new LaTeX-mode, ELPA Syncer, 2024/07/01