Re: [PATCH 12/19] remote-curl: avoid assigning string constant to non-const variable

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

 



Patrick Steinhardt <ps@xxxxxx> writes:

>  		} else if (skip_prefix(buf.buf, "option ", &arg)) {
> +			const char *value = strchr(arg, ' ');
> +			size_t arglen;
>  			int result;
>  
> +			if (value) {
> +				arglen = value - arg;
> +				value++;
> +			} else {
> +				arglen = strlen(arg);
>  				value = "true";
> +			}

There is a micro optimization opportunity here.

	const char *value = strchrnul(arg, ' ');
	size_t arglen = value - arg;

	if (*value)
		value++; /* skip over SP */
	else
		value = "true";

But other than that, very cleanly done.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux