diff options
author | Lei Zhang <thestig@chromium.org> | 2017-03-17 15:14:19 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-17 22:54:26 +0000 |
commit | 85f019a8e7d33cbba368a6c6b75fd091269e14a1 (patch) | |
tree | 8dcf6fcd98309a48ebbd9e46cc8c0d23a57c0965 /core/fxcrt | |
parent | 240fe6d79f234896a966ddce0b9a125776dc9171 (diff) | |
download | pdfium-85f019a8e7d33cbba368a6c6b75fd091269e14a1.tar.xz |
Add pdfium::clamp() as a placeholder for std::clamp().chromium/3046
Ue it to fix a typo as well.
BUG=pdfium:634
Change-Id: I2d686242ffb841aedc2fae6a3cf7a00bea667404
Reviewed-on: https://pdfium-review.googlesource.com/3113
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r-- | core/fxcrt/fx_basic_bstring.cpp | 5 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_wstring.cpp | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index b4eb4a75e0..f049b14c3a 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -12,6 +12,7 @@ #include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/fx_basic.h" #include "third_party/base/numerics/safe_math.h" +#include "third_party/base/stl_util.h" template class CFX_StringDataTemplate<char>; template class CFX_StringCTemplate<char>; @@ -405,8 +406,8 @@ CFX_ByteString CFX_ByteString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const { if (!m_pData) return CFX_ByteString(); - nFirst = std::min(std::max(nFirst, 0), m_pData->m_nDataLength); - nCount = std::min(std::max(nCount, 0), m_pData->m_nDataLength - nFirst); + nFirst = pdfium::clamp(nFirst, 0, m_pData->m_nDataLength); + nCount = pdfium::clamp(nCount, 0, m_pData->m_nDataLength - nFirst); if (nCount == 0) return CFX_ByteString(); diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp index 8522d42a38..384b0b0086 100644 --- a/core/fxcrt/fx_basic_wstring.cpp +++ b/core/fxcrt/fx_basic_wstring.cpp @@ -13,6 +13,7 @@ #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_ext.h" #include "third_party/base/numerics/safe_math.h" +#include "third_party/base/stl_util.h" template class CFX_StringDataTemplate<wchar_t>; template class CFX_StringCTemplate<wchar_t>; @@ -375,8 +376,8 @@ CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const { if (!m_pData) return CFX_WideString(); - nFirst = std::min(std::max(nFirst, 0), m_pData->m_nDataLength); - nCount = std::min(std::max(nCount, 0), m_pData->m_nDataLength - nFirst); + nFirst = pdfium::clamp(nFirst, 0, m_pData->m_nDataLength); + nCount = pdfium::clamp(nCount, 0, m_pData->m_nDataLength - nFirst); if (nCount == 0) return CFX_WideString(); |