Skip to content

How allocate STRSXP outside of gc

2 messages · Vadim Ogranovich, Brian Ripley

#
mkChar is a rather expensive call since it allocates a new R object. For
example in reading char data from a file it is often advantageous to
first try to look up an already made R string and only then use mkChar.
That is, the overhead of the lookup is usually smaller than that of
mkChar.
#
On Wed, 13 Apr 2005, Vadim Ogranovich wrote:

            
Yes (and that is one reason why scan in 2.1.0 uses lookups, space sharing 
being the other), but both are really fast and this only comes into play 
with hundreds of millions of items.  (On my machine mkChar takes about 200 
ns, hardly `rather expensive'.)  And if you have that much data, why not 
store it in a more efficient format?