From f9a73777e7e367821d889d3fff2b9f4350f49553 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 29 May 2024 10:23:46 +0800 Subject: [PATCH] Perf over function --- src/components/status.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/status.jsx b/src/components/status.jsx index ac891ad7..4c782b01 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -161,6 +161,11 @@ const SIZE_CLASS = { }; const detectLang = mem((text) => { + // Ref: https://github.com/komodojp/tinyld/blob/develop/docs/benchmark.md + // 500 should be enough for now, also the default max chars for Mastodon + if (text?.length > 500) { + return null; + } const langs = detectAll(text); const lang = langs[0]; if (lang?.lang && lang?.accuracy > 0.5) {