diff options
author | Vendicated <vendicated@riseup.net> | 2022-11-07 21:05:33 +0100 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-11-07 21:05:33 +0100 |
commit | 0af4579204fcbabbce239b2fbd4dfef0df58774d (patch) | |
tree | 4e39a537bdd5bfd50ac11ba80bd39288b0bf061b /src/webpack | |
parent | 851d07f31a117cf342d09c0886ae0b38ae0c9050 (diff) | |
download | Vencord-0af4579204fcbabbce239b2fbd4dfef0df58774d.tar.gz Vencord-0af4579204fcbabbce239b2fbd4dfef0df58774d.tar.bz2 Vencord-0af4579204fcbabbce239b2fbd4dfef0df58774d.zip |
Add tracer, fix MessageActions slow startup
Diffstat (limited to 'src/webpack')
-rw-r--r-- | src/webpack/webpack.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 1a3e15d..b78afd0 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -18,6 +18,7 @@ import type { WebpackInstance } from "discord-types/other"; +import { traceFunction } from "../debug/Tracer"; import Logger from "../utils/logger"; import { proxyLazy } from "../utils/proxyLazy"; @@ -74,7 +75,7 @@ if (IS_DEV && !IS_WEB) { }, 0); } -export function find(filter: FilterFn, getDefault = true, isWaitFor = false) { +export const find = traceFunction("find", function find(filter: FilterFn, getDefault = true, isWaitFor = false) { if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got " + typeof filter); @@ -109,7 +110,7 @@ export function find(filter: FilterFn, getDefault = true, isWaitFor = false) { } return null; -} +}); export function findAll(filter: FilterFn, getDefault = true) { if (typeof filter !== "function") @@ -222,7 +223,7 @@ export function bulk(...filterFns: FilterFn[]) { * @param code Code * @returns number or null */ -export function findModuleId(code: string) { +export const findModuleId = traceFunction("findModuleId", function findModuleId(code: string) { for (const id in wreq.m) { if (wreq.m[id].toString().includes(code)) { return Number(id); @@ -239,7 +240,7 @@ export function findModuleId(code: string) { } return null; -} +}); /** * Finds a mangled module by the provided code "code" (must be unique and can be anywhere in the module) @@ -253,7 +254,7 @@ export function findModuleId(code: string) { * closeModal: filters.byCode("key==") * }) */ -export function mapMangledModule<S extends string>(code: string, mappers: Record<S, FilterFn>): Record<S, any> { +export const mapMangledModule = traceFunction("mapMangledModule", function mapMangledModule<S extends string>(code: string, mappers: Record<S, FilterFn>): Record<S, any> { const exports = {} as Record<S, any>; const id = findModuleId(code); @@ -273,7 +274,7 @@ export function mapMangledModule<S extends string>(code: string, mappers: Record } } return exports; -} +}); /** * Same as {@link mapMangledModule} but lazy |