What is the fastest way to resize std::string?
<p>I'm working on a C++ project (using <code>VS2008</code>) where I will need to load a very large XML file into <code>std::wstring</code> from a file. Presently the following line reserves memory before the data is loaded:</p>

<pre><code>//std::wstring str;
//size_t ncbDataSz = file size in bytes

str.resize(ncbDataSz / sizeof(WCHAR));
</code></pre>

<p>But my current issue is that the <code>resize</code> method takes somewhat long time for a larger string size (I just tested it with 3GB of data, in a <code>x64</code> project, on a desktop PC with <code>12GB</code> of free RAM and it took about 4-5 seconds to complete.)</p>

<p>So I'm curious, is there's a faster (more optimized) method to resize <code>std::string</code>? I'm asking for Windows only.</p>