mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 10:00:13 -06:00
hasSameKeys: Simplify and optimize for identical maps (#21763)
This commit is contained in:
parent
79dde93068
commit
28c4871c99
@ -41,15 +41,9 @@ namespace ts {
|
||||
program: Program;
|
||||
}
|
||||
|
||||
function hasSameKeys<T, U>(map1: ReadonlyMap<T> | undefined, map2: ReadonlyMap<U> | undefined) {
|
||||
if (map1 === undefined) {
|
||||
return map2 === undefined;
|
||||
}
|
||||
if (map2 === undefined) {
|
||||
return map1 === undefined;
|
||||
}
|
||||
function hasSameKeys<T, U>(map1: ReadonlyMap<T> | undefined, map2: ReadonlyMap<U> | undefined): boolean {
|
||||
// Has same size and every key is present in both maps
|
||||
return map1.size === map2.size && !forEachKey(map1, key => !map2.has(key));
|
||||
return map1 as ReadonlyMap<T | U> === map2 || map1 && map2 && map1.size === map2.size && !forEachKey(map1, key => !map2.has(key));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user