[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should [[ -v 1 ]] be supported?

From: G. Branden Robinson
Subject: Re: Should [[ -v 1 ]] be supported?
Date: Thu, 27 Dec 2018 20:36:25 -0500
User-agent: NeoMutt/20180716

At 2018-12-27T18:39:26-0600, Peng Yu wrote:
> What I meant in my original email is that I want something for testing
> if there is a command line argument (one or more, the exact number
> does not matter). $# gives more than that info, because it tells not
> only whether is any command line argument, but also how many. This
> could lead to slower performance if the goal is to just test if there
> is an argument.

You should look into how integer comparisons are done in hardware.

For instance, comparison and subtraction operations are often comparable
(or even identical) in cycle count because they both perform a
subtraction "under the hood".  You need to be programming in assembly
language to influence execution at such depths.

See, e.g.,


As others have noted, if you are worried about marginal performance
impacts this small, margin you are probably writing in the wrong
language, or distracting yourself with tiny details when you do not even
know the cyclomatic complexity of your code or the big-O classification
of your algorithms.

Attack those problems first, and see what you discover.


Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]