Csound Csound-dev Csound-tekno Search About

[Cs-dev] faster new parser (50%)

Date2012-03-29 08:47
FromTito Latini
Subject[Cs-dev] faster new parser (50%)
AttachmentsNone  

Date2012-03-29 09:16
FromRory Walsh
SubjectRe: [Cs-dev] faster new parser (50%)
50% faster seems like a good thing!

On 29 March 2012 00:47, Tito Latini  wrote:
> I have written the code to speed up the new parser.
> The current code for `corfile_puts' uses two loops, one for `strlen'
> and one for `strcat'. The new code uses only a loop for the string.
> Besides, it preserves the NUL chars to the end (like `strcat'),
> necessary for the new parser. Here is the code:
>
> void corfile_puts(char *s, CORFIL *f)
> {
>    char *c;
>    int n;
>    /* skip and count the NUL chars to the end */
>    for (n=0; f->p > 0 && f->body[f->p-1] == '\0'; n++, f->p--);
>    /* append the string */
>    for (c = s; *c != '\0'; c++) {
>      f->body[f->p++] = *c;
>      if (f->p >= f->len)
>        f->body = (char*) realloc(f->body, f->len+=100);
>    }
>    if (n > 0) {
>      /* put the extra NUL chars to the end */
>      while(--n >= 0) {
>        f->body[f->p++] = '\0';
>        if (f->p >= f->len)
>          f->body = (char*) realloc(f->body, f->len+=100);
>      }
>    }
>    f->body[f->p] = '\0';
> }
>
> It passes the extensive tests (also faster).
>
> Is it good for you?
>
> tito
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-03-29 09:18
FromTito Latini
SubjectRe: [Cs-dev] faster new parser (50%)
AttachmentsNone  

Date2012-03-29 09:38
FromTito Latini
SubjectRe: [Cs-dev] faster new parser (50%)
AttachmentsNone