From 3f6f26731ab7d6f23510a0a95c882e1d8d4e0d06 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Fri, 11 Feb 2022 12:48:54 +0800 Subject: [PATCH] =?UTF-8?q?ts=E5=B0=8F=E6=96=87=E4=BB=B6=E5=85=88=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=88=B0=E5=86=85=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpBody.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Http/HttpBody.cpp b/src/Http/HttpBody.cpp index 9d88cec3..6b660c7a 100644 --- a/src/Http/HttpBody.cpp +++ b/src/Http/HttpBody.cpp @@ -95,6 +95,12 @@ static std::shared_ptr getSharedMmap(const string &file_path, const std::s } }); { + if (max_size < 10 * 1024 * 1024 && file_path.rfind(".ts") != string::npos) { + //如果是小ts文件,那么尝试先加载到内存 + auto buf = BufferRaw::create(); + buf->assign(ret.get(), max_size); + ret.reset(buf->data(), [buf](char *ptr) {}); + } lock_guard lck(s_mtx); s_shared_mmap[file_path] = std::make_pair(ret.get(), ret); }