This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Rethinking... (Re: RFC: fp printing speedup...)


Nathan Myers wrote:

...
Well, wait. What if ctype.widen looked like:

CharT widen(char) {
 if (!cache) {
	cache = getcache();
	do_widen(cache.CharTarray, cache.chararry);
 }
 return cache.CharTarray[char];
}

Would this help the speed?



I don't think a ctype cache would help much, if at all. Better to avoid calling ctype<>::widen(char) too frequently.

That would be the ideal goal :) Our widen() looks similar to the one above and it does make a significant difference in performance, especially where virtual function calls are expensive.


...
If the standard does intend this to be the case, then we don't need to
loop with widen(char) and can use the array form instead.


Absolutely you can use the array form. Anybody who suggested that
anything should work right when widen gives different results for single char and array forms would be laughed off the list.

I'm sure Nathan is right but I agree that it would be nice if the standard actually said so. I'll submit an issue. That said, it may not be straightforward to eliminate the virtual call from the array form. Plus, using the array form may also require another buffer to copy to before inserting into the stream (although your implementation has that snazzy ostreambuf_iterator to avoid this extra copy).

Martin



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]