From d595ef716a851da88864ae33f1eb503818af64f5 Mon Sep 17 00:00:00 2001 From: Auto PR Bot Date: Sun, 7 Jun 2026 06:09:42 +0800 Subject: [PATCH] Improve code quality: auto-pr/type_annotations-1780783781 --- .../TypeScriptSources/ObjectLiterals.ts | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/SharpTS.Benchmarks/TypeScriptSources/ObjectLiterals.ts b/SharpTS.Benchmarks/TypeScriptSources/ObjectLiterals.ts index 787ea292..45a09acc 100644 --- a/SharpTS.Benchmarks/TypeScriptSources/ObjectLiterals.ts +++ b/SharpTS.Benchmarks/TypeScriptSources/ObjectLiterals.ts @@ -1,35 +1,35 @@ -// Object-literal allocation benchmarks. Measures cost of `{ ... }` in -// hot loops — common in real code (return values, options bags, AST-like -// tree builders). Each iteration constructs a fresh Dictionary and stores boxed values. - -function smallLiteralLoop(n: number): number { - let total: number = 0; - for (let i: number = 0; i < n; i++) { - const o = { x: i, y: i + 1 }; - total = total + (o.x as number); - } - return total; -} - -function mediumLiteralLoop(n: number): number { - let total: number = 0; - for (let i: number = 0; i < n; i++) { - const o = { a: i, b: i + 1, c: i + 2, d: i + 3, e: i + 4 }; - total = total + (o.a as number); - } - return total; -} - -function nestedLiteralLoop(n: number): number { - let total: number = 0; - for (let i: number = 0; i < n; i++) { - const o = { - point: { x: i, y: i + 1 }, - label: "pt" - }; - const inner = o.point as any; - total = total + (inner.x as number); - } - return total; -} +// Object-literal allocation benchmarks. Measures cost of `{ ... }` in +// hot loops — common in real code (return values, options bags, AST-like +// tree builders). Each iteration constructs a fresh Dictionary and stores boxed values. + +function smallLiteralLoop(n: number): number { + let total: number = 0; + for (let i: number = 0; i < n; i++) { + const o = { x: i, y: i + 1 }; + total = total + (o.x as number); + } + return total; +} + +function mediumLiteralLoop(n: number): number { + let total: number = 0; + for (let i: number = 0; i < n; i++) { + const o = { a: i, b: i + 1, c: i + 2, d: i + 3, e: i + 4 }; + total = total + (o.a as number); + } + return total; +} + +function nestedLiteralLoop(n: number): number { + let total: number = 0; + for (let i: number = 0; i < n; i++) { + const o = { + point: { x: i, y: i + 1 }, + label: "pt" + }; + const inner = o.point; + total = total + inner.x; + } + return total; +}