diff --git a/src/Task.cpp b/src/Task.cpp index ed9544a8d..a8a2e2ef1 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1643,12 +1643,8 @@ void Task::validate_before (const std::string& left, const std::string& right) // ] -> &close; const std::string Task::encode (const std::string& value) const { - std::string modified = value; - - str_replace (modified, "[", "&open;"); - str_replace (modified, "]", "&close;"); - - return modified; + auto modified = str_replace (value, "[", "&open;"); + return str_replace (modified, "]", "&close;"); } //////////////////////////////////////////////////////////////////////////////// @@ -1661,18 +1657,11 @@ const std::string Task::encode (const std::string& value) const // : <- : const std::string Task::decode (const std::string& value) const { - if (value.find ('&') != std::string::npos) - { - std::string modified = value; + if (value.find ('&') == std::string::npos) + return value; - // Supported encodings. - str_replace (modified, "&open;", "["); - str_replace (modified, "&close;", "]"); - - return modified; - } - - return value; + auto modified = str_replace (value, "&open;", "["); + return str_replace (modified, "&close;", "]"); } ////////////////////////////////////////////////////////////////////////////////