|
| 1 | +//// [objectSpreadRepeatedNullCheckPerf.ts] |
| 2 | +interface Props { |
| 3 | + readonly a?: string |
| 4 | + readonly b?: string |
| 5 | + readonly c?: string |
| 6 | + readonly d?: string |
| 7 | + readonly e?: string |
| 8 | + readonly f?: string |
| 9 | + readonly g?: string |
| 10 | + readonly h?: string |
| 11 | + readonly i?: string |
| 12 | + readonly j?: string |
| 13 | + readonly k?: string |
| 14 | + readonly l?: string |
| 15 | + readonly m?: string |
| 16 | + readonly n?: string |
| 17 | + readonly o?: string |
| 18 | + readonly p?: string |
| 19 | + readonly q?: string |
| 20 | + readonly r?: string |
| 21 | + readonly s?: string |
| 22 | + readonly t?: string |
| 23 | + readonly u?: string |
| 24 | + readonly v?: string |
| 25 | + readonly w?: string |
| 26 | + readonly x?: string |
| 27 | + readonly y?: string |
| 28 | + readonly z?: string |
| 29 | +} |
| 30 | + |
| 31 | +function parseWithSpread(config: Record<string, number>): Props { |
| 32 | + return { |
| 33 | + ...config.a !== undefined && { a: config.a.toString() }, |
| 34 | + ...config.b !== undefined && { b: config.b.toString() }, |
| 35 | + ...config.c !== undefined && { c: config.c.toString() }, |
| 36 | + ...config.d !== undefined && { d: config.d.toString() }, |
| 37 | + ...config.e !== undefined && { e: config.e.toString() }, |
| 38 | + ...config.f !== undefined && { f: config.f.toString() }, |
| 39 | + ...config.g !== undefined && { g: config.g.toString() }, |
| 40 | + ...config.h !== undefined && { h: config.h.toString() }, |
| 41 | + ...config.i !== undefined && { i: config.i.toString() }, |
| 42 | + ...config.j !== undefined && { j: config.j.toString() }, |
| 43 | + ...config.k !== undefined && { k: config.k.toString() }, |
| 44 | + ...config.l !== undefined && { l: config.l.toString() }, |
| 45 | + ...config.m !== undefined && { m: config.m.toString() }, |
| 46 | + ...config.n !== undefined && { n: config.n.toString() }, |
| 47 | + ...config.o !== undefined && { o: config.o.toString() }, |
| 48 | + ...config.p !== undefined && { p: config.p.toString() }, |
| 49 | + ...config.q !== undefined && { q: config.q.toString() }, |
| 50 | + ...config.r !== undefined && { r: config.r.toString() }, |
| 51 | + ...config.s !== undefined && { s: config.s.toString() }, |
| 52 | + ...config.t !== undefined && { t: config.t.toString() }, |
| 53 | + ...config.u !== undefined && { u: config.u.toString() }, |
| 54 | + ...config.v !== undefined && { v: config.v.toString() }, |
| 55 | + ...config.w !== undefined && { w: config.w.toString() }, |
| 56 | + ...config.x !== undefined && { x: config.x.toString() }, |
| 57 | + ...config.y !== undefined && { y: config.y.toString() }, |
| 58 | + ...config.z !== undefined && { z: config.z.toString() } |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +parseWithSpread({ a: 1, b: 2, z: 26 }) |
| 63 | + |
| 64 | +//// [objectSpreadRepeatedNullCheckPerf.js] |
| 65 | +"use strict"; |
| 66 | +var __assign = (this && this.__assign) || function () { |
| 67 | + __assign = Object.assign || function(t) { |
| 68 | + for (var s, i = 1, n = arguments.length; i < n; i++) { |
| 69 | + s = arguments[i]; |
| 70 | + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) |
| 71 | + t[p] = s[p]; |
| 72 | + } |
| 73 | + return t; |
| 74 | + }; |
| 75 | + return __assign.apply(this, arguments); |
| 76 | +}; |
| 77 | +function parseWithSpread(config) { |
| 78 | + return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, config.a !== undefined && { a: config.a.toString() }), config.b !== undefined && { b: config.b.toString() }), config.c !== undefined && { c: config.c.toString() }), config.d !== undefined && { d: config.d.toString() }), config.e !== undefined && { e: config.e.toString() }), config.f !== undefined && { f: config.f.toString() }), config.g !== undefined && { g: config.g.toString() }), config.h !== undefined && { h: config.h.toString() }), config.i !== undefined && { i: config.i.toString() }), config.j !== undefined && { j: config.j.toString() }), config.k !== undefined && { k: config.k.toString() }), config.l !== undefined && { l: config.l.toString() }), config.m !== undefined && { m: config.m.toString() }), config.n !== undefined && { n: config.n.toString() }), config.o !== undefined && { o: config.o.toString() }), config.p !== undefined && { p: config.p.toString() }), config.q !== undefined && { q: config.q.toString() }), config.r !== undefined && { r: config.r.toString() }), config.s !== undefined && { s: config.s.toString() }), config.t !== undefined && { t: config.t.toString() }), config.u !== undefined && { u: config.u.toString() }), config.v !== undefined && { v: config.v.toString() }), config.w !== undefined && { w: config.w.toString() }), config.x !== undefined && { x: config.x.toString() }), config.y !== undefined && { y: config.y.toString() }), config.z !== undefined && { z: config.z.toString() }); |
| 79 | +} |
| 80 | +parseWithSpread({ a: 1, b: 2, z: 26 }); |
0 commit comments