Re: [PATCH 1/2] log-tree: simplify digit_in_number

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

 



Ralf Thielow wrote:

> +++ b/log-tree.c
> @@ -254,12 +254,10 @@ static void append_signoff(struct strbuf *sb, const char *signoff)
>  
>  static unsigned int digits_in_number(unsigned int number)
>  {
> -	unsigned int i = 10, result = 1;
> -	while (i <= number) {
> -		i *= 10;
> -		result++;
> -	}
> -	return result;
> +	int digits = 0;
> +	while (number /= 10) 
> +		digits++;
> +	return digits++;

I think you mean "return ++digits;".

But other questions come to mind first:

 - What is the motivation?  How did this come up and what does your change
   improve?

 - Why rewrite this in one patch, only to rewrite it again?

Hope that helps,
Jonathan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]