Author: jreidinger
Date: Tue Apr 22 11:57:59 2008
New Revision: 9772
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9772&view=rev
Log:
replace boost::replace_all by jano's implementation which is faster (replace in place)
Modified:
trunk/libzypp/zypp/PoolQuery.cc
trunk/libzypp/zypp/PublicKey.cc
trunk/libzypp/zypp/base/String.cc
trunk/libzypp/zypp/base/String.h
Modified: trunk/libzypp/zypp/PoolQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9772&r1=9771&r2=9772&view=diff
==============================================================================
--- trunk/libzypp/zypp/PoolQuery.cc (original)
+++ trunk/libzypp/zypp/PoolQuery.cc Tue Apr 22 11:57:59 2008
@@ -11,7 +11,6 @@
*/
#include <iostream>
#include <sstream>
-#include
#include "zypp/base/Gettext.h"
#include "zypp/base/Logger.h"
@@ -1079,7 +1078,7 @@
else
{
string s = attrName;
- boost::replace_all( s,"_",":" );
+ str::replace_all( s,"_",":" );
SolvAttr a(s);
addAttribute(a,attrValue);
}
@@ -1177,7 +1176,7 @@
for_( it, attributes().begin(), attributes().end() )
{
string s = it->first.asString();
- boost::replace_all(s,":","_");
+ str::replace_all(s,":","_");
for_( it2,it->second.begin(),it->second.end() )
{
str << s <<": "<< *it2 << delim;
Modified: trunk/libzypp/zypp/PublicKey.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PublicKey.cc?rev=9772&r1=9771&r2=9772&view=diff
==============================================================================
--- trunk/libzypp/zypp/PublicKey.cc (original)
+++ trunk/libzypp/zypp/PublicKey.cc Tue Apr 22 11:57:59 2008
@@ -11,8 +11,6 @@
*/
#include <iostream>
-#include
-
//#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
@@ -168,7 +166,7 @@
_id = what[5];
_name = what[10];
//replace all escaped semicolon with real
- boost::replace_all(_name,"\\x3a",":");
+ str::replace_all(_name,"\\x3a",":");
_created = createDate(what[6]);
_expires = createDate(what[7]);
Modified: trunk/libzypp/zypp/base/String.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/String.cc?rev=9772&r1=9771&r2=9772&view=diff
==============================================================================
--- trunk/libzypp/zypp/base/String.cc (original)
+++ trunk/libzypp/zypp/base/String.cc Tue Apr 22 11:57:59 2008
@@ -207,9 +207,24 @@
}
}
+
return sNew;
}
+ string & replace_all(string & str, const string & from, const string & to)
+ {
+ string::size_type pos = 0;
+ while((pos = str.find(from, pos)) != string::npos)
+ {
+ str.replace(pos, from.size(), to);
+ pos += to.size();
+
+ if (pos >= str.length())
+ break;
+ }
+ return str;
+ }
+
/******************************************************************
**
**
Modified: trunk/libzypp/zypp/base/String.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/String.h?rev=9772&r1=9771&r2=9772&view=diff
==============================================================================
--- trunk/libzypp/zypp/base/String.h (original)
+++ trunk/libzypp/zypp/base/String.h Tue Apr 22 11:57:59 2008
@@ -16,8 +16,6 @@
#include <string>
#include
-#include
-
#include "zypp/base/PtrTypes.h"
///////////////////////////////////////////////////////////////////
@@ -287,6 +285,22 @@
{ return( default_r ? strToFalse( str ) : strToTrue( str ) ); }
//@}
+ /**
+ * \short Looks for text in a string and replaces it.
+ *
+ * \note It only perform substtution in one pass
+ */
+ std::string gsub( const std::string& sData, const std::string& sFrom, const std::string& sTo);
+
+ /**
+ * \short Looks for text in string and replaces it in place
+ *
+ *
+ * \note It only perform substtution in one pass
+ * \note use only if you replace same lenght strings, otherwise use gsub
+ */
+ std::string& replace_all( std::string & str, const std::string & from, const std::string & to);
+
///////////////////////////////////////////////////////////////////
/** \name Split. */
//@{
@@ -381,11 +395,11 @@
std::string s( beg+1, cur-beg-2 ); //without quotes
//transform escaped escape
- boost::replace_all( s, "\\\\", "\\" );
+ replace_all( s, "\\\\", "\\" );
//transform escaped quotes (only same as open
char tmpn[2] = { closeChar, 0 };
char tmpo[3] = { '\\', closeChar, 0 };
- boost::replace_all( s, tmpo, tmpn );
+ replace_all( s, tmpo, tmpn );
*result_r = s;
}
@@ -404,7 +418,7 @@
// build string
std::string s( beg, cur-beg );
//transform escaped escape
- boost::replace_all( s, "\\\\", "\\" );
+ replace_all( s, "\\\\", "\\" );
const char *delimeter = sepchars_r;
while ( *delimeter )
@@ -413,7 +427,7 @@
const char tmp[2] = { *delimeter, '\0' };
std::string del(tmp);
ds+= del;
- boost::replace_all( s, ds, del );
+ replace_all( s, ds, del );
++delimeter;
}
@@ -516,14 +530,6 @@
inline bool endsWith(const std::string& s, const char* str) { return s.find(str) == s.size() - strlen(str); }
inline bool contains(const std::string& s, const char* str) { return s.find(str) != std::string::npos; }
- /**
- * \short Looks for text in a string and replaces it.
- *
- * \note It only perform substtution in one pass
- */
- std::string gsub( const std::string& sData, const std::string& sFrom, const std::string& sTo);
-
-
///////////////////////////////////////////////////////////////////
/** \name String prefix handling.
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org