emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode 5f3af11 1/5: Added some (thread-yield) comman


From: Christian Johansson
Subject: [elpa] externals/phps-mode 5f3af11 1/5: Added some (thread-yield) commands in lexer to improve responsivity in multi-threaded mode
Date: Tue, 2 Nov 2021 12:05:33 -0400 (EDT)

branch: externals/phps-mode
commit 5f3af11443e064bc6527217f3df2177a2c7b0f27
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Added some (thread-yield) commands in lexer to improve responsivity in 
multi-threaded mode
---
 phps-mode-lex-analyzer.el | 38 +++++++++++++++++++++-----------------
 phps-mode-lexer.el        | 17 +++++++++++------
 2 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 1a6b793..ac5ea39 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -388,16 +388,17 @@
      buffer-name
 
      (lambda()
-       (let* ((lex-result
+       (let ((lex-result
                (phps-mode-lex-analyzer--lex-string
-                buffer-contents))
-              (processed-result
-               (phps-mode-lex-analyzer--process-tokens-in-string
-                (nth 0 lex-result)
                 buffer-contents)))
-         (list
-          lex-result
-          processed-result)))
+         (thread-yield)
+         (let ((processed-result
+                (phps-mode-lex-analyzer--process-tokens-in-string
+                 (nth 0 lex-result)
+                 buffer-contents)))
+           (list
+            lex-result
+            processed-result))))
 
      (lambda(result)
        (when (get-buffer buffer-name)
@@ -422,6 +423,7 @@
              (setq phps-mode-lex-analyzer--lines-indent (nth 1 
processed-result))
              (setq phps-mode-lex-analyzer--bookkeeping (nth 2 
processed-result))
              (phps-mode-lex-analyzer--reset-imenu)
+             (thread-yield)
 
              ;; Apply syntax color on tokens
              (dolist (token phps-mode-lex-analyzer--tokens)
@@ -514,7 +516,7 @@
      buffer-name
 
      (lambda()
-       (let* ((lex-result
+       (let ((lex-result
               (phps-mode-lex-analyzer--lex-string
                buffer-contents
                incremental-start-new-buffer
@@ -525,14 +527,15 @@
                incremental-heredoc-label
                incremental-heredoc-label-stack
                incremental-nest-location-stack
-               head-tokens))
-             (processed-result
-              (phps-mode-lex-analyzer--process-tokens-in-string
-               (nth 0 lex-result)
-               buffer-contents)))
-         (list
-          lex-result
-          processed-result)))
+               head-tokens)))
+         (thread-yield)
+         (let ((processed-result
+                (phps-mode-lex-analyzer--process-tokens-in-string
+                 (nth 0 lex-result)
+                 buffer-contents)))
+           (list
+            lex-result
+            processed-result))))
 
      (lambda(result)
        (when (get-buffer buffer-name)
@@ -562,6 +565,7 @@
              (setq phps-mode-lex-analyzer--lines-indent (nth 1 
processed-result))
              (setq phps-mode-lex-analyzer--bookkeeping (nth 2 
processed-result))
              (phps-mode-lex-analyzer--reset-imenu)
+             (thread-yield)
 
              ;; Apply syntax color on tokens
              (dolist (token phps-mode-lex-analyzer--tokens)
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index ba1d661..80d1ee0 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -493,11 +493,11 @@
         (buffer-substring-no-properties
          start
          end))
-     (message
-      "\nRunning lexer from point %s, state: %s, lookahead: '%s'.."
-      old-start
-      phps-mode-lexer--state
-      lookahead)))
+       (message
+        "\nRunning lexer from point %s, state: %s, lookahead: '%s'.."
+        old-start
+        phps-mode-lexer--state
+        lookahead)))
     (phps-mode-lexer--reset-match-data)
     
     (let ((SHEBANG (equal phps-mode-lexer--state 'SHEBANG))
@@ -848,6 +848,8 @@
           phps-mode-lexer--tabs-and-spaces ")")))
        (phps-mode-lexer--return-token 'T_UNSET_CAST))
 
+      (thread-yield)
+
       (phps-mode-lexer--match-macro
        (and ST_IN_SCRIPTING (looking-at "eval"))
        (phps-mode-lexer--return-token-with-indent 'T_EVAL))
@@ -1151,6 +1153,8 @@
              (phps-mode-lexer--return-token 'T_DNUMBER)
            (phps-mode-lexer--return-token 'T_LNUMBER))))
 
+      (thread-yield)
+
       (phps-mode-lexer--match-macro
        (and ST_VAR_OFFSET (looking-at "\\([0]\\|[1-9][0-9]*\\)"))
        (phps-mode-lexer--return-token 'T_NUM_STRING))
@@ -1827,7 +1831,8 @@
                (message "Restarting lexer"))
               (phps-mode-lexer--re2c)))
         (phps-mode-debug-message
-         (message "Found nothing at %d" (point)))))))
+         (message "Found nothing at %d" (point))))))
+  (thread-yield))
 
 
 (provide 'phps-mode-lexer)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]