summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-08-11 00:35:43 +0200
committerHenning Baldersheim <balder@oath.com>2018-08-11 00:35:43 +0200
commitbb54ccd7a3422f9f3835d71dc71bded0a766fd88 (patch)
tree2beda45dfa7cfc3fdb8ae198a171e2ab48083a0e /vespalib
parente198573919f269bf62bb7ff22c0fb5797375ef9c (diff)
Pass stringref by value
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/component/version.cpp4
-rw-r--r--vespalib/src/vespa/vespalib/text/stringtokenizer.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/text/stringtokenizer.h4
-rw-r--r--vespalib/src/vespa/vespalib/text/utf8.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/exception.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/util/exception.h14
-rw-r--r--vespalib/src/vespa/vespalib/util/exceptions.cpp26
-rw-r--r--vespalib/src/vespa/vespalib/util/exceptions.h22
-rw-r--r--vespalib/src/vespa/vespalib/util/regexp.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/util/regexp.h2
10 files changed, 41 insertions, 47 deletions
diff --git a/vespalib/src/vespa/vespalib/component/version.cpp b/vespalib/src/vespa/vespalib/component/version.cpp
index 3aa8e134e36..fc7ee703e7f 100644
--- a/vespalib/src/vespa/vespalib/component/version.cpp
+++ b/vespalib/src/vespa/vespalib/component/version.cpp
@@ -63,8 +63,8 @@ Version::verifySanity()
}
// Precondition: input.empty() == false
-static int parseInteger(const stringref & input) __attribute__((noinline));
-static int parseInteger(const stringref & input)
+static int parseInteger(stringref input) __attribute__((noinline));
+static int parseInteger(stringref input)
{
const char *s = input.data();
unsigned char firstDigit = s[0];
diff --git a/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp b/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp
index 0e739d5b9b0..0191fdf7929 100644
--- a/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp
+++ b/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp
@@ -46,7 +46,7 @@ Token stripString(vespalib::stringref source,
}
void parse(TokenList& output,
- const vespalib::stringref & source,
+ vespalib::stringref source,
const AsciiSet & separators,
const AsciiSet & strip)
{
@@ -67,8 +67,8 @@ void parse(TokenList& output,
namespace vespalib {
StringTokenizer::StringTokenizer(vespalib::stringref source,
- const vespalib::stringref & separators,
- const vespalib::stringref & strip)
+ vespalib::stringref separators,
+ vespalib::stringref strip)
: _tokens()
{
AsciiSet sep(separators);
diff --git a/vespalib/src/vespa/vespalib/text/stringtokenizer.h b/vespalib/src/vespa/vespalib/text/stringtokenizer.h
index a54bcc7997e..5375a251b1b 100644
--- a/vespalib/src/vespa/vespalib/text/stringtokenizer.h
+++ b/vespalib/src/vespa/vespalib/text/stringtokenizer.h
@@ -42,8 +42,8 @@ public:
* @param strip Characters to be stripped from both ends of each token
**/
StringTokenizer(vespalib::stringref source,
- const vespalib::stringref & separators = ",",
- const vespalib::stringref & strip = " \t\f\r\n");
+ vespalib::stringref separators = ",",
+ vespalib::stringref strip = " \t\f\r\n");
/** Remove any empty tokens from the token list */
void removeEmptyTokens();
diff --git a/vespalib/src/vespa/vespalib/text/utf8.h b/vespalib/src/vespa/vespalib/text/utf8.h
index 6a25ef4f21e..0c75203fbbe 100644
--- a/vespalib/src/vespa/vespalib/text/utf8.h
+++ b/vespalib/src/vespa/vespalib/text/utf8.h
@@ -176,7 +176,7 @@ public:
* Construct a reader for the given block of data
* @param input data to read UTF-8 from (can be read-only)
**/
- Utf8Reader(const stringref &input)
+ Utf8Reader(stringref input)
: stringref(input), _pos(0)
{}
diff --git a/vespalib/src/vespa/vespalib/util/exception.cpp b/vespalib/src/vespa/vespalib/util/exception.cpp
index fc2edda0c54..318b167d27b 100644
--- a/vespalib/src/vespa/vespalib/util/exception.cpp
+++ b/vespalib/src/vespa/vespalib/util/exception.cpp
@@ -58,7 +58,7 @@ swap(ExceptionPtr &a, ExceptionPtr &b)
//-----------------------------------------------------------------------------
-Exception::Exception(const stringref &msg, const stringref &location,
+Exception::Exception(stringref msg, stringref location,
int skipStack)
: _what(),
_msg(msg),
@@ -69,8 +69,8 @@ Exception::Exception(const stringref &msg, const stringref &location,
{
}
-Exception::Exception(const stringref &msg, const Exception &cause,
- const stringref &location, int skipStack)
+Exception::Exception(stringref msg, const Exception &cause,
+ stringref location, int skipStack)
: _what(),
_msg(msg),
_location(location),
diff --git a/vespalib/src/vespa/vespalib/util/exception.h b/vespalib/src/vespa/vespalib/util/exception.h
index b3c63a17b3a..097ecc131c7 100644
--- a/vespalib/src/vespa/vespalib/util/exception.h
+++ b/vespalib/src/vespa/vespalib/util/exception.h
@@ -62,9 +62,9 @@
class MyClass : public Parent { \
public: \
MyClass(vespalib::stringref msg, \
- const vespalib::stringref &location = "", int skipStack = 0); \
+ vespalib::stringref location = "", int skipStack = 0); \
MyClass(vespalib::stringref msg, const Exception &cause, \
- const vespalib::stringref &location = "", int skipStack = 0); \
+ vespalib::stringref location = "", int skipStack = 0); \
VESPA_DEFINE_EXCEPTION_SPINE(MyClass) \
};
@@ -78,10 +78,10 @@ public: \
**/
#define VESPA_IMPLEMENT_EXCEPTION(MyClass, Parent) \
MyClass::MyClass(vespalib::stringref msg, \
- const vespalib::stringref &location, int skipStack) \
+ vespalib::stringref location, int skipStack) \
: Parent(msg, location, skipStack + 1) {} \
MyClass::MyClass(vespalib::stringref msg, const Exception &cause, \
- const vespalib::stringref &location, int skipStack) \
+ vespalib::stringref location, int skipStack) \
: Parent(msg, cause, location, skipStack + 1) {} \
VESPA_IMPLEMENT_EXCEPTION_SPINE(MyClass)
@@ -186,7 +186,7 @@ public:
* should send (skipStack + 1) to the parent constructor (see
* \ref VESPA_DEFINE_EXCEPTION for subclass implementation).
**/
- Exception(const stringref &msg, const stringref& location = "", int skipStack = 0);
+ Exception(stringref msg, stringref location = "", int skipStack = 0);
/**
* @brief Construct an exception with a message, a causing exception, and a source code location.
* @param msg A user-readable message describing the problem
@@ -198,8 +198,8 @@ public:
* should send (skipStack + 1) to the parent constructor (see
* \ref VESPA_DEFINE_EXCEPTION for subclass implementation).
**/
- Exception(const stringref &msg, const Exception &cause,
- const stringref &location = "", int skipStack = 0);
+ Exception(stringref msg, const Exception &cause,
+ stringref location = "", int skipStack = 0);
Exception(const Exception &);
Exception & operator = (const Exception &);
Exception(Exception &&) = default;
diff --git a/vespalib/src/vespa/vespalib/util/exceptions.cpp b/vespalib/src/vespa/vespalib/util/exceptions.cpp
index fc64aa79ca4..cdfa91c25ac 100644
--- a/vespalib/src/vespa/vespalib/util/exceptions.cpp
+++ b/vespalib/src/vespa/vespalib/util/exceptions.cpp
@@ -70,27 +70,27 @@ SilenceUncaughtException::~SilenceUncaughtException()
}
vespalib::string
-PortListenException::make_message(int port, const vespalib::stringref &protocol,
- const vespalib::stringref &msg)
+PortListenException::make_message(int port, vespalib::stringref protocol,
+ vespalib::stringref msg)
{
return make_string("failed to listen on port %d with protocol %s%s%s",
port, vespalib::string(protocol).c_str(), msg.empty() ? "" : ": ",
vespalib::string(msg).c_str());
}
-PortListenException::PortListenException(int port, const vespalib::stringref &protocol,
- const vespalib::stringref &msg,
- const vespalib::stringref &location, int skipStack)
+PortListenException::PortListenException(int port, vespalib::stringref protocol,
+ vespalib::stringref msg,
+ vespalib::stringref location, int skipStack)
: Exception(make_message(port, protocol, msg), location, skipStack + 1),
_port(port),
_protocol(protocol)
{
}
-PortListenException::PortListenException(int port, const vespalib::stringref &protocol,
+PortListenException::PortListenException(int port, vespalib::stringref protocol,
const Exception &cause,
- const vespalib::stringref &msg,
- const vespalib::stringref &location, int skipStack)
+ vespalib::stringref msg,
+ vespalib::stringref location, int skipStack)
: Exception(make_message(port, protocol, msg), cause, location, skipStack + 1),
_port(port),
_protocol(protocol)
@@ -104,15 +104,15 @@ PortListenException::~PortListenException() {}
//-----------------------------------------------------------------------------
-IoException::IoException(const stringref & msg, Type type,
- const stringref & location, int skipStack)
+IoException::IoException(stringref msg, Type type,
+ stringref location, int skipStack)
: Exception(createMessage(msg, type), location, skipStack+1),
_type(type)
{
}
-IoException::IoException(const stringref & msg, Type type,
- const Exception& cause, const stringref & location,
+IoException::IoException(stringref msg, Type type,
+ const Exception& cause, stringref location,
int skipStack)
: Exception(createMessage(msg, type), cause, location, skipStack+1),
_type(type)
@@ -120,7 +120,7 @@ IoException::IoException(const stringref & msg, Type type,
}
string
-IoException::createMessage(const stringref & msg, Type type)
+IoException::createMessage(stringref msg, Type type)
{
vespalib::asciistream ost;
switch (type) {
diff --git a/vespalib/src/vespa/vespalib/util/exceptions.h b/vespalib/src/vespa/vespalib/util/exceptions.h
index 4349aaa8d78..452781b1afc 100644
--- a/vespalib/src/vespa/vespalib/util/exceptions.h
+++ b/vespalib/src/vespa/vespalib/util/exceptions.h
@@ -97,17 +97,13 @@ private:
int _port;
vespalib::string _protocol;
- vespalib::string make_message(int port, const vespalib::stringref &protocol,
- const vespalib::stringref &msg);
+ vespalib::string make_message(int port, vespalib::stringref protocol, vespalib::stringref msg);
public:
- PortListenException(int port, const vespalib::stringref &protocol,
- const vespalib::stringref &msg = "",
- const vespalib::stringref &location = "", int skipStack = 0);
- PortListenException(int port, const vespalib::stringref &protocol,
- const Exception &cause,
- const vespalib::stringref &msg = "",
- const vespalib::stringref &location = "", int skipStack = 0);
+ PortListenException(int port, vespalib::stringref protocol, vespalib::stringref msg = "",
+ vespalib::stringref location = "", int skipStack = 0);
+ PortListenException(int port, vespalib::stringref protocol, const Exception &cause, vespalib::stringref msg = "",
+ vespalib::stringref location = "", int skipStack = 0);
PortListenException(PortListenException &&) = default;
PortListenException & operator = (PortListenException &&) = default;
PortListenException(const PortListenException &);
@@ -131,14 +127,12 @@ public:
TOO_MANY_OPEN_FILES, DIRECTORY_HAVE_CONTENT, FILE_FULL,
ALREADY_EXISTS };
- IoException(const stringref & msg, Type type, const stringref & location,
- int skipStack = 0);
- IoException(const stringref & msg, Type type, const Exception& cause,
- const stringref & location, int skipStack = 0);
+ IoException(stringref msg, Type type, stringref location, int skipStack = 0);
+ IoException(stringref msg, Type type, const Exception& cause, stringref location, int skipStack = 0);
VESPA_DEFINE_EXCEPTION_SPINE(IoException);
- static string createMessage(const stringref & msg, Type type);
+ static string createMessage(stringref msg, Type type);
Type getType() const { return _type; }
diff --git a/vespalib/src/vespa/vespalib/util/regexp.cpp b/vespalib/src/vespa/vespalib/util/regexp.cpp
index 7a400d1ca35..85079383c8c 100644
--- a/vespalib/src/vespa/vespalib/util/regexp.cpp
+++ b/vespalib/src/vespa/vespalib/util/regexp.cpp
@@ -64,7 +64,7 @@ Regexp::match(vespalib::stringref s) const
return pos >= 0;
}
-vespalib::string Regexp::replace(vespalib::stringref s, const vespalib::stringref & replacement) const
+vespalib::string Regexp::replace(vespalib::stringref s, vespalib::stringref replacement) const
{
if ( ! valid() ) { return s; }
regex_t *preg = const_cast<regex_t *>(static_cast<const regex_t *>(_data));
diff --git a/vespalib/src/vespa/vespalib/util/regexp.h b/vespalib/src/vespa/vespalib/util/regexp.h
index 42dbf3872ad..c9500b39099 100644
--- a/vespalib/src/vespa/vespalib/util/regexp.h
+++ b/vespalib/src/vespa/vespalib/util/regexp.h
@@ -63,7 +63,7 @@ public:
* @param replacement text to replace the pattern.
* @return modified string.
**/
- vespalib::string replace(vespalib::stringref s, const vespalib::stringref & replacement) const;
+ vespalib::string replace(vespalib::stringref s, vespalib::stringref replacement) const;
/**
* Look at the given regular expression and identify the prefix