From 520c00425997c69ddbb72441cb5bfe3e0949475e Mon Sep 17 00:00:00 2001 From: an-tao <20741618@qq.com> Date: Thu, 11 Oct 2018 16:55:41 +0800 Subject: [PATCH] Decrease map searching --- lib/src/HttpAppFrameworkImpl.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/HttpAppFrameworkImpl.cc b/lib/src/HttpAppFrameworkImpl.cc index 5fc9631e..8b2c5861 100755 --- a/lib/src/HttpAppFrameworkImpl.cc +++ b/lib/src/HttpAppFrameworkImpl.cc @@ -751,14 +751,15 @@ void HttpAppFrameworkImpl::onAsyncRequest(const HttpRequestPtr& req,const std::f { auto &filters=_simpCtrlMap[pathLower].filtersName; doFilters(filters,req,callback,needSetJsessionid,session_id,[=](){ - const std::string &ctrlName = _simpCtrlMap[pathLower].controllerName; + auto &ctrlItem=_simpCtrlMap[pathLower]; + const std::string &ctrlName = ctrlItem.controllerName; std::shared_ptr controller; HttpResponsePtr responsePtr; { //maybe update controller,so we use lock_guard to protect; - std::lock_guard guard(_simpCtrlMap[pathLower]._mutex); - controller=_simpCtrlMap[pathLower].controller; - responsePtr=_simpCtrlMap[pathLower].responsePtr.lock(); + std::lock_guard guard(ctrlItem._mutex); + controller=ctrlItem.controller; + responsePtr=ctrlItem.responsePtr.lock(); if(!controller) { auto _object = std::shared_ptr(DrClassMap::newObject(ctrlName));