Skip to content

Use @inline to replace @lazy where possible #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion asconfig.empty.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"options": {
"runtime": "stub",
"textFile": "build/empty.wat",
"debug": true
"debug": true,
"optimizeLevel": 3
},
"entries": ["assembly/__tests__/empty.ts"]
}
1 change: 0 additions & 1 deletion assembly/__tests__/empty.wat
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(module
(memory $0 0)
(table $0 1 funcref)
(export "memory" (memory $0))
)
14 changes: 7 additions & 7 deletions assembly/constants.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion assembly/duration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PlainDateTime } from "./plaindatetime";
import { TimeComponent } from "./enums";

// @ts-ignore
@lazy
@inline
const NULL = i32.MAX_VALUE;

export class DurationLike {
Expand Down
8 changes: 4 additions & 4 deletions assembly/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ 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
@lazy
let __null = false;
@inline
const __null = false;

// value objects - used in place of object literals
export class YMD {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this work, you may ask.

pre and post hooks can be added to any npm script by just prefixing it with pre or post.
https://docs.npmjs.com/cli/v7/using-npm/scripts#pre--post-scripts

"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",
Expand Down