invariant icon indicating copy to clipboard operation
invariant copied to clipboard

Use spread operator to get the arguments more safely

Open cyan33 opened this issue 6 years ago • 3 comments

Hi @zertosh,

Don't know if this repo is still under maintainence. Anyway, I've noticed that it uses a, b, c, d, e as placeholders for the %s to be replaced. This could be easily improved by using the spread operator. It enhances the readability and is more safe in case the length of the placeholders is more than 5.

Would love to listen to your thought on this. 😄

cyan33 avatar Mar 06 '18 05:03 cyan33

I'd be concerned that the spread operator in the function signature would result in the argument spreading being executed on every call, not just failing ones. How about old-school use of arguments when the condition fails?

adamdicarlo avatar Jul 18 '18 22:07 adamdicarlo

@adamdicarlo i don't see how is that a problem

Sceat avatar May 08 '20 12:05 Sceat

@Sceat Yeah, me neither, now (that was a while ago). At the time I was thinking it could be a performance issue. With eliminating these kinds of checks in production builds, it's no issue at all (maybe that wasn't standard when I commented? :thinking: ) ... even for debug builds I don't think it's nearly inefficient enough to be a problem.

adamdicarlo avatar May 09 '20 05:05 adamdicarlo