git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: "Derrick Stolee" <derrickstolee@github.com>,
	git@vger.kernel.org, "Jonathan Tan" <jonathantanmy@google.com>,
	"René Scharfe" <l.s.r@web.de>
Subject: Re: [PATCH 0/5] cleaning up read_object() family of functions
Date: Thu, 12 Jan 2023 11:53:29 -0500	[thread overview]
Message-ID: <Y8A7Cb/w0VQk6ppV@coredump.intra.peff.net> (raw)
In-Reply-To: <230112.86v8lbzpj1.gmgdl@evledraar.gmail.com>

On Thu, Jan 12, 2023 at 05:22:04PM +0100, Ævar Arnfjörð Bjarmason wrote:

> We have members like "struct strbuf"'s "buf", which always needs to be
> init'd, but never "maybe by the user", so the pattern above would work
> there.

We've discussed in the past having a strbuf that points to an existing
buffer, over which it takes ownership. Or a const string that we'd leave
behind (but not free) if we needed to grow.

In those cases you'd want to pass in a buffer to the allocator. Of
course in the case of a strbuf those initializers would probably just be
totally separate from the regular slopbuf one, just because there's not
much else in a strbuf to initialize. You don't gain much from trying to
avoid repetition.

> Anyway, I agree that it's not worth pursuing this in this case.
> 
> But I think it's a neat pattern that we might find use for sooner than
> later for something else.

I remain unconvinced. ;) Mostly just that the lines saved versus the
amount of magic and thought doesn't seem reasonable. But it's something
we can keep in mind as new opportunities show up.

-Peff

      reply	other threads:[~2023-01-12 17:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 13:48 [PATCH 0/5] cleaning up read_object() family of functions Jeff King
2023-01-07 13:48 ` [PATCH 1/5] object-file: inline calls to read_object() Jeff King
2023-01-12  9:13   ` Ævar Arnfjörð Bjarmason
2023-01-12 16:06     ` [PATCH] object-file: fix indent-with-space Jeff King
2023-01-12 16:08       ` Ævar Arnfjörð Bjarmason
2023-01-13 17:40         ` Junio C Hamano
2023-01-07 13:49 ` [PATCH 2/5] streaming: inline call to read_object_file_extended() Jeff King
2023-01-07 13:50 ` [PATCH 3/5] read_object_file_extended(): drop lookup_replace option Jeff King
2023-01-07 13:50 ` [PATCH 4/5] repo_read_object_file(): stop wrapping read_object_file_extended() Jeff King
2023-01-07 13:50 ` [PATCH 5/5] packfile: inline custom read_object() Jeff King
2023-01-12  9:01   ` Ævar Arnfjörð Bjarmason
2023-01-12 16:29     ` Jeff King
2023-01-09 15:09 ` [PATCH 0/5] cleaning up read_object() family of functions Derrick Stolee
2023-01-11 18:26   ` Jeff King
2023-01-11 20:17     ` Derrick Stolee
2023-01-11 20:30       ` Jeff King
2023-01-12  9:21     ` Ævar Arnfjörð Bjarmason
2023-01-12 16:16       ` Jeff King
2023-01-12 16:22         ` Ævar Arnfjörð Bjarmason
2023-01-12 16:53           ` Jeff King [this message]

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=Y8A7Cb/w0VQk6ppV@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.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).