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,
|
||||
expectsLowerCase?: boolean
|
||||
): (key: string) => boolean {
|
||||
const map: Record<string, boolean> = Object.create(null)
|
||||
const list: Array<string> = str.split(',')
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
map[list[i]] = true
|
||||
}
|
||||
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]
|
||||
const set = new Set(str.split(','))
|
||||
return expectsLowerCase
|
||||
? val => set.has(val.toLowerCase())
|
||||
: val => set.has(val)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue