Re: [RFC PATCH 1/2] Btrfs: add precomputed log2()

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

 



On Mon, Jun 26, 2017 at 12:02:09AM +0300, Timofey Titovets wrote:
> +int log2_lshift16(long long unsigned lshift16)
> +{
> +	if (lshift16 < 1)
> +		return -136;
> +	if (lshift16 < 2)
> +		return -123;
> +	if (lshift16 < 3)
> +		return -117;
> +	if (lshift16 < 4)
> +		return -113;
> +	if (lshift16 < 5)
> +		return -110;
> +	if (lshift16 < 6)

Here you have 110 comparisons and branches.  It'd be much better to reorder
those into a sort of a binary search.

-- 
⢀⣴⠾⠻⢶⣦⠀ 
⣾⠁⢠⠒⠀⣿⡁ A dumb species has no way to open a tuna can.
⢿⡄⠘⠷⠚⠋⠀ A smart species invents a can opener.
⠈⠳⣄⠀⠀⠀⠀ A master species delegates.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux