Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 07 Mar 2019 14:57:06 -0800
From:      Kirk McKusick <mckusick@mckusick.com>
To:        Alexander Leidinger <Alexander@leidinger.net>, freebsd-fs@freebsd.org
Subject:   Re: 'td' vs sys/fs/nfsserver/
Message-ID:  <201903072257.x27Mv66I067345@chez.mckusick.com>
In-Reply-To: <20190307105011.GI2492@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
Code refactoring takes (nearly) duplicate code from two or usually
more places and puts it in a single function. Code refactoring is
nearly always a useful thing to do. It increases reliability because
a bug fix in the new function corrects the problem in all the places
that the code was previously located. It also concentrates the
functionality in a single place which makes understanding easier.

Reducing the complexity of a function by removing an unneeded, unused,
or duplicate parameter can make the code more comprehensible. That is
the point that is being raised here where the 'td' parameter is to be
removed because the 'curthread()' routine can be used to get its value
where it is needed. Changes of this sort also makes understanding easier.

The tradeoff in making these changes are the number of lines of code 
that are affected. The more lines that are affected and the more files
that have changes, the higher the cost and the more developers that
are affected.

Changes that are all contained within a single file are almost always
worth the cost. Code refactoring typically provides greater benefit
than reducing the parameters to a function, so can be justified across
more lines and files.

In the case of eliminating 'td', the cost is thousands of lines of
changes in a substantial number of files in the kernel. Nearly every
developer would be affected by a change that would have just a small
benefit. IMO, the benefit is not even remotely worth the cost.

	Kirk McKusick



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903072257.x27Mv66I067345>