lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master a34d612 3/3: Remove an unnecessary accessor


From: Greg Chicares
Subject: [lmi-commits] [lmi] master a34d612 3/3: Remove an unnecessary accessor
Date: Mon, 12 Feb 2018 19:54:22 -0500 (EST)

branch: master
commit a34d6122422dcc3dfce1b31b8b673fd95b13082c
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Remove an unnecessary accessor
    
    See the in-depth discussion here:
      http://lists.nongnu.org/archive/html/lmi/2018-02/msg00009.html
      http://lists.nongnu.org/archive/html/lmi/2018-02/msg00011.html
---
 html.hpp          | 9 +++------
 pdf_writer_wx.cpp | 4 ++--
 pdf_writer_wx.hpp | 2 +-
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/html.hpp b/html.hpp
index 3493f77..395dcd8 100644
--- a/html.hpp
+++ b/html.hpp
@@ -53,7 +53,9 @@ namespace html
 /// escaping internally).
 ///
 /// As it still needs to be converted to a string sooner or later to be really
-/// used, it does provide a conversion -- but it can be used only once.
+/// used, it does provide a conversion, as_html(), which uses move semantics,
+/// so it requires an rvalue reference and must be the last member function
+/// called on an instance of this class.
 
 class text
 {
@@ -115,11 +117,6 @@ class text
         return *this;
     }
 
-    std::string const& as_html() const&
-    {
-        return m_html;
-    }
-
     std::string&& as_html() &&
     {
         return std::move(m_html);
diff --git a/pdf_writer_wx.cpp b/pdf_writer_wx.cpp
index bfb1d76..8f1284d 100644
--- a/pdf_writer_wx.cpp
+++ b/pdf_writer_wx.cpp
@@ -173,7 +173,7 @@ int pdf_writer_wx::output_html
     (int                          x
     ,int                          y
     ,int                          width
-    ,html::text const&            html
+    ,html::text&&                 html
     ,oenum_render_or_only_measure output_mode
     )
 {
@@ -181,7 +181,7 @@ int pdf_writer_wx::output_html
     // font which is changed by rendering the HTML contents.
     wxDCFontChanger preserve_font(pdf_dc_, wxFont());
 
-    auto const html_str = wxString::FromUTF8(html.as_html());
+    auto const html_str = wxString::FromUTF8(std::move(html).as_html());
     std::unique_ptr<wxHtmlContainerCell> const cell
         (static_cast<wxHtmlContainerCell*>(html_parser_.Parse(html_str))
         );
diff --git a/pdf_writer_wx.hpp b/pdf_writer_wx.hpp
index 0a76029..c5bcc11 100644
--- a/pdf_writer_wx.hpp
+++ b/pdf_writer_wx.hpp
@@ -59,7 +59,7 @@ class pdf_writer_wx
         (int                          x
         ,int                          y
         ,int                          width
-        ,html::text const&            html
+        ,html::text&&                 html
         ,oenum_render_or_only_measure output_mode = oe_render
         );
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]