I've played a bit with the code.

It seems convenient to change Path::ToUTF8() to return std::string.
I'd like to not introduce something like PathUTF8 class and use standard 
types where applicable.

This gives one extra copying and one extra allocation.

Once fs_charset_to_utf8() is replaced with Path::ToUTF8() everywhere 
implementation could be changed to use stack-allocated buffer* and 
streaming conversion API: g_iconv_open()/g_iconv()/g_iconv_close().

This eliminates extra allocation. Copying overhead is tolerable IMO for 
the benefits it provides.

* We could predict max size for UTF-8 path name basing on MPD_PATH_MAX. 
I know there are lots of weird encodings out there, but likely the 
result string would not exceed MPD_PATH_MAX * 4. One character in UTF-8 
occupies at most 4 bytes, so even extreme case this should be enough.
Since the path is nul-terminated size could be even less: ((MPD_MAX_PATH 
- 1) * 4 + 1).

-- 
Denis

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to