Skip to content
Prev 40949 / 63424 Next

slightly speeding up readChar()

On Aug 4, 2011, at 5:26 PM, Michael Lachmann wrote:

            
I'm not sure it's really worth bothering with such optimizations, on my machine I get
user  system elapsed 
  0.295   0.048   0.343 

so that is a fraction of a second for 100MB of data. Besides, why in the world would you want to use character vectors to store bytes? It's much more efficient to work with raw vectors instead...

AFAICS the only lesson from the list below is that we could add in an internal function for safe_mkCharLenCE that doesn't check for NULs. But that seems a little contrived for a very special case. Everything else is either increasing complexity at the cost of safety or could lead to internal inconsistencies (hashing is mandatory, otherwise you can't compare CHARSXPs).

BTW: your code doesn't do what you think it does - you'll force a pretty ugly buffer overflow - perfect illustration why optimization should be done only if really needed, otherwise you are just likely to introduce bugs...

Cheers,
Simon