You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Branko Čibej <br...@apache.org> on 2018/03/03 21:21:37 UTC

Re: svn commit: r1825787 - /subversion/trunk/subversion/tests/libsvn_subr/utf-test.c

On 03.03.2018 22:03, jamessan@apache.org wrote:
> Author: jamessan
> Date: Sat Mar  3 21:03:09 2018
> New Revision: 1825787
>
> URL: http://svn.apache.org/viewvc?rev=1825787&view=rev
> Log:
> * subversion/tests/libsvn_subr/utf-test.c:
>   (test_utf_conversions): Move maxlen loop after declarations
>
> Modified:
>     subversion/trunk/subversion/tests/libsvn_subr/utf-test.c
>
> Modified: subversion/trunk/subversion/tests/libsvn_subr/utf-test.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/utf-test.c?rev=1825787&r1=1825786&r2=1825787&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/tests/libsvn_subr/utf-test.c (original)
> +++ subversion/trunk/subversion/tests/libsvn_subr/utf-test.c Sat Mar  3 21:03:09 2018
> @@ -807,11 +807,6 @@ test_utf_conversions(apr_pool_t *pool)
>    const svn_string_t *result;
>    apr_size_t maxlen = 0;
>  
> -  for (tc = tests; tc->source; ++tc)
> -    if (tc->sourcelen > maxlen)
> -      maxlen = tc->sourcelen;
> -  maxlen++;
> -
>    /* To assure proper alignment of the source string, it needs to be copied
>       into an array of the appropriate type before calling
>       svn_utf__utf{16,32}_to_utf8. */
> @@ -819,6 +814,11 @@ test_utf_conversions(apr_pool_t *pool)
>    apr_int32_t *source32 = apr_pcalloc(pool, maxlen * sizeof(*source32));
>  
>    for (tc = tests; tc->source; ++tc)
> +    if (tc->sourcelen > maxlen)
> +      maxlen = tc->sourcelen;
> +  maxlen++;
> +
> +  for (tc = tests; tc->source; ++tc)
>      {
>        if (tc->sixteenbit)
>          {


Really? You'll always allocate a zero-length buffer?


Re: svn commit: r1825787 - /subversion/trunk/subversion/tests/libsvn_subr/utf-test.c

Posted by James McCoy <ja...@jamessan.com>.
On Sat, Mar 03, 2018 at 10:21:37PM +0100, Branko Čibej wrote:
> On 03.03.2018 22:03, jamessan@apache.org wrote:
> > Author: jamessan
> > Date: Sat Mar  3 21:03:09 2018
> > New Revision: 1825787
> >
> > URL: http://svn.apache.org/viewvc?rev=1825787&view=rev
> > Log:
> > * subversion/tests/libsvn_subr/utf-test.c:
> >   (test_utf_conversions): Move maxlen loop after declarations
> >
> > Modified:
> >     subversion/trunk/subversion/tests/libsvn_subr/utf-test.c
> >
> > Modified: subversion/trunk/subversion/tests/libsvn_subr/utf-test.c
> > URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/utf-test.c?rev=1825787&r1=1825786&r2=1825787&view=diff
> > ==============================================================================
> > --- subversion/trunk/subversion/tests/libsvn_subr/utf-test.c (original)
> > +++ subversion/trunk/subversion/tests/libsvn_subr/utf-test.c Sat Mar  3 21:03:09 2018
> > @@ -807,11 +807,6 @@ test_utf_conversions(apr_pool_t *pool)
> >    const svn_string_t *result;
> >    apr_size_t maxlen = 0;
> >  
> > -  for (tc = tests; tc->source; ++tc)
> > -    if (tc->sourcelen > maxlen)
> > -      maxlen = tc->sourcelen;
> > -  maxlen++;
> > -
> >    /* To assure proper alignment of the source string, it needs to be copied
> >       into an array of the appropriate type before calling
> >       svn_utf__utf{16,32}_to_utf8. */
> > @@ -819,6 +814,11 @@ test_utf_conversions(apr_pool_t *pool)
> >    apr_int32_t *source32 = apr_pcalloc(pool, maxlen * sizeof(*source32));
> >  
> >    for (tc = tests; tc->source; ++tc)
> > +    if (tc->sourcelen > maxlen)
> > +      maxlen = tc->sourcelen;
> > +  maxlen++;
> > +
> > +  for (tc = tests; tc->source; ++tc)
> >      {
> >        if (tc->sixteenbit)
> >          {
> 
> 
> Really? You'll always allocate a zero-length buffer?

It makes the tests run really fast! :) Fixed in r1825788.

Cheers,
-- 
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7  2D23 DFE6 91AE 331B A3DB