Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-6560

The default stout stringify always copies its argument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.3.0
    • stout
    • 2

    Description

      The default implementation of the template stringify in stout always copies its argument,

      template <typename T> std::string stringify(T t)
      

      For most types implementing a dedicated stringify we restrict T to some const ref with the exception of the specialization for bool,

      template <> std::string stringify(const bool& b)
      

      Copying by default is bad since it requires T to be copyable without stringify actually requiring this. It also likely leads to bad performance.
      It appears switching to e.g.,

      template <typename T> std::string stringify(const T& t)
      

      and adjusting the bool specialization would be a general improvement.

      This issue was first detected by Coverity in CID 727974 way back on 2012-09-21.

      Attachments

        Issue Links

          Activity

            People

              bbannier Benjamin Bannier
              bbannier Benjamin Bannier
              Neil Conway Neil Conway
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: