feat(tl): generate switches instead of OR expressions
switches are WAY faster.
This commit is contained in:
parent
f19fdf76b8
commit
6879ae945a
1 changed files with 5 additions and 3 deletions
|
@ -226,9 +226,11 @@ const writeSingleSchemaEntry = (type) => {
|
|||
js.write(`${jsPrefix}isAny${camelToPascal(
|
||||
union.type
|
||||
)} = function (obj) {
|
||||
return ${union.subtypes
|
||||
.map((typ) => `obj._ === '${prefix_}${typ}'`)
|
||||
.join(' || ')};
|
||||
switch (obj._) {
|
||||
${union.subtypes
|
||||
.map((typ) => `case '${prefix_}${typ}':`).join('')}return true;
|
||||
}
|
||||
return false;
|
||||
};`)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue