From af0f28532a9118cf69858d7146df5c5ef4f3dda4 Mon Sep 17 00:00:00 2001 From: Herman Venter Date: Thu, 13 Jun 2013 14:20:45 -0700 Subject: [PATCH] Cache the contents of systemlib.php for use by the debugger, if debugging. Instead of calling get_systemlib every time the debugger client needs to list source from systemlib.php, use a cached copy of the source string. Only do this if debugging is enabled. --- hphp/runtime/base/program_functions.cpp | 4 +++- hphp/runtime/debugger/cmd/cmd_list.cpp | 2 +- hphp/system/lib/systemlib.cpp | 1 + hphp/system/lib/systemlib.h | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hphp/runtime/base/program_functions.cpp b/hphp/runtime/base/program_functions.cpp index 74833a61d..e56a43cb3 100644 --- a/hphp/runtime/base/program_functions.cpp +++ b/hphp/runtime/base/program_functions.cpp @@ -1199,7 +1199,9 @@ string get_systemlib(string* hhas) { ifs.seekg(desc.m_start, std::ios::beg); std::unique_ptr data(new char[desc.m_len]); ifs.read(data.get(), desc.m_len); - return systemlib_split(string(data.get(), desc.m_len), hhas); + string ret = systemlib_split(string(data.get(), desc.m_len), hhas); + if (RuntimeOption::EnableDebugger) SystemLib::s_source = ret; + return ret; } /////////////////////////////////////////////////////////////////////////////// diff --git a/hphp/runtime/debugger/cmd/cmd_list.cpp b/hphp/runtime/debugger/cmd/cmd_list.cpp index 67469fa53..392f56dd7 100644 --- a/hphp/runtime/debugger/cmd/cmd_list.cpp +++ b/hphp/runtime/debugger/cmd/cmd_list.cpp @@ -350,7 +350,7 @@ bool CmdList::onServer(DebuggerProxy &proxy) { } RuntimeOption::WarningFrequency = savedWarningFrequency; if (!m_code && m_file == "systemlib.php") { - m_code = get_systemlib(); + m_code = SystemLib::s_source; } return proxy.sendToClient((DebuggerCommand*)this); } diff --git a/hphp/system/lib/systemlib.cpp b/hphp/system/lib/systemlib.cpp index 60e9d8d9d..0f103813b 100644 --- a/hphp/system/lib/systemlib.cpp +++ b/hphp/system/lib/systemlib.cpp @@ -33,6 +33,7 @@ namespace HPHP { } bool SystemLib::s_inited = false; +string SystemLib::s_source = ""; HPHP::Unit* SystemLib::s_unit = nullptr; HPHP::Unit* SystemLib::s_hhas_unit = nullptr; HPHP::Unit* SystemLib::s_nativeFuncUnit = nullptr; diff --git a/hphp/system/lib/systemlib.h b/hphp/system/lib/systemlib.h index b7d25c0fc..aa7712218 100644 --- a/hphp/system/lib/systemlib.h +++ b/hphp/system/lib/systemlib.h @@ -68,6 +68,7 @@ namespace Eval { class SystemLib { public: static bool s_inited; + static string s_source; static HPHP::Unit* s_unit; static HPHP::Unit* s_hhas_unit; static HPHP::Unit* s_nativeFuncUnit;