Alex Bennee wrote:
> On Wed, 2005-04-06 at 11:30 +0200, Christian Biere wrote:
> > I haven't looked at the surrounding code...but - if possible - propagate
> > the current time from a higher call because time() is "somewhat" heavy

> I can't see any easy way to reduce the cost. For live tickets this will
> occur every 10s or so. On startup the cost will be higher, but if the
> user has that many tickets in their cache....

Well, OK. However, you probably want to limit the number of tickets to hold
in the cache then for the future.
 
> > > + bitzi_cache_file = fopen(path, "w");

> Added error check. Its implicity closed on exit. If your that concerned
> I can add a bitzi_close() function to do a proper cleanup.

Ah, OK. I missed that it's kept open the whole time. That's not like
we handle other files but I guess it's OK for the moment at least.

> > > +         while (fgets(tmp, sizeof(tmp), old_data))
> > > +         {
> > Keep in mind that the line might be truncated now.
> Should only be truncated on an EOL, so shouldn't break the <?xml test

Not really. There are at least 2 special cases concerning fgets() to
look out for: 1. The line is longer than the buffer, 2. the line
may contain NUL bytes. In the latter case, you'd probably just consider
the file corrupt. The other case can be "ignored" as well if you're sure
that you never create longer lines.
 
> > > +                 if (strncmp(tmp,"<?xml",5)==0)

> Well I've made it cleaner (a la http_headers). Is it really worth
> creating a library function just to hide strncmp's?

It's not about hiding something but if it's actually about checking
for a fixed prefix, it's more to the point, in my opinion. It should
make things a tidbit more readable and counting characters is really
ugly anyway.
 
> This patch is not currently well tested as Bitzi seems to be generating
> wierd XML tickets at the moment.

Do you want it in CVS or is it still a preview?

-- 
Christian

Attachment: pgpTueQw270Fz.pgp
Description: PGP signature

Reply via email to