[R-sig-hpc] How to shorten an atomic vector without copying?

Simon Urbanek simon.urbanek at r-project.org
Sun Apr 15 15:16:12 CEST 2012

On Apr 15, 2012, at 6:54 AM, Jens Oehlschlägel wrote:

> Hi Performance gurus,
> Does any of you know how to shorten an atomic vector without copying the contents to a new vector? The official SET_LENGTH and lengthgets seem to create a new atomic vector rather than realloc the old one.

You can use SETLENGTH(x) to shorten vectors, but be aware that it doesn't change the allocated memory.

There is no way to realloc (besides, in practice realloc is typically just a shortcut for allocating more and copying the contents ).


More information about the R-sig-hpc mailing list