[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 4a3a27fe54 09/35: pyim-dhashcache-put -> pyim-dhas
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 4a3a27fe54 09/35: pyim-dhashcache-put -> pyim-dhashcache--put |
Date: |
Fri, 24 Jun 2022 08:58:06 -0400 (EDT) |
branch: externals/pyim
commit 4a3a27fe548f47036b314a8719f034d920f076fa
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
pyim-dhashcache-put -> pyim-dhashcache--put
---
pyim-dhashcache.el | 100 ++++++++++++++++++++++++++--------------------------
tests/pyim-tests.el | 14 ++++----
2 files changed, 57 insertions(+), 57 deletions(-)
diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index c920bfa9d8..eb446e3d26 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -147,7 +147,7 @@
;; 词库缓存会从 icode2word 再次重建。
(pyim-dhashcache-insert-word-into-ishortcode2word word code prepend))
-(defmacro pyim-dhashcache-put (cache code &rest body)
+(defmacro pyim-dhashcache--put (cache code &rest body)
"将 BODY 的返回值保存到 CACHE 对应的 CODE 中。
注意事项:这个宏是一个指代宏,其中 orig-value 在这个宏中有特殊含
@@ -168,7 +168,7 @@
默认 WORD 放到已有词条的最后,如果 PREPEND 为 non-nil, WORD 将放
到已有词条的最前面。"
- (pyim-dhashcache-put
+ (pyim-dhashcache--put
pyim-dhashcache-icode2word code
(if prepend
`(,word ,@(remove word orig-value))
@@ -180,12 +180,12 @@
默认 WORD 放到已有词条的最后,如果 PREPEND 为 non-nil, WORD 将放
到已有词条的最前面。"
(dolist (newcode (pyim-dhashcache-get-ishortcodes code))
- (pyim-dhashcache-put
- pyim-dhashcache-ishortcode2word
- newcode
- (if prepend
- `(,word ,@(remove word orig-value))
- `(,@(remove word orig-value) ,word)))))
+ (pyim-dhashcache--put
+ pyim-dhashcache-ishortcode2word
+ newcode
+ (if prepend
+ `(,word ,@(remove word orig-value))
+ `(,@(remove word orig-value) ,word)))))
(defun pyim-dhashcache-get-ishortcodes (code)
"获取CODE 所有的简写 ishortcodes.
@@ -565,55 +565,55 @@ pyim 使用的词库文件是简单的文本文件,编码 *强制* 为 \\='utf
(pyim-dhashcache--update-iword2count-recent
word 50 pyim-dhashcache-iword2count-recent-50-words))
;; 更新总 count 表
- (pyim-dhashcache-put
- pyim-dhashcache-iword2count word
- (cond
- ((functionp wordcount-handler)
- (funcall wordcount-handler (or orig-value 0)))
- ((numberp wordcount-handler)
- wordcount-handler)
- (t (or orig-value 0))))
+ (pyim-dhashcache--put
+ pyim-dhashcache-iword2count word
+ (cond
+ ((functionp wordcount-handler)
+ (funcall wordcount-handler (or orig-value 0)))
+ ((numberp wordcount-handler)
+ wordcount-handler)
+ (t (or orig-value 0))))
;; 更新 count 日志表。
- (pyim-dhashcache-put
- pyim-dhashcache-iword2count-log word
- (let (out)
- (dolist (x pyim-dhashcache-count-types)
- (let* ((label (car x))
- (key (intern (format-time-string (plist-get (cdr x) :format))))
- (n (plist-get (cdr x) :max-save-length))
- (plist (cdr (assoc label orig-value)))
- (value (plist-get plist key))
- (output (if value
- (plist-put plist key (+ 1 value))
- (append (list key 1) plist)))
- (length (length output))
- (output (cl-subseq output 0 (min length (* 2 n)))))
- (push `(,label ,@output) out)))
- out))
+ (pyim-dhashcache--put
+ pyim-dhashcache-iword2count-log word
+ (let (out)
+ (dolist (x pyim-dhashcache-count-types)
+ (let* ((label (car x))
+ (key (intern (format-time-string (plist-get (cdr x) :format))))
+ (n (plist-get (cdr x) :max-save-length))
+ (plist (cdr (assoc label orig-value)))
+ (value (plist-get plist key))
+ (output (if value
+ (plist-put plist key (+ 1 value))
+ (append (list key 1) plist)))
+ (length (length output))
+ (output (cl-subseq output 0 (min length (* 2 n)))))
+ (push `(,label ,@output) out)))
+ out))
;; 更新优先级表
- (pyim-dhashcache-put
- pyim-dhashcache-iword2priority word
- ;; Fix warn
- (ignore orig-value)
- (pyim-dhashcache-calculate-priority
- (pyim-dhashcache-get-counts-from-log
- (gethash word pyim-dhashcache-iword2count-log)))))
+ (pyim-dhashcache--put
+ pyim-dhashcache-iword2priority word
+ ;; Fix warn
+ (ignore orig-value)
+ (pyim-dhashcache-calculate-priority
+ (pyim-dhashcache-get-counts-from-log
+ (gethash word pyim-dhashcache-iword2count-log)))))
(defun pyim-dhashcache--update-iword2count-recent (word n hash-table)
(let (words-need-remove)
- (pyim-dhashcache-put
- hash-table :all-words
- (setq orig-value (remove word orig-value))
- (push word orig-value)
- (if (<= (length orig-value) n)
- orig-value
- (setq words-need-remove (nthcdr n orig-value))
- (cl-subseq orig-value 0 n)))
+ (pyim-dhashcache--put
+ hash-table :all-words
+ (setq orig-value (remove word orig-value))
+ (push word orig-value)
+ (if (<= (length orig-value) n)
+ orig-value
+ (setq words-need-remove (nthcdr n orig-value))
+ (cl-subseq orig-value 0 n)))
(dolist (w words-need-remove)
(remhash w hash-table))
- (pyim-dhashcache-put
- hash-table word
- (+ (or orig-value 0) 1))
+ (pyim-dhashcache--put
+ hash-table word
+ (+ (or orig-value 0) 1))
hash-table))
;; ** 根据 dhashcache 信息对词条进行排序
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index ba7515be4e..1a183224c0 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -1329,16 +1329,16 @@ zuo-zuo-you-mang 作作有芒")
(should (equal (gethash "n" ishortcode2word)
'("你" "呢")))))
-(ert-deftest pyim-tests-pyim-dhashcache-put/delete ()
+(ert-deftest pyim-tests-pyim-dhashcache--put/delete ()
(let ((pyim-dcache-backend 'pyim-dhashcache)
(pyim-dhashcache-icode2word (make-hash-table :test #'equal)))
(puthash "ni-hao" '("你好" "呢耗") pyim-dhashcache-icode2word)
- (pyim-dhashcache-put
- pyim-dhashcache-icode2word "ni-hao"
- (cons "呢毫" orig-value))
- (pyim-dhashcache-put
- pyim-dhashcache-icode2word "ni-bu-hao"
- (list "你不好"))
+ (pyim-dhashcache--put
+ pyim-dhashcache-icode2word "ni-hao"
+ (cons "呢毫" orig-value))
+ (pyim-dhashcache--put
+ pyim-dhashcache-icode2word "ni-bu-hao"
+ (list "你不好"))
(should (equal (gethash "ni-hao" pyim-dhashcache-icode2word) '("呢毫" "你好"
"呢耗")))
(should (equal (gethash "ni-bu-hao" pyim-dhashcache-icode2word) '("你不好")))
(pyim-dcache-delete-word "你不好")
- [elpa] externals/pyim updated (c573694ae4 -> f073ba0fb8), ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 2e687c443b 12/35: pyim-dhashcache-async* -> pyim-dhashcache--async*, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim be487264bc 07/35: pyim-dhashcache-upgrade* -> pyim-dhashcache--upgrade*, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 80fdf32548 14/35: pyim-dhashcache-generate* -> pyim-dhashcache--generate*, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 2473b5be9b 24/35: pyim-process-candidate-position -> pyim-process--candidate-position, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 43b09cfcac 26/35: pyim-process-input-chinese-predicate-1 -> pyim-process--input-chinese-predicate-1, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 2c04245442 05/35: pyim-preview-start-point -> pyim-preview--start-point, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim fea5fe56e3 06/35: pyim-dhashcache-update* -> pyim-dhashcache--update*, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 4a3a27fe54 09/35: pyim-dhashcache-put -> pyim-dhashcache--put,
ELPA Syncer <=
- [elpa] externals/pyim 8f195d4efe 19/35: pyim-dregcache- -> pyim-dregcache--, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 93e54a0783 23/35: pyim-process-candidates-last -> pyim-process--candidates-last, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim e264cbe5f5 02/35: pyim-preview-delete-overlay -> pyim-preview--delete-overlay, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 3454118ea9 08/35: pyim-dhashcache-init* -> pyim-dhashcache--init*, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 91ffc476b8 11/35: pyim-dhashcache-get* -> pyim-dhashcache--get*, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim e5920bae41 28/35: pyim-process-auto-select -> pyim-process--auto-select, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 93b372c8f9 01/35: pyim-preview-setup-overlay -> pyim-preview--setup-overlay, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 73ee676657 04/35: pyim-preview-delete-string -> pyim-preview--delete-string, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 9a6073f5f4 17/35: pyim-dhashcache-pinyin-string< -> pyim-dhashcache--pinyin-string<, ELPA Syncer, 2022/06/24
- [elpa] externals/pyim 46eaaa937d 10/35: pyim-dhashcache-insert* -> pyim-dhashcache--insert*, ELPA Syncer, 2022/06/24