git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Krzysztof Kowalczyk <kkowalczyk@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] Optimize common pattern of alloc_ref from string
Date: Sun, 11 May 2008 11:39:34 -0700	[thread overview]
Message-ID: <7vskwo3ct5.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 20080511080709.GA6971@sigill.intra.peff.net

Jeff King <peff@peff.net> writes:

> But really my main worry is that now we have _two_ functions which
> allocate refs, so if "struct ref" ever grows a new field that needs
> initializing, it has to go in two places (whereas if alloc_ref_from_str
> calls alloc_ref, it works automatically).

This is a very good point.  We really do not want a micro-optimization in
a way that hurts maintainability.

Krzysztof's patch has the new function with the duplicated allocation
implementation between the base allocator function and the existing
copy_ref() function which also has yet another duplicated allocation
implementation.  When somebody needs to modify one, it is likely to be
noticed that these three go hand-in-hand, hopefully ;-).

By the way, why isn't alloc_ref() doing xcalloc(), I have to wonder...

  reply	other threads:[~2008-05-11 18:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-10 23:26 [PATCH] Optimize common pattern of alloc_ref from string kkowalczyk
2008-05-10 23:39 ` Jeff King
2008-05-11  0:30   ` Krzysztof Kowalczyk
2008-05-11  8:07     ` Jeff King
2008-05-11 18:39       ` Junio C Hamano [this message]
2008-05-11 20:15         ` Krzysztof Kowalczyk
2008-05-11 22:02           ` Junio C Hamano
2008-05-11 15:32 ` Johannes Schindelin

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=7vskwo3ct5.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kkowalczyk@gmail.com \
    --cc=peff@peff.net \
    /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).