> On April 1, 2017, 12:01 a.m., Jeff Coffler wrote:
> > 3rdparty/stout/include/stout/stringify.hpp
> > Lines 42 (patched)
> > <https://reviews.apache.org/r/58125/diff/1/?file=1682876#file1682876line42>
> >
> >     We've learned, from other projects, that converting from string to/from 
> > wstring to/from utf8string can be VERY expensive operations, particularly 
> > when unicode is allowed. Certain unicode operations can be extraordinarily 
> > slow.
> >     
> >     Due to this, we learned that we're far better off just storing things 
> > in a CONSISTENT format (generally wstring, since that's fast for length 
> > operations and such) and then, if we need to convert for final 
> > transmission, convert once at the very end.
> >     
> >     How heavily will this function be used?
> >     
> >     And, of course, it's in stout, but if stout was better desogmed, it 
> > would be nicer to have a separate implementation rather than inlining code 
> > in a bunch of places.

This is an additional function template specialization. No conversions are 
being explicitly performed here.

That said, there is no way that Mesos is going to convert to `wstring` across 
its entire codebase. However, for Windows code, the recommended best practices 
are to use the Unicode versions of Windows APIs (as the non-Unicode versions 
are not UTF at all, they're the current "Windows code page" aka ANSI which 
could be almost any encoding). Since Windows returns UTF-16, we need a reliable 
way to convert to UTF-8 on-demand for Mesos, which this additional 
specialization of `stringify` provides.

This needs to be inlined because it is a specialization (e.g. not a template) 
in a header. If it is not inlined, then it gets defined in multiple objects and 
linking fails.


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58125/#review170802
-----------------------------------------------------------


On April 1, 2017, 4:32 a.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/58125/
> -----------------------------------------------------------
> 
> (Updated April 1, 2017, 4:32 a.m.)
> 
> 
> Review request for mesos, Jeff Coffler, John Kordich, Joseph Wu, Li Li, and 
> Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Stout: Added stringify for std::wstring.
> 
> 
> Diffs
> -----
> 
>   3rdparty/stout/include/stout/stringify.hpp 
> e9588d8d940046791794100c53469288656a14f0 
> 
> 
> Diff: https://reviews.apache.org/r/58125/diff/2/
> 
> 
> Testing
> -------
> 
> Testing done later in chain.
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>

Reply via email to