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 08a9d212d4b79dd2ab49f9a6870574be3d5cab45..fb436589dc442820cea541f60fa7cd5ed4b9dad2 100644 |
| --- a/core/fxcrt/fx_basic_wstring.cpp |
| +++ b/core/fxcrt/fx_basic_wstring.cpp |
| @@ -672,17 +672,31 @@ FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) { |
| if (!m_pData || m_pData->m_nDataLength < 1) |
| return 0; |
| - ReallocBeforeWrite(m_pData->m_nDataLength); |
| FX_WCHAR* pstrSource = m_pData->m_String; |
| - FX_WCHAR* pstrDest = m_pData->m_String; |
| FX_WCHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; |
| while (pstrSource < pstrEnd) { |
| + if (*pstrSource == chRemove) |
| + break; |
| + pstrSource++; |
| + } |
| + |
|
Lei Zhang
2016/04/11 21:47:57
BTW, there's an extra blank line vs bstring versio
Tom Sepez
2016/04/12 00:36:46
Done.
|
| + if (pstrSource == pstrEnd) |
| + return 0; |
| + |
| + ptrdiff_t copied = pstrSource - m_pData->m_String; |
| + ReallocBeforeWrite(m_pData->m_nDataLength); |
| + pstrSource = m_pData->m_String + copied; |
| + pstrEnd = m_pData->m_String + m_pData->m_nDataLength; |
| + |
| + FX_WCHAR* pstrDest = pstrSource; |
| + while (pstrSource < pstrEnd) { |
| if (*pstrSource != chRemove) { |
| *pstrDest = *pstrSource; |
| pstrDest++; |
| } |
| pstrSource++; |
| } |
| + |
| *pstrDest = 0; |
| FX_STRSIZE nCount = (FX_STRSIZE)(pstrSource - pstrDest); |
| m_pData->m_nDataLength -= nCount; |