[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] String support in DataView
On Fri, Nov 4, 2011 at 6:22 PM, Glenn Maynard <firstname.lastname@example.org>
No, because decoding a non-Unicode encoding requires table lookups. UTF-8 requires multiple branches per byte. strnlen can be optimized to less than one branch per byte (typically; glibc's optimization is somewhat more complex than that), and no memory access aside from linear access to the string itself.
The way I usually write it is one switch of the byte anded with 0xF8, so there is one branch (aside from validation checks, which you still have to do when computing the length). Single-byte encodings can obviously be done in constant time, but I wouldn't expect them to be used much anyway.
I mean having both ArrayBuffer and Blob. To my mind (and again not being involved in the discussion), I would have expected one API for supporting access to binary data, and whether it is in RAM or may be spooled to disc is an implementation detail. Not wanting to offer a synchronous API for the spooled to disc case complicates that of course.
John A. Tamplin
Software Engineer (GWT), Google