git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "René Scharfe" <l.s.r@web.de>, "Git List" <git@vger.kernel.org>
Subject: Re: [PATCH] merge: use string_list_split() in add_strategies()
Date: Wed, 10 Aug 2016 14:31:34 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1608101431300.4924@virtualbox> (raw)
In-Reply-To: <xmqqeg5zf8mh.fsf@gitster.mtv.corp.google.com>

[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]

Hi Junio,

On Mon, 8 Aug 2016, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > I wonder, however, if we could somhow turn things around by
> > introducing something like
> >
> > 	split_and_do_for_each(item_p, length, string, delimiter)
> > 		... <do something with item_p and length> ...
> >
> > that both string_list_split() *and* add_strategies() could use? We
> > would then be able to avoid allocating the list and duplicating the
> > items in the latter case.
> 
> I do think such a feature may be useful if we often work on pieces of a
> string delimited by a delimiter, but if the caller does not see the
> split result, then the function with "split" is probably misnamed.
> 
> I however suspect the variant of this where "delimiter" can just be a
> single byte would not be so useful.
> 
> If the input comes from the end user, we certainly would want to allow
> "word1  word2\tword3 " as input (i.e. squishing repeated delimiters into
> one without introducing an "empty" element, allowing more than one
> delimiter characters like SP and HT, and ignoring leading or trailing
> runs of delimiter characters).
> 
> If the input is generated internally, perhaps we should rethink the
> interface between the function that wants to do the for-each-word and
> its caller; if the caller wants to pass multiple things to the callee,
> it should be able to do so without first having to stuff these multiple
> things into a single string, only to force the callee to use this helper
> to split them out into individual pieces.

All true, but I guess this type of complexity would really complexify
René's patch too much, so I am comfortable with the patch as-is.

Ciao,
Dscho

  parent reply	other threads:[~2016-08-10 19:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05 21:01 [PATCH] merge: use string_list_split() in add_strategies() René Scharfe
2016-08-08  8:39 ` Johannes Schindelin
2016-08-08 17:55   ` Junio C Hamano
2016-08-08 20:11     ` Junio C Hamano
2016-08-10 12:31     ` Johannes Schindelin [this message]
2016-08-10 16:33       ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1608101431300.4924@virtualbox \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).