[quagga-dev 12150] Re: [PATCH] lib/cli: reduce strcmp in CLI hot paths

Paul Jakma paul at jakma.org
Fri Apr 17 18:02:37 BST 2015


Nice.

Just one question. The s/CMD_/CMDS_/ in the macro names seems to just be 
churn? Presumably to help catch uses while developing? If just churn, 
maybe undo it?

regards,

Paul

On Mon, 13 Apr 2015, David Lamparter wrote:

> Er, no idea how anyone could ever have thought that it would be a good
> idea to have a zillion of strcmp() calls in the CLI's active paths, just
> to compare against things like "A.B.C.D".
>
> Reduces 40k prefix list load time from 1.65s to 1.23s (1.34:1).
>
> Signed-off-by: David Lamparter <equinox at opensourcerouting.org>

> /* Some macroes */
> -#define CMD_OPTION(S)   ((S[0]) == '[')
> -#define CMD_VARIABLE(S) (((S[0]) >= 'A' && (S[0]) <= 'Z') || ((S[0]) == '<'))
> -#define CMD_VARARG(S)   ((S[0]) == '.')
> -#define CMD_RANGE(S)	((S[0] == '<'))
> -
> -#define CMD_IPV4(S)	   ((strcmp ((S), "A.B.C.D") == 0))
> -#define CMD_IPV4_PREFIX(S) ((strcmp ((S), "A.B.C.D/M") == 0))
> -#define CMD_IPV6(S)        ((strcmp ((S), "X:X::X:X") == 0))
> -#define CMD_IPV6_PREFIX(S) ((strcmp ((S), "X:X::X:X/M") == 0))
> +#define CMDS_OPTION(S)   ((S[0]) == '[')
> +#define CMDS_VARIABLE(S) (((S[0]) >= 'A' && (S[0]) <= 'Z') || ((S[0]) == '<'))
> +#define CMDS_VARARG(S)   ((S[0]) == '.')
> +#define CMDS_RANGE(S)    ((S[0] == '<'))
> +
> +#define CMDS_IPV4(S)        ((strcmp ((S), "A.B.C.D") == 0))
> +#define CMDS_IPV4_PREFIX(S) ((strcmp ((S), "A.B.C.D/M") == 0))
> +#define CMDS_IPV6(S)        ((strcmp ((S), "X:X::X:X") == 0))
> +#define CMDS_IPV6_PREFIX(S) ((strcmp ((S), "X:X::X:X/M") == 0))
>
> /* Common descriptions. */
> #define SHOW_STR "Show running system information\n"
>

-- 
Paul Jakma	paul at jakma.org	@pjakma	Key ID: 64A2FF6A
Fortune:
Isn't it conceivable to you that an intelligent person could harbor
two opposing ideas in his mind?
 		-- Adlai Stevenson, to reporters




More information about the Quagga-dev mailing list