You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Greg Stein <gs...@lyra.org> on 2002/05/09 22:15:44 UTC

Re: svn commit: rev 1918 - trunk/subversion/libsvn_repos

On Thu, May 09, 2002 at 04:55:10PM -0500, sussman@tigris.org wrote:
>...
> @@ -231,31 +234,29 @@
>    remaining_bytes = content_length - bytes_sucked;
>    if (remaining_bytes > 0) 
>      {
> +      apr_size_t rlen, wlen, i, iterations, remainder;
>...
> +      remainder = remaining_bytes % buflen;
> +      iterations = remaining_bytes / buflen;

The logic in the function would be a lot simpler if you did a couple things:

* tossed bytes_sucked and just decrement content_length
* toss remaining_bytes and just test content_length directly
* don't compute iterations and remainder: just loop, decrement
  content_length for each chunk you read, and exit when content_length
  reaches zero.

>...
> @@ -326,6 +330,8 @@
>  {
>    svn_stringbuf_t *linebuf;
>    void *current_rev_baton = NULL;
> +  char *buffer = apr_pcalloc (pool, SVN_STREAM_CHUNK_SIZE);
> +  apr_size_t buflen = SVN_STREAM_CHUNK_SIZE;

Ah! Goodness. Although, I'd suggest tossing buflen, and just passing
SVN_STREAM_CHUNK_SIZE (not too fussed either way, but if you keep the
variable, then init it first and use the var in the alloc). That should also
be apr_palloc() since you don't need it zeroed.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: rev 1918 - trunk/subversion/libsvn_repos

Posted by Ben Collins-Sussman <su...@collab.net>.
Greg Stein <gs...@lyra.org> writes:

> > +      remainder = remaining_bytes % buflen;
> > +      iterations = remaining_bytes / buflen;
> 
> The logic in the function would be a lot simpler if you did a couple things:
> 
> * tossed bytes_sucked and just decrement content_length
> * toss remaining_bytes and just test content_length directly
> * don't compute iterations and remainder: just loop, decrement
>   content_length for each chunk you read, and exit when content_length
>   reaches zero.

Ohhhhhhhhhhhhhhhhhhhh.... of course!

[Ben is flattened by the Clue Anvil]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org