Mercurial > hg > orthanc
diff OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp @ 4484:64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 28 Jan 2021 19:03:19 +0100 |
parents | d9473bd5ed43 |
children | fa2311f94d9f |
line wrap: on
line diff
--- a/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp Thu Jan 28 16:59:40 2021 +0100 +++ b/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp Thu Jan 28 19:03:19 2021 +0100 @@ -23,8 +23,9 @@ #include "../PrecompiledHeaders.h" #include "MemoryStorageArea.h" +#include "../Logging.h" #include "../OrthancException.h" -#include "../Logging.h" +#include "../StringMemoryBuffer.h" namespace Orthanc { @@ -65,9 +66,8 @@ } - void MemoryStorageArea::Read(std::string& content, - const std::string& uuid, - FileContentType type) + IMemoryBuffer* MemoryStorageArea::Read(const std::string& uuid, + FileContentType type) { LOG(INFO) << "Reading attachment \"" << uuid << "\" of \"" << static_cast<int>(type) << "\" content type"; @@ -86,7 +86,7 @@ } else { - content.assign(*found->second); + return StringMemoryBuffer::CreateFromCopy(*found->second); } }