diff --git a/trunk/src/app/srs_app_pithy_print.cpp b/trunk/src/app/srs_app_pithy_print.cpp index f408d08c5..ebf70def8 100644 --- a/trunk/src/app/srs_app_pithy_print.cpp +++ b/trunk/src/app/srs_app_pithy_print.cpp @@ -171,6 +171,7 @@ static SrsStageManager* _srs_stages = new SrsStageManager(); SrsPithyPrint::SrsPithyPrint(int _stage_id) { stage_id = _stage_id; + cache_ = NULL; client_id = enter_stage(); previous_tick = srs_get_system_time(); _age = 0; @@ -308,7 +309,10 @@ void SrsPithyPrint::leave_stage() void SrsPithyPrint::elapse() { - SrsStageInfo* stage = _srs_stages->fetch_or_create(stage_id); + SrsStageInfo* stage = cache_; + if (!stage) { + stage = cache_ = _srs_stages->fetch_or_create(stage_id); + } srs_assert(stage != NULL); srs_utime_t diff = srs_get_system_time() - previous_tick; @@ -321,7 +325,10 @@ void SrsPithyPrint::elapse() bool SrsPithyPrint::can_print() { - SrsStageInfo* stage = _srs_stages->fetch_or_create(stage_id); + SrsStageInfo* stage = cache_; + if (!stage) { + stage = cache_ = _srs_stages->fetch_or_create(stage_id); + } srs_assert(stage != NULL); return stage->can_print(); diff --git a/trunk/src/app/srs_app_pithy_print.hpp b/trunk/src/app/srs_app_pithy_print.hpp index 0fa3b6da2..bc966db98 100644 --- a/trunk/src/app/srs_app_pithy_print.hpp +++ b/trunk/src/app/srs_app_pithy_print.hpp @@ -111,6 +111,7 @@ class SrsPithyPrint { private: int client_id; + SrsStageInfo* cache_; int stage_id; srs_utime_t _age; srs_utime_t previous_tick;