From 7132f71cf010e4f13eb27c1a24d8878aa984b43f Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Wed, 29 Mar 2017 18:31:00 +0300
Subject: Remove extra memory copy in VirtFs::loadFile.

Also add const into VirtFs::loadFile.
---
 src/fs/virtfs/virtfs1_unittest.cc | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

(limited to 'src/fs/virtfs/virtfs1_unittest.cc')

diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc
index ee8e97e3e..a48f9829c 100644
--- a/src/fs/virtfs/virtfs1_unittest.cc
+++ b/src/fs/virtfs/virtfs1_unittest.cc
@@ -1433,8 +1433,8 @@ TEST_CASE("VirtFs1 loadFile1")
     VirtFs::mountDir(prefix + "data",
         Append_false);
 
-    char *const buffer = VirtFs::loadFile("test/test.txt", fileSize);
-    REQUIRE(static_cast<void*>(buffer) != nullptr);
+    const char *const buffer = VirtFs::loadFile("test/test.txt", fileSize);
+    REQUIRE(static_cast<const void*>(buffer) != nullptr);
     REQUIRE(fileSize == 23);
     REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
     delete [] buffer;
@@ -1459,8 +1459,9 @@ TEST_CASE("VirtFs1 loadFile2")
 
     SECTION("test 1")
     {
-        char *restrict buffer = VirtFs::loadFile("dir2//test.txt", fileSize);
-        REQUIRE(static_cast<void*>(buffer) != nullptr);
+        const char *restrict buffer = VirtFs::loadFile("dir2//test.txt",
+            fileSize);
+        REQUIRE(static_cast<const void*>(buffer) != nullptr);
         REQUIRE(fileSize == 23);
         REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
         delete [] buffer;
@@ -1468,8 +1469,9 @@ TEST_CASE("VirtFs1 loadFile2")
 
     SECTION("test 2")
     {
-        char *restrict buffer = VirtFs::loadFile("dir2\\/test.txt", fileSize);
-        REQUIRE(static_cast<void*>(buffer) != nullptr);
+        const char *restrict buffer = VirtFs::loadFile("dir2\\/test.txt",
+            fileSize);
+        REQUIRE(static_cast<const void*>(buffer) != nullptr);
         REQUIRE(fileSize == 23);
         REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
         delete [] buffer;
-- 
cgit v1.2.3-70-g09d2