4 ms·
UTF8/UTF16 conversions are far cheaper than you think they are. Especially when compared to the cost of a GetFileAttributesExW or other filesystem operation. I
by gilgoomesh 12y ago
UTF8/UTF16 conversions are far cheaper than you think they are. Especially when compared to the cost of a GetFileAttributesExW or other filesystem operation.
I use boost::filesystem for a server that performs large numbers of bulk file system traversals. I keep all my pathnames in UTF-8 and make boost::filesystem perform all the conversions (you need to imbue the boost::filesystem locale with a UTF-8 conversion facet to force UTF-8 on Windows but that's straightforward). When reading from NTFS cached data, the overhead of UTF-8 to UTF-16 conversions is around 15% in the worst case of ~300 char Long Path operations and much less for smaller paths or uncached data.
If 15% overhead is going to kill your performance then yes, avoid the standard library and write your own classes; that's probably true for all standard library classes. For all other cases, you'd be foolish to write everything yourself.