mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <>
To: Jeff King <>
Cc: "SZEDER Gábor" <>,
	"Rene Scharfe" <>,
	"Stefan Beller" <>,
	"Lars Schneider" <>,
Subject: Re: [PATCH] Use MOVE_ARRAY
Date: Mon, 22 Jan 2018 15:26:59 -0800	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <> (Jeff King's message of "Mon, 22 Jan 2018 17:44:10 -0500")

Jeff King <> writes:

> Most of these are "shift part of the array". I wonder if it would make
> sense to encapsulate that pattern in a helper, like:
>   #define SHIFT_ARRAY(a, nr, pos, slots) \
>     MOVE_ARRAY(a + pos + slots, a + pos, nr - pos - slots)
>   ...
>   SHIFT_ARRAY(it->down, it->subtree_nr, pos, 1);

Exactly my thought when I was queuing it, but I was wondering about
this more from "can we use the higher level abstraction for reducing
errors?" point of view.  If we are shifting an array by 3 slots to
the right, we should at least have enough slots allocated to hold
them (i.e. a->nr - a->alloc must be 3 or more).  But after realizing
that the level these macros operate at is still a bit too low to do
something like that, I quickly lost interest ;-)

> I'm not sure if that's more readable because it describes a higher-level
> operation, or if it's less because it adds yet another non-standard
> helper for the reader to learn.

Yeah, conflicting goals.  It indeed is easier to see what is going
on when reading the code, once the reader gets used to them.


  reply	other threads:[~2018-01-22 23:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 17:10 [PATCH] describe: use strbuf_add_unique_abbrev() for adding short hashes René Scharfe
2018-01-16 13:48 ` Derrick Stolee
2018-01-16 17:11 ` SZEDER Gábor
2018-01-18 21:40   ` René Scharfe
2018-01-18 22:40     ` SZEDER Gábor
2018-01-18 23:02       ` Lars Schneider
2018-01-19 17:53       ` René Scharfe
2018-01-22 17:50         ` [PATCH] Use MOVE_ARRAY SZEDER Gábor
2018-01-22 22:44           ` Jeff King
2018-01-22 23:26             ` Junio C Hamano [this message]
2018-01-22 23:34               ` Jeff King

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:

  List information:

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

  git send-email \ \ \ \ \ \ \ \ \

* 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.
Code repositories for project(s) associated with this public inbox

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 read-only IMAP folder(s) and NNTP newsgroup(s).