From ripley at stats.ox.ac.uk  Thu Apr 14 09:02:25 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu Apr 14 09:02:43 2005
Subject: [Rd] How allocate STRSXP outside of gc
In-Reply-To: <C698D707214E6F4AB39AB7096C3DE5A59E8984@phost015.EVAFUNDS.intermedia.net>
References: <C698D707214E6F4AB39AB7096C3DE5A59E8984@phost015.EVAFUNDS.intermedia.net>
Message-ID: <Pine.LNX.4.61.0504131632090.10084@gannet.stats>

On Wed, 13 Apr 2005, Vadim Ogranovich wrote:

> 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.

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?

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] How allocate STRSXP outside of gc
Prof Brian Ripley