--- a/src/core/model/test.cc Tue May 28 16:53:09 2013 -0700
+++ b/src/core/model/test.cc Tue May 28 17:29:48 2013 -0700
@@ -484,22 +484,30 @@
TestRunnerImpl::ReplaceXmlSpecialCharacters (std::string xml) const
{
NS_LOG_FUNCTION (this << xml);
- std::string specials = "<>&\"'";
- std::string replacements[] = {"<", ">", "&", "'", """};
+ typedef std::map <char, std::string> specials_map;
+ specials_map specials;
+ specials['<'] = "<";
+ specials['>'] = ">";
+ specials['&'] = "&";
+ specials['"'] = "'";
+ specials['\''] = """;
+
std::string result;
- std::size_t index, length = xml.length ();
+ std::size_t length = xml.length ();
for (size_t i = 0; i < length; ++i)
{
char character = xml[i];
- if ((index = specials.find (character)) == std::string::npos)
+ specials_map::const_iterator it = specials.find (character);
+
+ if (it == specials.end ())
{
result.push_back (character);
}
else
{
- result += replacements[index];
+ result += it->second;
}
}
return result;