Re: [PATCH v2 06/37] diff: rename 'this' variables
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 14, 2018, 21:19 UTC
- Message-ID
- <xmqqh8qjmfq5.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180214185959.221906-7-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
Show 5 quoted lines
> Rename C++ keyword in order to bring the codebase closer to being able > to be compiled with a C++ compiler. > > Signed-off-by: Brandon Williams <bmwill@google.com> > ---
The patch is not as bad as renaming "this" and leaving "that" behind but in the original, "this" and "this_dir" were treated as a pair. "this" was a score for a single item in the directory, "this_dir" was the sum of these scores for entries in the directory.
So renaming "this" to "sum" and leaving "this_dir" as-is looks like readability regression. Perhaps replace "this_dir" with "sum_changes" and "this" with "changes" instead, or something like that?
Show 35 quoted lines
> diff.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index 0a9a0cdf1..d682d0d1f 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -2601,7 +2601,7 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
> while (dir->nr) {
> struct dirstat_file *f = dir->files;
> int namelen = strlen(f->name);
> - unsigned long this;
> + unsigned long sum;
> char *slash;
>
> if (namelen < baselen)
> @@ -2611,15 +2611,15 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
> slash = strchr(f->name + baselen, '/');
> if (slash) {
> int newbaselen = slash + 1 - f->name;
> - this = gather_dirstat(opt, dir, changed, f->name, newbaselen);
> + sum = gather_dirstat(opt, dir, changed, f->name, newbaselen);
> sources++;
> } else {
> - this = f->changed;
> + sum = f->changed;
> dir->files++;
> dir->nr--;
> sources += 2;
> }
> - this_dir += this;
> + this_dir += sum;
> }
>
> /*