Use C++17 non-const string.data() in WindowsUtils

Bug: dawn:824
Change-Id: I9a7880bc38b15864364505f9f9399e440c048e7a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75064
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/common/WindowsUtils.cpp b/src/common/WindowsUtils.cpp
index f4aef7c..a0f041a 100644
--- a/src/common/WindowsUtils.cpp
+++ b/src/common/WindowsUtils.cpp
@@ -23,12 +23,11 @@
     // input. It will return a size that includes the null terminator.
     int requiredSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, nullptr, 0, nullptr, nullptr);
 
-    // When we can use C++17 this can be changed to use string.data() instead.
-    std::unique_ptr<char[]> result = std::make_unique<char[]>(requiredSize);
-    WideCharToMultiByte(CP_UTF8, 0, input, -1, result.get(), requiredSize, nullptr, nullptr);
+    std::string result;
+    result.resize(requiredSize - 1);
+    WideCharToMultiByte(CP_UTF8, 0, input, -1, result.data(), requiredSize, nullptr, nullptr);
 
-    // This will allocate the returned std::string and then destroy result.
-    return std::string(result.get(), result.get() + (requiredSize - 1));
+    return result;
 }
 
 std::wstring UTF8ToWStr(const char* input) {
@@ -36,10 +35,9 @@
     // input. It will return a size that includes the null terminator.
     int requiredSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, nullptr, 0);
 
-    // When we can use C++17 this can be changed to use string.data() instead.
-    std::unique_ptr<wchar_t[]> result = std::make_unique<wchar_t[]>(requiredSize);
-    MultiByteToWideChar(CP_UTF8, 0, input, -1, result.get(), requiredSize);
+    std::wstring result;
+    result.resize(requiredSize - 1);
+    MultiByteToWideChar(CP_UTF8, 0, input, -1, result.data(), requiredSize);
 
-    // This will allocate the returned std::string and then destroy result.
-    return std::wstring(result.get(), result.get() + (requiredSize - 1));
+    return result;
 }