From 5e4f7feff822e1f4a66d7abcf1318d35800dfa55 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 30 Jan 2012 00:18:53 -0500 Subject: [PATCH] Performance - Added a shortcut test that speeds up the decode process for most cases. --- src/util.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 24ed18aa2..520cf552d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -516,22 +516,27 @@ const std::string encode (const std::string& value) // : <- : const std::string decode (const std::string& value) { - std::string modified = value; + if (value.find ('&') != std::string::npos) + { + std::string modified = value; - // Supported encodings. - str_replace (modified, "&dquot;", "\""); - str_replace (modified, """, "'"); - str_replace (modified, "&open;", "["); - str_replace (modified, "&close;", "]"); + // Supported encodings. + str_replace (modified, "&dquot;", "\""); + str_replace (modified, """, "'"); + str_replace (modified, "&open;", "["); + str_replace (modified, "&close;", "]"); - // Support for deprecated encodings. These cannot be removed or old files - // will not be parsable. Not just old files - completed.data can contain - // tasks formatted/encoded using these. - str_replace (modified, "&squot;", "'"); // Deprecated 2.0 - str_replace (modified, ",", ","); // Deprecated 2.0 - str_replace (modified, ":", ":"); // Deprecated 2.0 + // Support for deprecated encodings. These cannot be removed or old files + // will not be parsable. Not just old files - completed.data can contain + // tasks formatted/encoded using these. + str_replace (modified, "&squot;", "'"); // Deprecated 2.0 + str_replace (modified, ",", ","); // Deprecated 2.0 + str_replace (modified, ":", ":"); // Deprecated 2.0 - return modified; + return modified; + } + + return value; } ////////////////////////////////////////////////////////////////////////////////