From 0dc60fb75603fbf09d3072ef3c0046e7535f0858 Mon Sep 17 00:00:00 2001 From: Dvel Date: Thu, 20 Apr 2023 09:38:32 +0800 Subject: [PATCH] #220 --- rime.lua | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/rime.lua b/rime.lua index e2b9a9a..1696edd 100644 --- a/rime.lua +++ b/rime.lua @@ -10,17 +10,6 @@ function date_translator(input, seg, env) local week = config:get_string(env.name_space .. "/week") or "xq" local datetime = config:get_string(env.name_space .. "/datetime") or "dt" local timestamp = config:get_string(env.name_space .. "/timestamp") or "ts" - -- if input == "s" then - -- local cand = Candidate("date", seg.start, seg._end, ("%.f"):format(collectgarbage('count')), "") - -- cand.quality = 100 - -- yield(cand) - -- end - -- if input == "xxx" then - -- collectgarbage() - -- local cand = Candidate("date", seg.start, seg._end, "collectgarbage()", "") - -- cand.quality = 100 - -- yield(cand) - -- end -- 日期 if (input == date) then local cand = Candidate("date", seg.start, seg._end, os.date("%Y-%m-%d"), "") @@ -172,10 +161,10 @@ function long_word_filter(input, env) local i = 1 for cand in input:iter() do - -- 找齐了或者 l 太大了,就不找了 - if (s == count) or (#l > 100) then - break - end + -- 找齐了或者 l 太大了,就不找了 + if (s == count) or (#l > 50) then + break + end local leng = utf8.len(cand.text) if (firstWordLength < 1 or i < idx) then i = i + 1 @@ -191,9 +180,15 @@ function long_word_filter(input, env) for _, cand in ipairs(l) do yield(cand) end - for cand in input:iter() do - yield(cand) - end + for cand in input:iter() do + yield(cand) + end + + -- 如果内存大于 5000 的话,GC 一次,最小间隔 60s + -- if collectgarbage('count') > 5000 and (os.time() - last_gc_time) > 60 then + -- collectgarbage("collect") + -- last_gc_time = os.time() + -- end end ------------------------------------------------------------- -- 降低部分英语单词在候选项的位置