aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-10-07 21:57:07 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-10-07 21:57:07 +0000
commit34e1444ebde9516422f08d8ddb4358b11b7e50c1 (patch)
tree979e432f6b66f32ee31a2947acad1040b61dad6f /lib/Support
parentd56cba0b4bc3854e7ed825adbde3ffa8ee9937cb (diff)
downloadexternal_llvm-34e1444ebde9516422f08d8ddb4358b11b7e50c1.zip
external_llvm-34e1444ebde9516422f08d8ddb4358b11b7e50c1.tar.gz
external_llvm-34e1444ebde9516422f08d8ddb4358b11b7e50c1.tar.bz2
Windows: Avoiding resizing, use uninitialized data() instead
This is ever-so faster but more importantly matches what we have elsewhere. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192137 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/Windows/Process.inc9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Support/Windows/Process.inc b/lib/Support/Windows/Process.inc
index 50a204f..f9a3db9 100644
--- a/lib/Support/Windows/Process.inc
+++ b/lib/Support/Windows/Process.inc
@@ -161,8 +161,9 @@ Optional<std::string> Process::GetEnv(StringRef Name) {
SmallVector<wchar_t, MAX_PATH> Buf;
size_t Size = MAX_PATH;
do {
- Buf.resize(Size);
- Size = GetEnvironmentVariableW(&NameUTF16[0], &Buf[0], Buf.capacity());
+ Buf.reserve(Size);
+ Size =
+ GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.capacity());
if (Size == 0)
return None;
@@ -172,9 +173,9 @@ Optional<std::string> Process::GetEnv(StringRef Name) {
// Convert the result from UTF-16 to UTF-8.
SmallVector<char, MAX_PATH> Res;
- if (error_code ec = windows::UTF16ToUTF8(&Buf[0], Size, Res))
+ if (error_code ec = windows::UTF16ToUTF8(Buf.data(), Size, Res))
return None;
- return std::string(&Res[0]);
+ return std::string(Res.data());
}
error_code