diff options
author | Lei Zhang <thestig@chromium.org> | 2015-06-19 15:09:45 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-06-19 15:09:45 -0700 |
commit | e8d3691c82d1be805ffdce3329d00313af7ce0ab (patch) | |
tree | 39c6aeb956cc865e8f0b88ddcd80d1dd9e4285f7 /fpdfsdk/src/pdfwindow/PWL_Wnd.cpp | |
parent | cfac954abcab7caf47d3fa3d641c553cba998271 (diff) | |
download | pdfium-e8d3691c82d1be805ffdce3329d00313af7ce0ab.tar.xz |
Replace CFX_MapPtrTemplate with std::map.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1181593003.
Diffstat (limited to 'fpdfsdk/src/pdfwindow/PWL_Wnd.cpp')
-rw-r--r-- | fpdfsdk/src/pdfwindow/PWL_Wnd.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp index dcc6e409a4..89d4babcd7 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include <map> + #include "../../include/pdfwindow/PDFWindow.h" #include "../../include/pdfwindow/PWL_Wnd.h" #include "../../include/pdfwindow/PWL_Utils.h" @@ -11,10 +13,10 @@ /* -------------------------- CPWL_Timer -------------------------- */ -static CFX_MapPtrTemplate<int32_t, CPWL_Timer*>& GetPWLTimeMap() +static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() { // Leak the object at shutdown. - static auto timeMap = new CFX_MapPtrTemplate<int32_t, CPWL_Timer*>; + static auto timeMap = new std::map<int32_t, CPWL_Timer*>; return *timeMap; } @@ -34,33 +36,33 @@ CPWL_Timer::~CPWL_Timer() int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse) { - if (m_nTimerID != 0) KillPWLTimer(); - m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); - GetPWLTimeMap().SetAt(m_nTimerID, this); - return m_nTimerID; + if (m_nTimerID != 0) + KillPWLTimer(); + m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); + + GetPWLTimeMap()[m_nTimerID] = this; + return m_nTimerID; } void CPWL_Timer::KillPWLTimer() { - if (m_nTimerID != 0) - { - m_pSystemHandler->KillTimer(m_nTimerID); - GetPWLTimeMap().RemoveKey(m_nTimerID); - m_nTimerID = 0; - } + if (m_nTimerID == 0) + return; + + m_pSystemHandler->KillTimer(m_nTimerID); + GetPWLTimeMap().erase(m_nTimerID); + m_nTimerID = 0; } void CPWL_Timer::TimerProc(int32_t idEvent) { - CPWL_Timer* pTimer = NULL; - if (GetPWLTimeMap().Lookup(idEvent, pTimer)) - { - if (pTimer) - { - if (pTimer->m_pAttached) - pTimer->m_pAttached->TimerProc(); - } - } + auto it = GetPWLTimeMap().find(idEvent); + if (it == GetPWLTimeMap().end()) + return; + + CPWL_Timer* pTimer = it->second; + if (pTimer->m_pAttached) + pTimer->m_pAttached->TimerProc(); } /* -------------------------- CPWL_TimerHandler -------------------------- */ |