The lvalue substr doesn't actually return the string but a special lvalue indicating the offset and length. Creating this and setting it to '' involves a fair amount of overhead.
Which is actually more efficient will probably depend on how much you are truncating.
In reply to Re: Re: Re: Re: Efficienty truncating a long string
by ysth
in thread Efficienty truncating a long string
by dino
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |