Skip to content

Commit

Permalink
perf: use Set.has instead of Array.includes (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
Azurewarth0920 authored Jan 4, 2024
1 parent 977ee3c commit c8eba5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/devtools-kit/src/core/component/state/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const vueBuiltins = [
export const vueBuiltins = new Set([
'nextTick',
'defineComponent',
'defineAsyncComponent',
Expand Down Expand Up @@ -50,7 +50,7 @@ export const vueBuiltins = [
'resolveDirective',
'withDirectives',
'withModifiers',
]
])

export const symbolRE = /^\[native Symbol Symbol\((.*)\)\]$/
export const rawTypeRE = /^\[object (\w+)]$/
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-kit/src/core/component/state/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function getStateTypeAndName(info: ReturnType<typeof getSetupStateType>) {
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
Expand Down

0 comments on commit c8eba5a

Please sign in to comment.