Improved speed by removing sha384 in ScriptCache

This commit is contained in:
phoriah
2025-10-28 16:37:22 +02:00
parent 91f340ff6b
commit 13307033e8

View File

@@ -52,7 +52,7 @@ do
-- getcon = 'string.find(...,"get",nil,true) and (string.find(...,"conn",nil,true) or string.find(...,"sig",nil,true)) and string.sub(...,#(...))=="s"',
getnilinstances = 'string.find(...,"nil",nil,true) and string.find(...,"get",nil,true) and string.sub(...,#...) == "s"', -- ! Could match some unwanted stuff
getscriptbytecode = 'string.find(...,"get",nil,true) and string.find(...,"bytecode",nil,true)', -- or string.find(...,"dump",nil,true) and string.find(...,"string",nil,true) due to Fluxus (dumpstring returns a function)
hash = 'local a={...}local b=a[1]local function c(a,b)return string.find(a,b,nil,true)end;return c(b,"hash")and c(string.lower(tostring(a[2])),"crypt")',
-- hash = 'local a={...}local b=a[1]local function c(a,b)return string.find(a,b,nil,true)end;return c(b,"hash")and c(string.lower(tostring(a[2])),"crypt")',
protectgui = 'string.find(...,"protect",nil,true) and string.find(...,"ui",nil,true) and not string.find(...,"un",nil,true)',
setthreadidentity = 'string.find(...,"identity",nil,true) and string.find(...,"set",nil,true)',
}, true, 10)
@@ -72,7 +72,6 @@ local writefile = writefile
local getscriptbytecode = global_container.getscriptbytecode -- * A lot of assumptions are made based on whether this function is defined or not. So in certain edge cases, like if the executor defines "decompile" or "getscripthash" function yet doesn't define this function there might be loss of functionality of the saveinstance. Although that would be very rare and weird
local base64encode = global_container.base64encode
local sha384
local service = setmetatable({}, {
__index = function(self, serviceName)
@@ -189,46 +188,9 @@ do -- * Load Region of Déjà Vu
end
assert(base64encode, "base64encode not found")
end
do
local hash = global_container.hash
if hash then
sha384 = function(data)
return hash(data, "sha384")
end
end
local filename = "RequireOnlineModule"
-- Credits @boatbomber
local hashlib_sha384
pcall(function()
hashlib_sha384 = loadstring(
game:HttpGet("https://raw.githubusercontent.com/luau/SomeHub/main/" .. filename .. ".luau", true),
filename
)()(4544052033).sha384
end)
-- * Tests if sha384 exists then benchmark it
if hashlib_sha384 then
if sha384 then
sha384 = benchmark(sha384, hashlib_sha384, test_str)
else
sha384 = hashlib_sha384
end
end
assert(sha384, "sha384 hash function not found")
end
end
-- local custom_decompiler
-- if getscriptbytecode then
-- end
local SharedStrings = {}
local SharedString_identifiers = setmetatable({
identifier = 1e15, -- 1 quadrillion, up to 9.(9) quadrillion, in theory this shouldn't ever run out and be enough for all sharedstrings ever imaginable
@@ -2295,17 +2257,19 @@ local function synsaveinstance(CustomOptions, CustomOptions2)
ldecompile = function(script)
-- local name = scr.ClassName .. scr.Name
local hashed_bytecode
local bytecode
if ScriptCache then
local s, bytecode = getbytecode(script)
local s
s, bytecode = getbytecode(script)
local cached
if s then
if not bytecode or bytecode == "" then
return "-- The Script is Empty"
end
hashed_bytecode = sha384(bytecode)
cached = ldeccache[hashed_bytecode]
cached = ldeccache[bytecode]
else
bytecode = nil
end
if cached then
@@ -2335,8 +2299,8 @@ local function synsaveinstance(CustomOptions, CustomOptions2)
output = "--[[ Failed to decompile. Reason:\n" .. (result or "") .. "\n]]"
end
if ScriptCache and hashed_bytecode then -- TODO there might(?) be an edgecase where it manages to decompile (built-in) even though getscriptbytecode failed, and the output won't get cached
ldeccache[hashed_bytecode] = output -- ? Should we cache even if it timed out?
if ScriptCache and bytecode then -- TODO there might(?) be an edgecase where it manages to decompile (built-in) even though getscriptbytecode failed, and the output won't get cached
ldeccache[bytecode] = output -- ? Should we cache even if it timed out?
if __DEBUG_MODE then
__DEBUG_MODE("Cached", script:GetFullName())
end