git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] merge: use string_list_split() in add_strategies()

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 10, 2016, 12:31 UTC
Message-ID
<alpine.DEB.2.20.1608101431300.4924@virtualbox>
In-Reply-To
<xmqqeg5zf8mh.fsf@gitster.mtv.corp.google.com>
Hi Junio,
On Mon, 8 Aug 2016, Junio C Hamano wrote:
Show 31 quoted lines
> 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

Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 6 in “merge: use string_list_split() in add_strategies()”
  1. merge: use string_list_split() in add_strategies()René Scharfe, Aug 5, 2016
  2. Johannes SchindelinAug 8, 2016
  3. Junio C HamanoAug 8, 2016
  4. Junio C HamanoAug 8, 2016
  5. Johannes SchindelinAug 10, 2016
  6. Junio C HamanoAug 10, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.