From 4b703c07c1291603a390a494c0df464629821c3d Mon Sep 17 00:00:00 2001 From: frto027 <602706150@qq.com> Date: Wed, 19 Jan 2022 21:32:53 +0800 Subject: [PATCH] use string.rep in generatePlaceholderString --- eid_api.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index 4ffcacb8..0dfbcf51 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -530,11 +530,7 @@ end -- Generates a string with the defined pixel-length using a custom 1px wide character -- This will only work for this specific custom font function EID:generatePlaceholderString(length) - local placeholder = "" - for i = 1, length do - placeholder = placeholder .. "¤" - end - return placeholder + return string.rep("¤", length) end -- Returns the inlineIcon object of a given Iconstring @@ -795,11 +791,11 @@ function EID:fitTextToWidth(str, textboxWidth, breakUtf8Chars) local word = sub(str, word_begin_index, cursor) local colorFiltered = EID:filterColorMarkup(word, EID:getTextColor()) - local filteredWord = "" + local filteredWord = {} for _, filtered in ipairs(colorFiltered) do - filteredWord = filteredWord .. filtered[1] + table.insert(filteredWord, filtered[1]) end - local strFiltered, spriteTable = EID:filterIconMarkup(filteredWord, 0, 0) + local strFiltered, spriteTable = EID:filterIconMarkup(table.concat(filteredWord), 0, 0) local wordLength = EID:getStrWidth(strFiltered) if curLength + wordLength <= textboxWidth or curLength < 12 then