Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Alex Riesen <raa.lkml@...>
Cc: Lukas <lukass@...>, Git Mailing List <git@...>, Junio C Hamano <junkio@...>
Date: Tuesday, September 4, 2007 - 7:01 pm

On mar, sep 04, 2007 at 09:38:57 +0000, Alex Riesen wrote:
linfo.c
 I'd

  Well I honestly believe that putting strbufs/bstrings in mailinfo.c
adds no value. I was going to give it a try to see how strbufs
performed, but it's just useless.

  The main problem mailinfo has, it's according to Junio that it may
sometimes truncate some things in buffers at 1000 octets, without dying
loudly. That is bad.

  _but_ there is no point in using arbitrary long string buffers to
parse a mail. Remember, a mail goes through SMTP, and SMTP is supposed
to limit its lines at 512 characters (without use of extensions at
least). Not to mention that an email address cannot be more than 64+256
chars long (or sth around that). So using variable lengths buffers is
just a waste.

  string buffers are not really (IMHO) supposed to help in parsing
tasks, and when you need to do some serious parsing, either do it by
hand or use lex, but nothing in between makes sense to me.

  OTOH, string buffers can be used in many places where git has (at
least 4 different to my current count, growing) many implementations of
always slightly different kind of buffers. I've some more patches
pending here than the one I already sent, and well, here is the
diffstat:

$ git diff --stat origin/master.. ^strbuf*
 archive-tar.c         |   67 ++++++++++++---------------------------------=
---
 builtin-apply.c       |   29 ++++++---------------
 builtin-blame.c       |   34 ++++++++-----------------
 builtin-commit-tree.c |   59 +++++++++---------------------------------
 builtin-rerere.c      |   53 +++++++++++---------------------------
 cache-tree.c          |   57 ++++++++++++++---------------------------
 diff.c                |   25 ++++++------------
 fast-import.c         |   38 +++++++++++----------------
 mktree.c              |   26 ++++++-------------
 9 files changed, 116 insertions(+), 272 deletions(-)

  I mean, there is not even a need to show the diff to understand what
the gain is. And that was possible, because strbufs are straightforward,
and gives you the kind of controls git needs (tweaking how memory will
be allocated to avoid reallocs is part of the answer).


  A French author once said: =E2=80=9CIl semble que la perfection soit atte=
inte
non quand il n'y a plus rien =C3=A0 ajouter, mais quand il n'y a plus rien =
=C3=A0
retrancher.=E2=80=9D -- Antoine de St =C3=89xup=C3=A9ry[0]. IMHO git will n=
ever need any
of the bstring splits, streaming functions, tokenization or whatever,
and supporting those has necessarily led the bstring library to make
some choices that may not fit git needs. I don't really like reinventing
the wheel, but OTOH buffers and strings are often of the critical path,
and having a nice fitting buffer API is priceless.


  [0] Perfection is achieved, not when there is nothing more to add, but
      when there is nothing left to take away.
--=20
=C2=B7O=C2=B7  Pierre Habouzit
=C2=B7=C2=B7O                                                madcoder@debia=
n.org
OOO                                                http://www.madism.org
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Fri Sep 7, 6:21 am)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Fri Sep 7, 6:56 am)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Fri Sep 7, 6:26 am)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Fri Sep 7, 6:28 am)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Johannes Schindelin, (Thu Sep 6, 8:08 am)
Re: [RFC] Convert builin-mailinfo.c to use The Better String..., Pierre Habouzit, (Tue Sep 4, 7:01 pm)