Chromium Code Reviews| Index: core/src/fxcodec/codec/fx_codec_icc.cpp |
| diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp |
| index 856766e4ea65aedbada070a827f37634ba96cad4..20bd0a017c7502e84c81af53e77b8d268d161c0e 100644 |
| --- a/core/src/fxcodec/codec/fx_codec_icc.cpp |
| +++ b/core/src/fxcodec/codec/fx_codec_icc.cpp |
| @@ -436,7 +436,8 @@ void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam, |
| CFX_ByteString ProfileKey(key.GetBuffer(), key.GetSize()); |
| ASSERT(pTransformKey); |
| pTransformKey->AppendBlock(ProfileKey.GetBuffer(0), ProfileKey.GetLength()); |
| - if (!m_MapProfile.Lookup(ProfileKey, (void*&)pCache)) { |
| + auto it = m_MapProfile.find(ProfileKey); |
| + if (it == m_MapProfile.end()) { |
| pCache = new CFX_IccProfileCache; |
| switch (pIccParam->dwProfileType) { |
| case Icc_PARAMTYPE_BUFFER: |
| @@ -458,8 +459,9 @@ void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam, |
| default: |
| break; |
| } |
| - m_MapProfile.SetAt(ProfileKey, pCache); |
| + m_MapProfile[ProfileKey] = pCache; |
| } else { |
| + pCache = it->second; |
| pCache->m_dwRate++; |
| } |
| return pCache->m_pProfile; |
| @@ -498,7 +500,8 @@ void* CCodec_IccModule::CreateTransform( |
| << (pProofProfile != NULL) << dwPrfIntent << dwPrfFlag; |
| CFX_ByteStringC TransformKey(key.GetBuffer(), key.GetSize()); |
| CFX_IccTransformCache* pTransformCache; |
| - if (!m_MapTranform.Lookup(TransformKey, (void*&)pTransformCache)) { |
| + auto it = m_MapTranform.find(TransformKey); |
| + if (it == m_MapTranform.end()) { |
| pCmm = FX_Alloc(CLcmsCmm, 1); |
| pCmm->m_nSrcComponents = T_CHANNELS(dwInputProfileType); |
| pCmm->m_nDstComponents = T_CHANNELS(dwOutputProfileType); |
| @@ -514,25 +517,25 @@ void* CCodec_IccModule::CreateTransform( |
| dwOutputProfileType, dwIntent, dwFlag); |
| } |
| pCmm->m_hTransform = pTransformCache->m_pIccTransform; |
| - m_MapTranform.SetAt(TransformKey, pTransformCache); |
| + m_MapTranform[TransformKey] = pTransformCache; |
| } else { |
| + pTransformCache = it->second; |
| pTransformCache->m_dwRate++; |
| } |
| return pTransformCache->m_pCmm; |
| } |
| CCodec_IccModule::~CCodec_IccModule() { |
| - FX_POSITION pos = m_MapProfile.GetStartPosition(); |
| - CFX_ByteString key; |
| - CFX_IccProfileCache* pProfileCache; |
| - while (pos) { |
| - m_MapProfile.GetNextAssoc(pos, key, (void*&)pProfileCache); |
| - delete pProfileCache; |
| + auto profile_it = m_MapProfile.begin(); |
| + while (profile_it != m_MapProfile.end()) { |
|
Lei Zhang
2015/08/15 00:47:33
Range-Based For Loops here and below?
Tom Sepez
2015/08/17 20:15:25
Done.
|
| + auto temp = profile_it++; |
| + delete temp->second; |
| + m_MapProfile.erase(temp); |
| } |
| - pos = m_MapTranform.GetStartPosition(); |
| - CFX_IccTransformCache* pTransformCache; |
| - while (pos) { |
| - m_MapTranform.GetNextAssoc(pos, key, (void*&)pTransformCache); |
| - delete pTransformCache; |
| + auto transform_it = m_MapTranform.begin(); |
| + while (transform_it != m_MapTranform.end()) { |
| + auto temp = transform_it++; |
| + delete temp->second; |
| + m_MapTranform.erase(temp); |
| } |
| } |
| void* CCodec_IccModule::CreateTransform_sRGB(const uint8_t* pProfileData, |