Mail Archives: djgpp/1998/07/20/14:00:56
Eli Zaretskii wrote:
>
> On Mon, 20 Jul 1998, Mariano Alvarez Fernández wrote:
>
> > 0.87 479.39 4.33 2688065 0.00 0.00 strtol
>
> This (and other) entries indicate that you convert strings to integers
> quite a lot. You might consider storing the integer values instead,
> to cut the number of these conversions.
I know, but I use dbf format to store data-bases.
>
> > 0.63 482.56 3.17 5284125 0.00 0.00 strcopnb
> > 0.52 485.17 2.61 5284126 0.00 0.00 strncpy
> > 0.48 487.56 2.39 5284125 0.00 0.00 strlen
>
> These entries seem to imply that you call strlen for each call to
> strcpy/strncpy. It would be faster to call memcpy/memmove instead,
> since once you know the length of a string, there's no reason to use
> the string-copy functions (which are slower because they look for the
> terminating null character).
It's the dbf format too. In dbf char strings are blank filled, I use
null terminated strings internally, strcopnb do the input conversion.
int strcopnb( char *dest, char *org, int max )
{
int i;
strncpy( dest,org,max );
dest[max] = '\0';
max = strlen( dest );
for( i=max-1; i >= 0 && dest[i] == ' '; i-- );
dest[i+1] = '\0';
return 0;
}
Regards, M.Alvarez.
- Raw text -