mirror of https://github.com/vuejs/core.git
perf: optimize makeMap
This commit is contained in:
parent
81e941da5b
commit
ae6fba9495
|
@ -9,10 +9,8 @@ export function makeMap(
|
||||||
str: string,
|
str: string,
|
||||||
expectsLowerCase?: boolean
|
expectsLowerCase?: boolean
|
||||||
): (key: string) => boolean {
|
): (key: string) => boolean {
|
||||||
const map: Record<string, boolean> = Object.create(null)
|
const set = new Set(str.split(','))
|
||||||
const list: Array<string> = str.split(',')
|
return expectsLowerCase
|
||||||
for (let i = 0; i < list.length; i++) {
|
? val => set.has(val.toLowerCase())
|
||||||
map[list[i]] = true
|
: val => set.has(val)
|
||||||
}
|
|
||||||
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue