Skip to content

Commit 82c1c99

Browse files
committed
Optimize code by 16.5%
1 parent 29d8e81 commit 82c1c99

File tree

6 files changed

+147
-103
lines changed

6 files changed

+147
-103
lines changed

src/Evaluator/Evaluator.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--[[
22
Name: Evaluator.lua
33
Author: ByteXenon [Luna Gilbert]
4-
Date: 2024-02-21
4+
Date: 2024-05-21
55
--]]
66

77
--* Imports *--

src/Helpers/Helpers.lua

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
--[[
22
Name: Helpers.lua
33
Author: ByteXenon [Luna Gilbert]
4-
Date: 2024-01-10
4+
Date: 2024-05-21
55
--]]
66

77
--* Imports *--
8+
local char = string.char
9+
local match = string.match
810
local gmatch = string.gmatch
911
local insert = table.insert
1012

@@ -35,4 +37,18 @@ function Helpers.stringToTable(string)
3537
return table
3638
end
3739

40+
--- Converts a pattern to a character lookup table.
41+
-- @param <String> pattern The pattern to convert.
42+
-- @return <Table> table The table of characters.
43+
function Helpers.createPatternLookupTable(pattern)
44+
local lookupTable = {}
45+
for i = 0, 255 do
46+
local character = char(i)
47+
if match(character, pattern) then
48+
lookupTable[character] = true
49+
end
50+
end
51+
return lookupTable
52+
end
53+
3854
return Helpers

0 commit comments

Comments
 (0)