From 8e57449577dec9d8f7abe018e43dafccb7214823 Mon Sep 17 00:00:00 2001 From: Sebastian Speitel Date: Thu, 6 May 2021 19:01:55 +0200 Subject: [PATCH 1/4] test: fix empty test by running an optimized build --- asconfig.empty.json | 3 ++- assembly/__tests__/empty.wat | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/asconfig.empty.json b/asconfig.empty.json index fce89aa..f364278 100644 --- a/asconfig.empty.json +++ b/asconfig.empty.json @@ -2,7 +2,8 @@ "options": { "runtime": "stub", "textFile": "build/empty.wat", - "debug": true + "debug": true, + "optimizeLevel": 3 }, "entries": ["assembly/__tests__/empty.ts"] } diff --git a/assembly/__tests__/empty.wat b/assembly/__tests__/empty.wat index bffe105..23da386 100644 --- a/assembly/__tests__/empty.wat +++ b/assembly/__tests__/empty.wat @@ -1,5 +1,4 @@ (module (memory $0 0) - (table $0 1 funcref) (export "memory" (memory $0)) ) From 979c507c3909dcda791a65ce731bd8b72c5db4dc Mon Sep 17 00:00:00 2001 From: Sebastian Speitel Date: Thu, 6 May 2021 19:07:14 +0200 Subject: [PATCH 2/4] refactor: replace @lazy with @inline where possible --- assembly/constants.ts | 14 +++++++------- assembly/duration.ts | 2 +- assembly/utils.ts | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/assembly/constants.ts b/assembly/constants.ts index 3aca06d..0e03e5f 100644 --- a/assembly/constants.ts +++ b/assembly/constants.ts @@ -1,27 +1,27 @@ // @ts-ignore -@lazy +@inline export const MILLIS_PER_DAY = 1_000 * 60 * 60 * 24; // @ts-ignore -@lazy +@inline export const MILLIS_PER_HOUR = 1_000 * 60 * 60; // @ts-ignore -@lazy +@inline export const MILLIS_PER_MINUTE = 1_000 * 60; // @ts-ignore -@lazy +@inline export const MILLIS_PER_SECOND = 1_000; // @ts-ignore -@lazy +@inline export const MICROS_PER_SECOND = 1_000_000; // @ts-ignore -@lazy +@inline export const NANOS_PER_SECOND = 1_000_000_000; // @ts-ignore -@lazy +@inline export const NANOS_PER_DAY = i64(MILLIS_PER_DAY) * 1_000_000; diff --git a/assembly/duration.ts b/assembly/duration.ts index c246993..926bdd8 100644 --- a/assembly/duration.ts +++ b/assembly/duration.ts @@ -6,7 +6,7 @@ import { PlainDateTime } from "./plaindatetime"; import { TimeComponent } from "./enums"; // @ts-ignore -@lazy +@inline const NULL = i32.MAX_VALUE; export class DurationLike { diff --git a/assembly/utils.ts b/assembly/utils.ts index bfdfdc8..6755d53 100644 --- a/assembly/utils.ts +++ b/assembly/utils.ts @@ -18,11 +18,11 @@ import { PlainDate } from "./plaindate"; import { PlainDateTime } from "./plaindatetime"; // @ts-ignore -@lazy +@inline const YEAR_MIN = -271821; // @ts-ignore -@lazy +@inline const YEAR_MAX = 275760; // @ts-ignore From f83bdeb6813a141a3b44df1ee08b2896779934f4 Mon Sep 17 00:00:00 2001 From: Sebastian Speitel Date: Thu, 6 May 2021 19:09:19 +0200 Subject: [PATCH 3/4] test: ensure empty build before empty test --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8d4abed..8c17e9a 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "ascMain": "assembly/index.ts", "types": "assembly/index.ts", "scripts": { - "pretest": "npm run asbuild:empty", "test": "asp --verbose --nologo && npm run test:empty", + "pretest:empty": "npm run asbuild:empty", "test:empty": "diff build/empty.wat assembly/__tests__/empty.wat", "test:ci": "asp --summary && npm run test:empty", "asbuild:untouched": "asc assembly/index.ts --target debug", From 294fa88e4e979380564182679e805565c5030827 Mon Sep 17 00:00:00 2001 From: Sebastian Speitel Date: Thu, 6 May 2021 19:24:14 +0200 Subject: [PATCH 4/4] refactor: inline __null --- assembly/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assembly/utils.ts b/assembly/utils.ts index 6755d53..303577f 100644 --- a/assembly/utils.ts +++ b/assembly/utils.ts @@ -26,8 +26,8 @@ const YEAR_MIN = -271821; const YEAR_MAX = 275760; // @ts-ignore -@lazy -let __null = false; +@inline +const __null = false; // value objects - used in place of object literals export class YMD {