D
Deno

help

About performance

R!Roricchi 2.0『藤田の妻』11/14/2022
if a function takes only one paramater and i pass unnecessary additional parameters would it affect the performance of just the function part of the code?
function echo(sentence) {
console.log(sentence)
}

echo('hello')

echo('hello', 'bye', 'okay')
function echo(sentence) {
console.log(sentence)
}

echo('hello')

echo('hello', 'bye', 'okay')
this is what im caonfused abt i have a object, every value is a function that takes the same parameter payload except only one value that takes an additional second parameter args i want to know which way from these two would perform better
const handler = {
READY: (payload, args) => {},
GUILD_CREATE: (payload) => {},
MESSAGE_CREATE: (payload) => {}.
// ...about 30 more
}


// should i do this
handler[eventName](payload, args)

// or this
if (eventName === 'READY') handler[eventName](payload, args)
else handler[eventName](payload)
const handler = {
READY: (payload, args) => {},
GUILD_CREATE: (payload) => {},
MESSAGE_CREATE: (payload) => {}.
// ...about 30 more
}


// should i do this
handler[eventName](payload, args)

// or this
if (eventName === 'READY') handler[eventName](payload, args)
else handler[eventName](payload)
sorry for not using typescript types, i asked the same question in a javascript server, i copy pasted here too
AAapoAlas11/14/2022
IIRC It does have some effect, yes, but nothing particularly horrible. I expect the latter might be better simply because less parameters means less polymorphism.
UUUnknown User11/14/2022
2 Messages Not Public
Sign In & Join Server To View
R!Roricchi 2.0『藤田の妻』11/15/2022
i see tyvm!

Looking for more? Join the community!

Recommended Posts
deno_core Extension with Global AccessIs there a way to make a Deno Extension be accessed by `Extension.op()` instead of `Deno.core.ops.opHow to stop reading from a ReadableStream?```js let user for await (const data of readable) { if (data.user.id === 'user-id') { user = Deno.inspect, how to log class instances with gettersim trying to log a class instance that has getters in it, with `Deno.inspect` ```ts Deno.inspect(clhow to ssr preact (without fresh)i tried with preact render to string but it wouldnt ship any jsSynchronous read single line from Deno.stdinHi, how would I go about reading a single line from `Deno.stdin` synchronously?Closing a websocket server in a unit testHello, I'm an author of [rpc lib](https://github.com/deno-libs/rpc) and I'm currently writing unit tHow to cancel or abort .pipeTo()?I prefer not asking, but after I found (what I consider) an MDN easter egg, I realized this is probais it possible to change how tsx bundles to js?So I’m wondering if it’s possible to get Deno to convert ```jsx <div class="test">Potato</div> ``` tcan't load external modules when run as child process with Deno.spawnChildHi! This is really weird, but I'm trying to run deno scripts under another deno process with Deno.spFile line operationsHello, How to perform the following file manipulations in Deno ? - Read the nth line - Remove the FFI how to pass (or get) 128-bit bigints to (or from) Rust functions?I want to pass bigints from Deno and get i128 or u128 in Rust. Do I have to use typed arrays for thaUnable to view logs to debug edge function for Deno Fresh + Deno DeployThanks for making Deno, and Deploy, and Fresh. I'm a huge fan. I'm building a feature to allow userTypeScript enumsSo enums are objects with all keys being values and values being keys. Most of the time when using eHow to get complete Deno RAM usage?Do we use `Deno.memoryUsage().rss` or should it be `rss+heapUsed+external`?