summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-08-10 23:34:45 +0200
committerHenning Baldersheim <balder@oath.com>2018-08-10 23:34:45 +0200
commit6ecf0ff7e093eae86292c283bf586c405a557659 (patch)
treedc45738bead7ad07399324f255e2a0dbd38e5fcf /vespalib
parent86139ca05e67c56dfdee0399c4ebc157903f47ea (diff)
Pass stringref by value
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/data/memory.h2
-rw-r--r--vespalib/src/vespa/vespalib/io/fileutil.h2
-rw-r--r--vespalib/src/vespa/vespalib/objects/nbostream.h2
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.h8
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hash_fun.h2
-rw-r--r--vespalib/src/vespa/vespalib/stllike/string.cpp30
-rw-r--r--vespalib/src/vespa/vespalib/stllike/string.h94
-rw-r--r--vespalib/src/vespa/vespalib/stllike/string.hpp30
-rw-r--r--vespalib/src/vespa/vespalib/text/lowercase.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/text/lowercase.h2
-rw-r--r--vespalib/src/vespa/vespalib/text/stringtokenizer.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/text/stringtokenizer.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/exception.h8
-rw-r--r--vespalib/src/vespa/vespalib/util/regexp.cpp20
-rw-r--r--vespalib/src/vespa/vespalib/util/regexp.h16
16 files changed, 116 insertions, 116 deletions
diff --git a/vespalib/src/vespa/vespalib/data/memory.h b/vespalib/src/vespa/vespalib/data/memory.h
index eae7c8d2f23..07767180b57 100644
--- a/vespalib/src/vespa/vespalib/data/memory.h
+++ b/vespalib/src/vespa/vespalib/data/memory.h
@@ -22,7 +22,7 @@ struct Memory
: data(str.data()), size(str.size()) {}
Memory(const vespalib::string &str)
: data(str.data()), size(str.size()) {}
- Memory(const vespalib::stringref &str_ref)
+ Memory(vespalib::stringref str_ref)
: data(str_ref.data()), size(str_ref.size()) {}
vespalib::string make_string() const;
vespalib::stringref make_stringref() const { return stringref(data, size); }
diff --git a/vespalib/src/vespa/vespalib/io/fileutil.h b/vespalib/src/vespa/vespalib/io/fileutil.h
index 1b493a9ebf1..9d7e64788a0 100644
--- a/vespalib/src/vespa/vespalib/io/fileutil.h
+++ b/vespalib/src/vespa/vespalib/io/fileutil.h
@@ -218,7 +218,7 @@ class LazyFile : public File {
public:
typedef std::unique_ptr<LazyFile> UP;
- LazyFile(const vespalib::stringref & filename, int flags,
+ LazyFile(vespalib::stringref filename, int flags,
bool autoCreateDirs = false)
: File(filename),
_flags(flags),
diff --git a/vespalib/src/vespa/vespalib/objects/nbostream.h b/vespalib/src/vespa/vespalib/objects/nbostream.h
index c3127e06133..8942004fadf 100644
--- a/vespalib/src/vespa/vespalib/objects/nbostream.h
+++ b/vespalib/src/vespa/vespalib/objects/nbostream.h
@@ -71,7 +71,7 @@ public:
return *this;
}
nbostream & operator << (const char * v) { uint32_t sz(strlen(v)); (*this) << sz; write(v, sz); return *this; }
- nbostream & operator << (const vespalib::stringref & v) { uint32_t sz(v.size()); (*this) << sz; write(v.data(), sz); return *this; }
+ nbostream & operator << (vespalib::stringref v) { uint32_t sz(v.size()); (*this) << sz; write(v.data(), sz); return *this; }
nbostream & operator << (const vespalib::string & v) { uint32_t sz(v.size()); (*this) << sz; write(v.c_str(), sz); return *this; }
nbostream & operator >> (vespalib::string & v) {
uint32_t sz; (*this) >> sz;
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
index 7e8570b3d61..9b2cdad822a 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
@@ -59,7 +59,7 @@ asciistream::asciistream() :
_precision(6)
{ }
-asciistream::asciistream(const stringref & buf) :
+asciistream::asciistream(stringref buf) :
_rPos(0),
_wbuf(),
_rbuf(buf),
@@ -555,7 +555,7 @@ string asciistream::getline(char delim)
return line;
}
-asciistream asciistream::createFromFile(const stringref & fileName)
+asciistream asciistream::createFromFile(stringref fileName)
{
FastOS_File file(vespalib::string(fileName).c_str());
asciistream is;
@@ -576,7 +576,7 @@ asciistream asciistream::createFromFile(const stringref & fileName)
return is;
}
-asciistream asciistream::createFromDevice(const stringref & fileName)
+asciistream asciistream::createFromDevice(stringref fileName)
{
FastOS_File file(vespalib::string(fileName).c_str());
asciistream is;
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.h b/vespalib/src/vespa/vespalib/stllike/asciistream.h
index 9dd73706d0a..80523d5133d 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.h
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.h
@@ -31,7 +31,7 @@ class asciistream
{
public:
asciistream();
- asciistream(const stringref & buf);
+ asciistream(stringref buf);
~asciistream();
asciistream(const asciistream & rhs);
asciistream & operator = (const asciistream & rhs);
@@ -43,7 +43,7 @@ public:
asciistream & operator << (unsigned char v) { doFill(1); write(&v, 1); return *this; }
asciistream & operator << (const char * v) { if (v != nullptr) { size_t n(strlen(v)); doFill(n); write(v, n); } return *this; }
asciistream & operator << (const string & v) { doFill(v.size()); write(v.data(), v.size()); return *this; }
- asciistream & operator << (const stringref & v) { doFill(v.size()); write(v.data(), v.size()); return *this; }
+ asciistream & operator << (stringref v) { doFill(v.size()); write(v.data(), v.size()); return *this; }
asciistream & operator << (const std::string & v) { doFill(v.size()); write(v.data(), v.size()); return *this; }
asciistream & operator << (int16_t v) { return *this << static_cast<int64_t>(v); }
asciistream & operator << (uint16_t v) { return *this << static_cast<uint64_t>(v); }
@@ -144,8 +144,8 @@ public:
asciistream & operator << (Precision v);
asciistream & operator >> (Precision v);
void eatWhite();
- static asciistream createFromFile(const vespalib::stringref & fileName);
- static asciistream createFromDevice(const vespalib::stringref & fileName);
+ static asciistream createFromFile(stringref fileName);
+ static asciistream createFromDevice(stringref fileName);
string getline(char delim='\n');
std::vector<string> getlines(char delim='\n');
char getFill() const noexcept { return _fill; }
diff --git a/vespalib/src/vespa/vespalib/stllike/hash_fun.h b/vespalib/src/vespa/vespalib/stllike/hash_fun.h
index 7d7be666136..5686871b91a 100644
--- a/vespalib/src/vespa/vespalib/stllike/hash_fun.h
+++ b/vespalib/src/vespa/vespalib/stllike/hash_fun.h
@@ -67,7 +67,7 @@ template<> struct hash<const char *> {
};
template<> struct hash<vespalib::stringref> {
- size_t operator() (const vespalib::stringref & arg) const { return hashValue(arg.data(), arg.size()); }
+ size_t operator() (vespalib::stringref arg) const { return hashValue(arg.data(), arg.size()); }
};
template<> struct hash<vespalib::string> {
diff --git a/vespalib/src/vespa/vespalib/stllike/string.cpp b/vespalib/src/vespa/vespalib/stllike/string.cpp
index 47d424e93aa..9001901bfd2 100644
--- a/vespalib/src/vespa/vespalib/stllike/string.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/string.cpp
@@ -30,7 +30,7 @@ stringref::rfind(const char * s, size_type e) const {
}
stringref::size_type
-stringref::find(const stringref & s, size_type start) const {
+stringref::find(stringref s, size_type start) const {
const char *buf = begin()+start;
const char *e = end() - s.size();
while (buf <= e) {
@@ -45,7 +45,7 @@ stringref::find(const stringref & s, size_type start) const {
return npos;
}
-std::ostream & operator << (std::ostream & os, const stringref & v)
+std::ostream & operator << (std::ostream & os, stringref v)
{
return os.write(v.data(), v.size());
}
@@ -65,29 +65,29 @@ std::istream & operator >> (std::istream & is, small_string<SS> & v)
return is;
}
-template std::ostream & operator << (std::ostream & os, const vespalib::string & v);
-template std::istream & operator >> (std::istream & is, vespalib::string & v);
+template std::ostream & operator << (std::ostream & os, const string & v);
+template std::istream & operator >> (std::istream & is, string & v);
-vespalib::string
-operator + (const vespalib::stringref & a, const char * b)
+string
+operator + (stringref a, const char * b)
{
- vespalib::string t(a);
+ string t(a);
t += b;
return t;
}
-vespalib::string
-operator + (const char * a, const vespalib::stringref & b)
+string
+operator + (const char * a, stringref b)
{
- vespalib::string t(a);
+ string t(a);
t += b;
return t;
}
-vespalib::string
-operator + (const vespalib::stringref & a, const vespalib::stringref & b)
+string
+operator + (stringref a, stringref b)
{
- vespalib::string t(a);
+ string t(a);
t += b;
return t;
}
@@ -95,8 +95,8 @@ operator + (const vespalib::stringref & a, const vespalib::stringref & b)
template class small_string<48>;
template string operator + (const string & a, const string & b);
-template string operator + (const string & a, const stringref & b);
-template string operator + (const stringref & a, const string & b);
+template string operator + (const string & a, stringref b);
+template string operator + (stringref a, const string & b);
template string operator + (const string & a, const char * b);
template string operator + (const char * a, const string & b);
diff --git a/vespalib/src/vespa/vespalib/stllike/string.h b/vespalib/src/vespa/vespalib/stllike/string.h
index 98ed0929a9b..7fe18285966 100644
--- a/vespalib/src/vespa/vespalib/stllike/string.h
+++ b/vespalib/src/vespa/vespalib/stllike/string.h
@@ -32,7 +32,7 @@ public:
* Note that the data may not be zero terminated, and a default
* constructed stringref will give a NULL pointer back. If you
* need to make sure data() gives a valid zero-terminated string
- * you should make a vespalib::string from the stringref.
+ * you should make a string from the stringref.
**/
const char * data() const { return _s; }
@@ -71,7 +71,7 @@ public:
* @return index from the start of the string at which the character
* was found, or npos if the character could not be located
*/
- size_type find(const stringref & s, size_type start=0) const;
+ size_type find(stringref s, size_type start=0) const;
/**
* Find the first occurrence of a character, searching from @c start
*
@@ -116,7 +116,7 @@ public:
* was found, or npos if the substring could not be located
*/
size_type rfind(const char * s, size_type e=npos) const;
- int compare(const stringref & s) const { return compare(s.data(), s.size()); }
+ int compare(stringref s) const { return compare(s.data(), s.size()); }
int compare(const char *s, size_type sz) const {
int diff(memcmp(_s, s, std::min(sz, size())));
return (diff != 0) ? diff : (size() - sz);
@@ -125,28 +125,28 @@ public:
operator std::string () const { return std::string(_s, _sz); }
bool operator < (const char * s) const { return compare(s, strlen(s)) < 0; }
bool operator < (const std::string & s) const { return compare(s.data(), s.size()) < 0; }
- bool operator < (const stringref & s) const { return compare(s.data(), s.size()) < 0; }
+ bool operator < (stringref s) const { return compare(s.data(), s.size()) < 0; }
bool operator <= (const char * s) const { return compare(s, strlen(s)) <= 0; }
bool operator <= (const std::string & s) const { return compare(s.data(), s.size()) <= 0; }
- bool operator <= (const stringref & s) const { return compare(s.data(), s.size()) <= 0; }
+ bool operator <= (stringref s) const { return compare(s.data(), s.size()) <= 0; }
bool operator != (const char * s) const { return compare(s, strlen(s)) != 0; }
bool operator != (const std::string & s) const { return compare(s.data(), s.size()) != 0; }
- bool operator != (const stringref & s) const { return compare(s.data(), s.size()) != 0; }
+ bool operator != (stringref s) const { return compare(s.data(), s.size()) != 0; }
bool operator == (const char * s) const { return compare(s, strlen(s)) == 0; }
bool operator == (const std::string & s) const { return compare(s.data(), s.size()) == 0; }
- bool operator == (const stringref & s) const { return compare(s.data(), s.size()) == 0; }
+ bool operator == (stringref s) const { return compare(s.data(), s.size()) == 0; }
bool operator >= (const char * s) const { return compare(s, strlen(s)) >= 0; }
bool operator >= (const std::string & s) const { return compare(s.data(), s.size()) >= 0; }
- bool operator >= (const stringref & s) const { return compare(s.data(), s.size()) >= 0; }
+ bool operator >= (stringref s) const { return compare(s.data(), s.size()) >= 0; }
bool operator > (const char * s) const { return compare(s, strlen(s)) > 0; }
bool operator > (const std::string & s) const { return compare(s.data(), s.size()) > 0; }
- bool operator > (const stringref & s) const { return compare(s.data(), s.size()) > 0; }
+ bool operator > (stringref s) const { return compare(s.data(), s.size()) > 0; }
private:
const char *_s;
size_type _sz;
- friend bool operator == (const std::string & a, const stringref & b) { return b == a; }
- friend bool operator != (const std::string & a, const stringref & b) { return b != a; }
- friend std::ostream & operator << (std::ostream & os, const stringref & v);
+ friend bool operator == (const std::string & a, stringref b) { return b == a; }
+ friend bool operator != (const std::string & a, stringref b) { return b != a; }
+ friend std::ostream & operator << (std::ostream & os, stringref v);
};
@@ -175,7 +175,7 @@ public:
small_string() : _buf(_stack), _sz(0), _bufferSize(StackSize) { _stack[0] = '\0'; }
small_string(const char * s) : _buf(_stack), _sz(s ? strlen(s) : 0) { init(s); }
small_string(const void * s, size_type sz) : _buf(_stack), _sz(sz) { init(s); }
- small_string(const stringref & s) : _buf(_stack), _sz(s.size()) { init(s.data()); }
+ small_string(stringref s) : _buf(_stack), _sz(s.size()) { init(s.data()); }
small_string(const std::string & s) : _buf(_stack), _sz(s.size()) { init(s.data()); }
small_string(const small_string & rhs) noexcept : _buf(_stack), _sz(rhs.size()) { init(rhs.data()); }
small_string(const small_string & rhs, size_type pos, size_type sz=npos) noexcept
@@ -203,7 +203,7 @@ public:
small_string& operator= (const small_string &rhs) {
return assign(rhs.data(), rhs.size());
}
- small_string & operator= (const stringref &rhs) {
+ small_string & operator= (stringref rhs) {
return assign(rhs.data(), rhs.size());
}
small_string& operator= (const char *s) {
@@ -317,23 +317,23 @@ public:
}
small_string & assign(const char * s) { return assign(s, strlen(s)); }
small_string & assign(const void * s, size_type sz);
- small_string & assign(const stringref &s, size_type pos, size_type sz) {
+ small_string & assign(stringref s, size_type pos, size_type sz) {
return assign(s.data() + pos, sz);
}
- small_string & assign(const stringref &rhs) {
+ small_string & assign(stringref rhs) {
if (data() != rhs.data()) assign(rhs.data(), rhs.size());
return *this;
}
small_string & push_back(char c) { return append(&c, 1); }
small_string & append(char c) { return append(&c, 1); }
small_string & append(const char * s) { return append(s, strlen(s)); }
- small_string & append(const stringref & s) { return append(s.data(), s.size()); }
+ small_string & append(stringref s) { return append(s.data(), s.size()); }
small_string & append(const std::string & s) { return append(s.data(), s.size()); }
small_string & append(const small_string & s) { return append(s.data(), s.size()); }
small_string & append(const void * s, size_type sz);
small_string & operator += (char c) { return append(c); }
small_string & operator += (const char * s) { return append(s); }
- small_string & operator += (const stringref & s) { return append(s); }
+ small_string & operator += (stringref s) { return append(s); }
small_string & operator += (const std::string & s) { return append(s); }
small_string & operator += (const small_string & s) { return append(s); }
@@ -355,7 +355,7 @@ public:
}
small_string & insert(iterator p, const_iterator f, const_iterator l) { return insert(p-c_str(), f, l-f); }
- small_string & insert(size_type start, const stringref & v) { return insert(start, v.data(), v.size()); }
+ small_string & insert(size_type start, stringref v) { return insert(start, v.data(), v.size()); }
small_string & insert(size_type start, const void * v, size_type sz);
/**
@@ -446,27 +446,27 @@ public:
bool operator < (const char * s) const { return compare(s, strlen(s)) < 0; }
bool operator < (const std::string & s) const { return compare(s.data(), s.size()) < 0; }
bool operator < (const small_string & s) const { return compare(s.data(), s.size()) < 0; }
- bool operator < (const stringref & s) const { return compare(s.data(), s.size()) < 0; }
+ bool operator < (stringref s) const { return compare(s.data(), s.size()) < 0; }
bool operator <= (const char * s) const { return compare(s, strlen(s)) <= 0; }
bool operator <= (const std::string & s) const { return compare(s.data(), s.size()) <= 0; }
bool operator <= (const small_string & s) const { return compare(s.data(), s.size()) <= 0; }
- bool operator <= (const stringref & s) const { return compare(s.data(), s.size()) <= 0; }
+ bool operator <= (stringref s) const { return compare(s.data(), s.size()) <= 0; }
bool operator == (const char * s) const { return compare(s, strlen(s)) == 0; }
bool operator == (const std::string & s) const { return compare(s.data(), s.size()) == 0; }
bool operator == (const small_string & s) const { return compare(s.data(), s.size()) == 0; }
- bool operator == (const stringref & s) const { return compare(s.data(), s.size()) == 0; }
+ bool operator == (stringref s) const { return compare(s.data(), s.size()) == 0; }
bool operator != (const char * s) const { return compare(s, strlen(s)) != 0; }
bool operator != (const std::string & s) const { return compare(s.data(), s.size()) != 0; }
bool operator != (const small_string & s) const { return compare(s.data(), s.size()) != 0; }
- bool operator != (const stringref & s) const { return compare(s.data(), s.size()) != 0; }
+ bool operator != (stringref s) const { return compare(s.data(), s.size()) != 0; }
bool operator >= (const char * s) const { return compare(s, strlen(s)) >= 0; }
bool operator >= (const std::string & s) const { return compare(s.data(), s.size()) >= 0; }
bool operator >= (const small_string & s) const { return compare(s.data(), s.size()) >= 0; }
- bool operator >= (const stringref & s) const { return compare(s.data(), s.size()) >= 0; }
+ bool operator >= (stringref s) const { return compare(s.data(), s.size()) >= 0; }
bool operator > (const char * s) const { return compare(s, strlen(s)) > 0; }
bool operator > (const std::string & s) const { return compare(s.data(), s.size()) > 0; }
bool operator > (const small_string & s) const { return compare(s.data(), s.size()) > 0; }
- bool operator > (const stringref & s) const { return compare(s.data(), s.size()) > 0; }
+ bool operator > (stringref s) const { return compare(s.data(), s.size()) > 0; }
template<typename T> bool operator != (const T& s) const { return ! operator == (s); }
@@ -572,62 +572,62 @@ const size_t small_string<StackSize>::npos;
typedef small_string<48> string;
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const vespalib::small_string<StackSize> & b);
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, const small_string<StackSize> & b);
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const vespalib::stringref & b);
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, stringref b);
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::stringref & a, const vespalib::small_string<StackSize> & b);
+small_string<StackSize>
+operator + (stringref a, const small_string<StackSize> & b);
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const char * b);
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, const char * b);
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const char * a, const vespalib::small_string<StackSize> & b);
+small_string<StackSize>
+operator + (const char * a, const small_string<StackSize> & b);
template<typename T, uint32_t StackSize>
bool
-operator == (const T& a, const vespalib::small_string<StackSize>& b)
+operator == (const T& a, const small_string<StackSize>& b)
{
return b == a;
}
template<typename T, uint32_t StackSize>
bool
-operator != (const T& a, const vespalib::small_string<StackSize>& b)
+operator != (const T& a, const small_string<StackSize>& b)
{
return b != a;
}
template<typename T, uint32_t StackSize>
bool
-operator < (const T& a, const vespalib::small_string<StackSize>& b)
+operator < (const T& a, const small_string<StackSize>& b)
{
return b > a;
}
-vespalib::string operator + (const vespalib::stringref & a, const vespalib::stringref & b);
-vespalib::string operator + (const char * a, const vespalib::stringref & b);
-vespalib::string operator + (const vespalib::stringref & a, const char * b);
+string operator + (stringref a, stringref b);
+string operator + (const char * a, stringref b);
+string operator + (stringref a, const char * b);
-inline bool contains(const stringref & text, const stringref & key) {
+inline bool contains(stringref text, stringref key) {
return text.find(key) != stringref::npos;
}
-inline bool starts_with(const stringref & text, const stringref & key) {
+inline bool starts_with(stringref text, stringref key) {
if (text.size() >= key.size()) {
return memcmp(text.begin(), key.begin(), key.size()) == 0;
}
return false;
}
-inline bool ends_with(const stringref & text, const stringref & key) {
+inline bool ends_with(stringref text, stringref key) {
if (text.size() >= key.size()) {
return memcmp(text.end()-key.size(), key.begin(), key.size()) == 0;
}
@@ -636,9 +636,9 @@ inline bool ends_with(const stringref & text, const stringref & key) {
/**
* Utility function to format an unsigned integer into a new
- * vespalib::string instance.
+ * string instance.
**/
-static inline vespalib::string stringify(uint64_t number)
+static inline string stringify(uint64_t number)
{
char digits[64];
int numdigits = 0;
@@ -646,7 +646,7 @@ static inline vespalib::string stringify(uint64_t number)
digits[numdigits++] = '0' + (number % 10);
number /= 10;
} while (number > 0);
- vespalib::string retval;
+ string retval;
while (numdigits > 0) {
retval.append(digits[--numdigits]);
}
diff --git a/vespalib/src/vespa/vespalib/stllike/string.hpp b/vespalib/src/vespa/vespalib/stllike/string.hpp
index 3ead42ee41e..7f4a0baa64a 100644
--- a/vespalib/src/vespa/vespalib/stllike/string.hpp
+++ b/vespalib/src/vespa/vespalib/stllike/string.hpp
@@ -156,46 +156,46 @@ small_string<StackSize>::append(const void * s, size_type addSz)
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const vespalib::small_string<StackSize> & b)
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, const small_string<StackSize> & b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const vespalib::stringref & b)
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, stringref b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::stringref & a, const vespalib::small_string<StackSize> & b)
+small_string<StackSize>
+operator + (stringref a, const small_string<StackSize> & b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const char * b)
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, const char * b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const char * a, const vespalib::small_string<StackSize> & b)
+small_string<StackSize>
+operator + (const char * a, const small_string<StackSize> & b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
diff --git a/vespalib/src/vespa/vespalib/text/lowercase.cpp b/vespalib/src/vespa/vespalib/text/lowercase.cpp
index bb0908b7158..f62433c8cda 100644
--- a/vespalib/src/vespa/vespalib/text/lowercase.cpp
+++ b/vespalib/src/vespa/vespalib/text/lowercase.cpp
@@ -6,7 +6,7 @@
namespace vespalib {
vespalib::string
-LowerCase::convert(const vespalib::stringref& input)
+LowerCase::convert(vespalib::stringref input)
{
vespalib::string output;
Utf8Reader r(input);
diff --git a/vespalib/src/vespa/vespalib/text/lowercase.h b/vespalib/src/vespa/vespalib/text/lowercase.h
index c69d37ce2ba..e628114c663 100644
--- a/vespalib/src/vespa/vespalib/text/lowercase.h
+++ b/vespalib/src/vespa/vespalib/text/lowercase.h
@@ -102,7 +102,7 @@ public:
* any bytes that aren't valid UTF-8 with the Unicode REPLACEMENT
* CHARACTER (U+FFFD).
**/
- static vespalib::string convert(const vespalib::stringref& input);
+ static vespalib::string convert(vespalib::stringref input);
};
diff --git a/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp b/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp
index b59101c8780..0e739d5b9b0 100644
--- a/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp
+++ b/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp
@@ -7,7 +7,7 @@ namespace {
class AsciiSet
{
public:
- AsciiSet(const vespalib::stringref & s) {
+ AsciiSet(vespalib::stringref s) {
memset(_set, 0, sizeof(_set));
for (size_t i(0), m(s.size()); i < m; i++) {
add(s[i]);
@@ -31,7 +31,7 @@ typedef vespalib::StringTokenizer::TokenList TokenList;
* strip leading and trailing sequences
* of characters contained in the strip set.
**/
-Token stripString(const vespalib::stringref & source,
+Token stripString(vespalib::stringref source,
const AsciiSet & strip)
{
Token::size_type start = 0;
@@ -66,7 +66,7 @@ void parse(TokenList& output,
namespace vespalib {
-StringTokenizer::StringTokenizer(const vespalib::stringref & source,
+StringTokenizer::StringTokenizer(vespalib::stringref source,
const vespalib::stringref & separators,
const vespalib::stringref & strip)
: _tokens()
diff --git a/vespalib/src/vespa/vespalib/text/stringtokenizer.h b/vespalib/src/vespa/vespalib/text/stringtokenizer.h
index 7a2fecc6469..a54bcc7997e 100644
--- a/vespalib/src/vespa/vespalib/text/stringtokenizer.h
+++ b/vespalib/src/vespa/vespalib/text/stringtokenizer.h
@@ -41,7 +41,7 @@ public:
* @param separators The characters to be used as token separators
* @param strip Characters to be stripped from both ends of each token
**/
- StringTokenizer(const vespalib::stringref & source,
+ StringTokenizer(vespalib::stringref source,
const vespalib::stringref & separators = ",",
const vespalib::stringref & strip = " \t\f\r\n");
diff --git a/vespalib/src/vespa/vespalib/util/exception.h b/vespalib/src/vespa/vespalib/util/exception.h
index ff5f02f33da..b3c63a17b3a 100644
--- a/vespalib/src/vespa/vespalib/util/exception.h
+++ b/vespalib/src/vespa/vespalib/util/exception.h
@@ -61,9 +61,9 @@
#define VESPA_DEFINE_EXCEPTION(MyClass, Parent) \
class MyClass : public Parent { \
public: \
- MyClass(const vespalib::stringref &msg, \
+ MyClass(vespalib::stringref msg, \
const vespalib::stringref &location = "", int skipStack = 0); \
- MyClass(const vespalib::stringref &msg, const Exception &cause, \
+ MyClass(vespalib::stringref msg, const Exception &cause, \
const vespalib::stringref &location = "", int skipStack = 0); \
VESPA_DEFINE_EXCEPTION_SPINE(MyClass) \
};
@@ -77,10 +77,10 @@ public: \
* @param MyClass the name of your class
**/
#define VESPA_IMPLEMENT_EXCEPTION(MyClass, Parent) \
- MyClass::MyClass(const vespalib::stringref &msg, \
+ MyClass::MyClass(vespalib::stringref msg, \
const vespalib::stringref &location, int skipStack) \
: Parent(msg, location, skipStack + 1) {} \
- MyClass::MyClass(const vespalib::stringref &msg, const Exception &cause, \
+ MyClass::MyClass(vespalib::stringref msg, const Exception &cause, \
const vespalib::stringref &location, int skipStack) \
: Parent(msg, cause, location, skipStack + 1) {} \
VESPA_IMPLEMENT_EXCEPTION_SPINE(MyClass)
diff --git a/vespalib/src/vespa/vespalib/util/regexp.cpp b/vespalib/src/vespa/vespalib/util/regexp.cpp
index e1aa4e9b189..7a400d1ca35 100644
--- a/vespalib/src/vespa/vespalib/util/regexp.cpp
+++ b/vespalib/src/vespa/vespalib/util/regexp.cpp
@@ -24,7 +24,7 @@ Regexp::Flags::enableICASE()
}
bool
-Regexp::compile(const vespalib::stringref & re, Flags flags)
+Regexp::compile(vespalib::stringref re, Flags flags)
{
re_set_syntax(flags.flags());
regex_t *preg = (regex_t *)_data;
@@ -45,7 +45,7 @@ Regexp::compile(const vespalib::stringref & re, Flags flags)
}
-Regexp::Regexp(const vespalib::stringref & re, Flags flags)
+Regexp::Regexp(vespalib::stringref re, Flags flags)
: _valid(false),
_data(new regex_t)
{
@@ -53,7 +53,7 @@ Regexp::Regexp(const vespalib::stringref & re, Flags flags)
}
bool
-Regexp::match(const vespalib::stringref & s) const
+Regexp::match(vespalib::stringref s) const
{
if ( ! valid() ) { return false; }
regex_t *preg = const_cast<regex_t *>(static_cast<const regex_t *>(_data));
@@ -64,7 +64,7 @@ Regexp::match(const vespalib::stringref & s) const
return pos >= 0;
}
-vespalib::string Regexp::replace(const vespalib::stringref & s, const vespalib::stringref & replacement) const
+vespalib::string Regexp::replace(vespalib::stringref s, const vespalib::stringref & replacement) const
{
if ( ! valid() ) { return s; }
regex_t *preg = const_cast<regex_t *>(static_cast<const regex_t *>(_data));
@@ -92,7 +92,7 @@ Regexp::~Regexp()
namespace {
-bool has_option(const vespalib::stringref & re) {
+bool has_option(vespalib::stringref re) {
return (re.find('|') != re.npos);
}
@@ -105,7 +105,7 @@ bool maybe_none(char c) {
const vespalib::string special("^|()[]{}.*?+\\$");
bool is_special(char c) { return special.find(c) != special.npos; }
-vespalib::string escape(const vespalib::stringref &str) {
+vespalib::string escape(vespalib::stringref str) {
vespalib::string result;
for (char c: str) {
if (is_special(c)) {
@@ -119,7 +119,7 @@ vespalib::string escape(const vespalib::stringref &str) {
} // namespace vespalib::<unnamed>
vespalib::string
-Regexp::get_prefix(const vespalib::stringref & re)
+Regexp::get_prefix(vespalib::stringref re)
{
vespalib::string prefix;
if ((re.size() > 0) && (re.data()[0] == '^') && !has_option(re)) {
@@ -136,19 +136,19 @@ Regexp::get_prefix(const vespalib::stringref & re)
}
vespalib::string
-Regexp::make_from_prefix(const vespalib::stringref &prefix)
+Regexp::make_from_prefix(vespalib::stringref prefix)
{
return "^" + escape(prefix);
}
vespalib::string
-Regexp::make_from_suffix(const vespalib::stringref &suffix)
+Regexp::make_from_suffix(vespalib::stringref suffix)
{
return escape(suffix) + "$";
}
vespalib::string
-Regexp::make_from_substring(const vespalib::stringref &substring)
+Regexp::make_from_substring(vespalib::stringref substring)
{
return escape(substring);
}
diff --git a/vespalib/src/vespa/vespalib/util/regexp.h b/vespalib/src/vespa/vespalib/util/regexp.h
index 31db95c5d7e..42dbf3872ad 100644
--- a/vespalib/src/vespa/vespalib/util/regexp.h
+++ b/vespalib/src/vespa/vespalib/util/regexp.h
@@ -38,7 +38,7 @@ public:
* @throw IllegalArgumentException if the RE is invalid.
* @param re Regular expression.
**/
- Regexp(const vespalib::stringref & re, Flags=Flags());
+ Regexp(vespalib::stringref re, Flags=Flags());
~Regexp();
@@ -54,7 +54,7 @@ public:
* @param s text to search for a match.
* @return true if a match was found.
**/
- bool match(const vespalib::stringref & s) const;
+ bool match(vespalib::stringref s) const;
/**
* Will replace all occurrences of this pattern is string 's' with 'replacement'.
@@ -63,7 +63,7 @@ public:
* @param replacement text to replace the pattern.
* @return modified string.
**/
- vespalib::string replace(const vespalib::stringref & s, const vespalib::stringref & replacement) const;
+ vespalib::string replace(vespalib::stringref s, const vespalib::stringref & replacement) const;
/**
* Look at the given regular expression and identify the prefix
@@ -75,7 +75,7 @@ public:
* @param re Regular expression.
* @return prefix that must be present in matching strings
**/
- static vespalib::string get_prefix(const vespalib::stringref & re);
+ static vespalib::string get_prefix(vespalib::stringref re);
/**
* Make a regexp matching strings with the given prefix.
@@ -83,7 +83,7 @@ public:
* @param prefix the prefix
* @return the regexp
**/
- static vespalib::string make_from_prefix(const vespalib::stringref &prefix);
+ static vespalib::string make_from_prefix(vespalib::stringref prefix);
/**
* Make a regexp matching strings with the given suffix.
@@ -91,7 +91,7 @@ public:
* @param suffix the suffix
* @return the regexp
**/
- static vespalib::string make_from_suffix(const vespalib::stringref &suffix);
+ static vespalib::string make_from_suffix(vespalib::stringref suffix);
/**
* Make a regexp matching strings with the given substring.
@@ -99,12 +99,12 @@ public:
* @param substring the substring
* @return the regexp
**/
- static vespalib::string make_from_substring(const vespalib::stringref &substring);
+ static vespalib::string make_from_substring(vespalib::stringref substring);
private:
bool _valid;
void *_data;
- bool compile(const vespalib::stringref & re, Flags flags);
+ bool compile(vespalib::stringref re, Flags flags);
};
} // namespace vespalib