From d3b69e8098a2fd6e7bf9a96c37adcbc84f8d72aa Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 19 Oct 2006 07:14:25 +0000 Subject: Use rfind rather than find when chopping strings, its faster as the \r is more likely to be at the end of the sequence not the start git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5497 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 1a4f71b79..e4424a1b0 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -2074,8 +2074,12 @@ class TreeSocket : public InspSocket { std::string ret = in_buffer.substr(0,in_buffer.find("\n")-1); in_buffer = in_buffer.substr(in_buffer.find("\n")+1,in_buffer.length()-in_buffer.find("\n")); - if (ret.find("\r") != std::string::npos) - ret = in_buffer.substr(0,in_buffer.find("\r")-1); + /* Use rfind here not find, as theres more + * chance of the \r being near the end of the + * string, not the start. + */ + if (ret.rfind("\r") != std::string::npos) + ret = in_buffer.substr(0,in_buffer.rfind("\r")-1); /* Process this one, abort if it * didnt return true. */ -- cgit v1.2.3