From 82cba791799f414c3581cc6a045ece167b090fef Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Fri, 7 Oct 2016 17:21:09 +0200 Subject: [PATCH] Do not make unnecessary copy when serving binary content. Binary content do not need to be modified, so we don't need to copy it. We can directly serve it from the internal zim (cluster) buffer. The handle_content function now getArticleObjectByDecodedUrl instead of getContentByDecodedUrl. This is to get the mimetype of the article and copy the content only when needed (getContentByDecodedUrl always copy the content). Thus, handle_content is a bit more complex as it need to do some manipulation previously made in getContentByDecodedUrl. The main change is that if the content is binary, we serve the content with a callback response who will get the content chunks directly from the blob buffer. --- src/common/kiwix/reader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/kiwix/reader.h b/src/common/kiwix/reader.h index 79de7f18f..98901dbf8 100644 --- a/src/common/kiwix/reader.h +++ b/src/common/kiwix/reader.h @@ -81,6 +81,7 @@ namespace kiwix { bool parseUrl(const string &url, char *ns, string &title); unsigned int getFileSize(); zim::File* getZimFileHandler(); + bool getArticleObjectByDecodedUrl(const string &url, zim::Article &article); protected: zim::File* zimFileHandler; @@ -95,7 +96,6 @@ namespace kiwix { private: std::map parseCounterMetadata(); - bool getArticleObjectByDecodedUrl(const string &url, zim::Article &article); }; }