git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 3/3] pretty=format: Avoid some expensive calculations when not needed
Date: Thu, 8 Nov 2007 00:14:51 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0711080012510.4362@racer.site> (raw)
In-Reply-To: <47324810.2010507@lsrfire.ath.cx>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1690 bytes --]

Hi,

On Thu, 8 Nov 2007, René Scharfe wrote:

> Johannes Schindelin schrieb:
> 
> > On Wed, 7 Nov 2007, René Scharfe wrote:
> > 
> >> By the way, the more intrusive surgery required when using 
> >> strbuf_expand() leads to even faster operation.  Here my measurements 
> >> of most of Paul's test cases (best of three runs):
> >>
> >> [...]
> > 
> > impressive timings.  Although I wonder where the time comes from, as 
> > the other substitutions should not be _that_ expensive.
> 
> I haven't run a profiler, but my two suspects are the malloc()s and 
> free()s done by interp_set_entry(), and the fact that 
> format_commit_message() calls interpolate() twice.

But of course! *slapsthehead*

> > In any case, your approach seems much more sensible, now that we have 
> > strbuf.
> > 
> >> diff --git a/strbuf.h b/strbuf.h
> >> index cd7f295..95071d5 100644
> >> --- a/strbuf.h
> >> +++ b/strbuf.h
> >> @@ -102,6 +102,9 @@ static inline void strbuf_addbuf(struct strbuf *sb, struct strbuf *sb2) {
> >>  	strbuf_add(sb, sb2->buf, sb2->len);
> >>  }
> >>  
> >> +typedef void (*expand_fn_t) (struct strbuf *sb, const char *placeholder, void *context);
> >> +extern void strbuf_expand(struct strbuf *sb, const char *fmt, const char **placeholders, expand_fn_t fn, void *context);
> > 
> > I wonder if it would even faster (but maybe not half as readable) if 
> > expand_fd_t got the placeholder_index instead of the placeholder.
> 
> I doubt it.  All this would save is one pointer dereference per
> placeholder.  I haven't tried and measured this, though.

My thinko.  I thought that you save one prefixcmp(), but strbuf_expand() 
offloads that to the callback function.

Thanks,
Dscho

  reply	other threads:[~2007-11-08  0:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-04 19:14 [PATCH 0/3] Make user formatted commit listing less expensive Johannes Schindelin
2007-11-04 19:15 ` [PATCH 1/3] Split off the pretty print stuff into its own file Johannes Schindelin
2007-11-05 21:16   ` Junio C Hamano
2007-11-04 19:15 ` [PATCH 2/3] interpolate.[ch]: Add a function to find which interpolations are active Johannes Schindelin
2007-11-04 19:15 ` [PATCH 3/3] pretty=format: Avoid some expensive calculations when not needed Johannes Schindelin
2007-11-05 19:51   ` Junio C Hamano
2007-11-05 20:21     ` René Scharfe
2007-11-05 20:25       ` Jon Loeliger
2007-11-05 23:53       ` Johannes Schindelin
2007-11-06  1:06       ` Junio C Hamano
2007-11-06 22:31         ` René Scharfe
2007-11-06 23:17           ` René Scharfe
2007-11-06 23:45             ` Johannes Schindelin
2007-11-07 23:19               ` René Scharfe
2007-11-08  0:14                 ` Johannes Schindelin [this message]
2007-11-07  0:11             ` Pierre Habouzit
2007-11-07  0:14               ` Pierre Habouzit
2007-11-07 23:21                 ` René Scharfe
2007-11-07 23:31                   ` Pierre Habouzit
2007-11-07 20:43             ` Junio C Hamano
2007-11-09  0:49               ` René Scharfe
2007-11-06 23:36           ` Johannes Schindelin
2007-11-06 23:38             ` [PATCH 1/2] interpolate.[ch]: Add a function to find which interpolations are active Johannes Schindelin
2007-11-06 23:38             ` [PATCH 2/2] pretty=format: Avoid some expensive calculations when not needed 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=Pine.LNX.4.64.0711080012510.4362@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rene.scharfe@lsrfire.ath.cx \
    /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).