string reuse

raouljp at libero.it raouljp at libero.it
Wed May 21 10:09:23 UTC 2003


hi, 
i have a question about reuse of AjPStr objects.

which of the two possibilities is it correct or better?

"text" = string with a fixed text, it is used to extract substrings.

AjPStr str = NULL;
ajint i = 0;
ajint iMax = lenght_text - lenght_substring;

1) 
str = ajStrNew();
for ( i = 0; i < iMax; i++ )
 {
     ajStrAssSubC( &str, ajStrStr( text ), i, i+lenght_substring-1 );
      ... 
      ajStrDelReuse( &str);
}
ajStrDel( &str );

2) 

for ( i = 0; i < iMax; i++ )
 {
     str = ajStrNew();
     ajStrAssSubC( &str, ajStrStr( text ), i, i+lenght_substring-1 );
      ... 
      ajStrDel( &str);
}

tnx 

by R.J.P.B.
 





More information about the emboss-dev mailing list