git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrzej Hunt <andrzej@ahunt.org>
To: "Junio C Hamano" <gitster@pobox.com>, "René Scharfe" <l.s.r@web.de>
Cc: Andrzej Hunt via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Elijah Newren <newren@gmail.com>,
	Andrzej Hunt <ajrhunt@google.com>
Subject: Re: [PATCH] merge-ort: only do pointer arithmetic for non-empty lists
Date: Sun, 11 Apr 2021 11:14:31 +0200	[thread overview]
Message-ID: <2cac1b8b-fe53-01c0-825c-0e10edb8a320@ahunt.org> (raw)
In-Reply-To: <xmqq8s5pkav2.fsf@gitster.g>


On 11/04/2021 00:56, Junio C Hamano wrote:
> René Scharfe <l.s.r@web.de> writes:
> 
> [...] >> Reading the diff I was wondering if QSORT now gets handed uninitialized
>> values if version-nr is 0.  The answer is no -- relevant_entries is
>> initialized at declaration.  Otherwise the compiler would have probably
>> warned, but sometimes it gets confused.
>>
>> I wonder why relevant_entries is introduced at all, though.  It's not
>> referenced later.  So how about this instead?
>>
>> 	if (versions->nr)
>> 		QSORT(versions->items + offset, nr, tree_entry_order);
>>
>> The intent to sort the last versions->nr-offset entries of versions,
>> but only if it's not empty, is easier to see like this, I think.
> 
> That does make sense.  I wonder if there needs some assertion to
> ensure that "offset" does not exceed "versions.nr", though.
> 

I think so - I will add the assertion. Following the original offset 
calculations is not trivial- which seems like a good enough reason for 
the assert.

  reply	other threads:[~2021-04-11  9:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10  8:30 [PATCH] merge-ort: only do pointer arithmetic for non-empty lists Andrzej Hunt via GitGitGadget
2021-04-10 11:48 ` René Scharfe
2021-04-10 22:56   ` Junio C Hamano
2021-04-11  9:14     ` Andrzej Hunt [this message]
2021-04-11  9:12   ` Andrzej Hunt
2021-04-11 11:05 ` [PATCH v2] " Andrzej Hunt via GitGitGadget
2021-04-12 15:52   ` Elijah Newren
2021-04-12 17:39     ` Junio C Hamano
2021-04-12 17:47     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2cac1b8b-fe53-01c0-825c-0e10edb8a320@ahunt.org \
    --to=andrzej@ahunt.org \
    --cc=ajrhunt@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).