summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_bidi.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-05-01 18:47:54 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-01 18:47:54 +0000
commit4bbbca4880fdff6b106bd935e6cd62f82025ec55 (patch)
treedfe88a24e9df312a99c1dcfa08d66a4118f98c22 /core/fxcrt/fx_bidi.cpp
parent13339176b157eab56a1fa0a11525e193c3aa597a (diff)
downloadpdfium-4bbbca4880fdff6b106bd935e6cd62f82025ec55.tar.xz
Clean up CFX_BidiString.
- Refer to the string in CFX_BidiString by const-ref. - Remove useless CharAt() method. - Turn a member variable into a local variable. Change-Id: I30f221b7350150c839a793129789d8ea7cc1f331 Reviewed-on: https://pdfium-review.googlesource.com/31670 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_bidi.cpp')
-rw-r--r--core/fxcrt/fx_bidi.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/core/fxcrt/fx_bidi.cpp b/core/fxcrt/fx_bidi.cpp
index db46d994c9..48504e5821 100644
--- a/core/fxcrt/fx_bidi.cpp
+++ b/core/fxcrt/fx_bidi.cpp
@@ -577,16 +577,14 @@ void CFX_BidiChar::StartNewSegment(CFX_BidiChar::Direction direction) {
m_CurrentSegment.direction = direction;
}
-CFX_BidiString::CFX_BidiString(const WideString& str)
- : m_Str(str),
- m_pBidiChar(pdfium::MakeUnique<CFX_BidiChar>()),
- m_eOverallDirection(CFX_BidiChar::LEFT) {
- for (const auto& c : m_Str) {
- if (m_pBidiChar->AppendChar(c))
- m_Order.push_back(m_pBidiChar->GetSegmentInfo());
+CFX_BidiString::CFX_BidiString(const WideString& str) : m_Str(str) {
+ CFX_BidiChar bidi;
+ for (wchar_t c : m_Str) {
+ if (bidi.AppendChar(c))
+ m_Order.push_back(bidi.GetSegmentInfo());
}
- if (m_pBidiChar->EndChar())
- m_Order.push_back(m_pBidiChar->GetSegmentInfo());
+ if (bidi.EndChar())
+ m_Order.push_back(bidi.GetSegmentInfo());
size_t nR2L = std::count_if(m_Order.begin(), m_Order.end(),
[](const CFX_BidiChar::Segment& seg) {
@@ -604,6 +602,11 @@ CFX_BidiString::CFX_BidiString(const WideString& str)
CFX_BidiString::~CFX_BidiString() {}
+CFX_BidiChar::Direction CFX_BidiString::OverallDirection() const {
+ ASSERT(m_eOverallDirection != CFX_BidiChar::NEUTRAL);
+ return m_eOverallDirection;
+}
+
void CFX_BidiString::SetOverallDirectionRight() {
if (m_eOverallDirection != CFX_BidiChar::RIGHT) {
std::reverse(m_Order.begin(), m_Order.end());