[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: RFC: svn_iter_* iteration drivers for common iterations

From: Karl Fogel <kfogel_at_red-bean.com>
Date: 2007-09-10 21:38:17 CEST

"Erik Huelsmann" <ehuels@gmail.com> writes:
> macro:
> #define svn_iter_break return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL)
>
>
> How does it work?
> The iterator callbacks are called for each item in the set. (If the
> set is ordered, we could consider adding an optional 'from_end'
> boolean, to make it explicitly iterate forward or backward). If the
> iteration is to be cancelled, the iterator callback returns
> SVN_ERR_CANCELLED.
>
> Returning an error (including SVN_ERR_CANCELLED) from the iterator
> callback acts like the C 'break;' statement:it stops the iteration.
>
> The drivers have a *completed boolean return value which is set to
> TRUE if the iteration was completed successfully, or FALSE otherwise.
>
> The iterator driver return value is the one returned by the iterator
> callback, except for SVN_ERR_CANCELLED in which case the driver
> returns SVN_NO_ERROR.

+1

Maybe don't overload SVN_ERR_CANCELLED for this, but instead use a
dedicated, self-documenting error code -- SVN_ERR_ITER_BREAK or
something.

I'm a little worried about using an error object as the "stop" marker
at all. When we have nested iterations, the inner iteration will end
up generating lots of error objects. True, they will be cleared, but
there's some overhead to just allocating something in the global pool.

The only alternative I can think of would be that all iter '*_cb_t'
functions would have a boolean '&stop' parameter, which they set to
true when they want to break out of the iteration.

(I don't have hard numbers to back up this worry, so perhaps I'm just
being a curmudgeon.)

I found your rewritten code more readable, btw.

-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Sep 10 21:34:55 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.