From c8eba5a389a85b6077d48a38eabec132a999b2d6 Mon Sep 17 00:00:00 2001 From: Fan Pei Date: Thu, 4 Jan 2024 13:32:42 +0900 Subject: [PATCH] perf: use `Set.has` instead of `Array.includes` (#140) --- packages/devtools-kit/src/core/component/state/constants.ts | 4 ++-- packages/devtools-kit/src/core/component/state/process.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/devtools-kit/src/core/component/state/constants.ts b/packages/devtools-kit/src/core/component/state/constants.ts index f0f24c3be..f76eec41e 100644 --- a/packages/devtools-kit/src/core/component/state/constants.ts +++ b/packages/devtools-kit/src/core/component/state/constants.ts @@ -1,4 +1,4 @@ -export const vueBuiltins = [ +export const vueBuiltins = new Set([ 'nextTick', 'defineComponent', 'defineAsyncComponent', @@ -50,7 +50,7 @@ export const vueBuiltins = [ 'resolveDirective', 'withDirectives', 'withModifiers', -] +]) export const symbolRE = /^\[native Symbol Symbol\((.*)\)\]$/ export const rawTypeRE = /^\[object (\w+)]$/ diff --git a/packages/devtools-kit/src/core/component/state/process.ts b/packages/devtools-kit/src/core/component/state/process.ts index 4cc5f8c80..63b04a54d 100644 --- a/packages/devtools-kit/src/core/component/state/process.ts +++ b/packages/devtools-kit/src/core/component/state/process.ts @@ -131,7 +131,7 @@ function getStateTypeAndName(info: ReturnType) { function processSetupState(instance: VueAppInstance) { const raw = instance.devtoolsRawSetupState || {} return Object.keys(instance.setupState) - .filter(key => !vueBuiltins.includes(key) && key.split(/(?=[A-Z])/)[0] !== 'use') + .filter(key => !vueBuiltins.has(key) && key.split(/(?=[A-Z])/)[0] !== 'use') .map((key) => { const value = returnError(() => toRaw(instance.setupState[key])) as unknown as { render: Function