Chromium Code Reviews| Index: core/fxcrt/fx_basic_wstring.cpp |
| diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp |
| index 95b761bd09e67a55b38ae5216ab5e555b8872a96..b1aa05d1c89606ff3710041f755748f95dd7e5b7 100644 |
| --- a/core/fxcrt/fx_basic_wstring.cpp |
| +++ b/core/fxcrt/fx_basic_wstring.cpp |
| @@ -641,12 +641,10 @@ FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld, |
| FX_WCHAR* lpszStart = m_pData->m_String; |
| FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength; |
| FX_WCHAR* lpszTarget; |
| - { |
| - while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) && |
| - lpszStart < lpszEnd) { |
| - nCount++; |
| - lpszStart = lpszTarget + nSourceLen; |
| - } |
| + while ((lpszTarget = FXSYS_wcsstr(lpszStart, lpszOld)) != nullptr && |
|
Tom Sepez
2016/03/17 16:40:05
nit: again, I think this reads cleaner as a while
Wei Li
2016/03/18 17:42:39
Absolutely agree with you. I originally planned to
|
| + lpszStart < lpszEnd) { |
| + nCount++; |
| + lpszStart = lpszTarget + nSourceLen; |
| } |
| if (nCount > 0) { |
| CopyBeforeWrite(); |
| @@ -667,8 +665,7 @@ FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld, |
| lpszStart = m_pData->m_String; |
| lpszEnd = m_pData->m_String + std::max(m_pData->m_nDataLength, nNewLength); |
| { |
|
Tom Sepez
2016/03/17 16:40:05
nit: braces?
Wei Li
2016/03/18 17:42:39
Done.
|
| - while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) != |
| - NULL && |
| + while ((lpszTarget = FXSYS_wcsstr(lpszStart, lpszOld)) != nullptr && |
|
Tom Sepez
2016/03/17 16:40:05
nit: re-write as discussed above.
Wei Li
2016/03/18 17:42:39
Done.
|
| lpszStart < lpszEnd) { |
| FX_STRSIZE nBalance = |
| nOldLength - |