Re: printTable API (was: Show INHERIT in \du) - Mailing list pgsql-patches

From Brendan Jurd
Subject Re: printTable API (was: Show INHERIT in \du)
Date
Msg-id 37ed240d0804170148l6a4951bah292480af233729a3@mail.gmail.com
Whole thread Raw
In response to Re: printTable API (was: Show INHERIT in \du)  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-patches
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Apr 17, 2008 at 9:53 AM, Alvaro Herrera  wrote:
>
>  Well, consider that there are going to be 1 or 2 entries in the arrays
>  in most cases anyway :-)  Well, as far as footers go anyway ... I just
>  realized that in all other cases it will certainly be the wrong thing to
>  do :-)  Still, perhaps a integer count is better?
>

I oscillated between using an integer and a pointer for ->header and
- ->cell while I was writing the code.  In the end I went with pointer
simply because it makes the iterations nicer looking, and there's a
symmetry in having the "first item" and "last item" pointers be the
same type.

If there's some technical reason that integers would be better, I'll
all ears, but from an aesthetic/code readability perspective I like
the pointer.

> > Brendan Jurd escribió:
>  > What is it about the extra fields that makes you unhappy?
>
>  I don't know if "unnecessarity" is a word, but I hope you get what I
>  mean :-)

Since the footers list is usually pretty short, you could make an
argument for dropping the "last footer" pointer and just iterating
through the list to find the last element every time you want to do
something with footers.  And to do that, you'd have to declare a
temporary pointer inside the AddFooter function anyway, so you're not
getting rid of the pointer so much as making it slightly more
transient.

All that having been said, C isn't my native language.  So if the
pointer is indeed wasteful I'm happy to cede to the wisdom of more
experienced C coders.

Cheers,
BJ
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFIBw7m5YBsbHkuyV0RAv4IAJ0cKrziZpNWkVV7LxFhlV/V5L0pJACfUtZ+
cVbcjL1e89j21JDZJBVdBqw=
=Nzr+
-----END PGP SIGNATURE-----

pgsql-patches by date:

Previous
From: Bryce Nesbitt
Date:
Subject: Re: Proposed patch - psql wraps at window width
Next
From: Alvaro Herrera
Date:
Subject: Re: Proposed patch - psql wraps at window width