Skip to content
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

perf: lazy bootstrap options - first pass #21164

Merged
merged 10 commits into from
Nov 13, 2023
Prev Previous commit
Next Next commit
rename to memoizeLazy
  • Loading branch information
littledivy committed Nov 13, 2023
commit e709fb5c8370a5368831004cc8d23979dbcacd76
8 changes: 4 additions & 4 deletions runtime/js/98_global_scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Navigator {

const navigator = webidl.createBranded(Navigator);

function makeLazy(f) {
function memoizeLazy(f) {
let v_ = null;
return () => {
if (v_ === null) {
Expand All @@ -168,9 +168,9 @@ function makeLazy(f) {
};
}

const numCpus = makeLazy(() => ops.op_bootstrap_numcpus());
const userAgent = makeLazy(() => ops.op_bootstrap_user_agent());
const language = makeLazy(() => ops.op_bootstrap_language());
const numCpus = memoizeLazy(() => ops.op_bootstrap_numcpus());
const userAgent = memoizeLazy(() => ops.op_bootstrap_user_agent());
const language = memoizeLazy(() => ops.op_bootstrap_language());

ObjectDefineProperties(Navigator.prototype, {
hardwareConcurrency: {
Expand Down
8 changes: 4 additions & 4 deletions runtime/js/99_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import * as webidl from "ext:deno_webidl/00_webidl.js";
import DOMException from "ext:deno_web/01_dom_exception.js";
import {
mainRuntimeGlobalProperties,
makeLazy,
memoizeLazy,
unstableWindowOrWorkerGlobalScope,
windowOrWorkerGlobalScope,
workerRuntimeGlobalProperties,
Expand Down Expand Up @@ -238,9 +238,9 @@ function opMainModule() {
return ops.op_main_module();
}

const opArgs = makeLazy(() => ops.op_bootstrap_args());
const opPid = makeLazy(() => ops.op_bootstrap_pid());
const opPpid = makeLazy(() => ops.op_ppid());
const opArgs = memoizeLazy(() => ops.op_bootstrap_args());
const opPid = memoizeLazy(() => ops.op_bootstrap_pid());
const opPpid = memoizeLazy(() => ops.op_ppid());
setNoColorFn(() => ops.op_bootstrap_no_color());

function formatException(error) {
Expand Down
Loading