summaryrefslogtreecommitdiffstats
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
parent86139ca05e67c56dfdee0399c4ebc157903f47ea (diff)
Pass stringref by value
-rw-r--r--staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp8
-rw-r--r--staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h8
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp6
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/jsonwriter.h6
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/librarypool.cpp6
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/librarypool.h6
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp24
-rw-r--r--vdslib/src/vespa/vdslib/container/parameters.cpp28
-rw-r--r--vdslib/src/vespa/vdslib/container/parameters.h16
-rw-r--r--vdslib/src/vespa/vdslib/container/parameters.hpp6
-rw-r--r--vdslib/src/vespa/vdslib/state/clusterstate.h2
-rw-r--r--vdslib/src/vespa/vdslib/state/diskstate.cpp2
-rw-r--r--vdslib/src/vespa/vdslib/state/diskstate.h4
-rw-r--r--vdslib/src/vespa/vdslib/state/nodestate.cpp2
-rw-r--r--vdslib/src/vespa/vdslib/state/nodestate.h4
-rw-r--r--vdslib/src/vespa/vdslib/state/nodetype.cpp4
-rw-r--r--vdslib/src/vespa/vdslib/state/nodetype.h4
-rw-r--r--vdslib/src/vespa/vdslib/state/state.cpp4
-rw-r--r--vdslib/src/vespa/vdslib/state/state.h4
-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
37 files changed, 190 insertions, 190 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp b/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp
index 97bb4a9aac7..3082615c59e 100644
--- a/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp
+++ b/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp
@@ -18,7 +18,7 @@ void remove_seq(T &collection, size_t seq) {
} // namespace vespalib::<unnamed>
size_t
-JsonHandlerRepo::State::bind(const vespalib::stringref &path_prefix,
+JsonHandlerRepo::State::bind(vespalib::stringref path_prefix,
const JsonGetHandler &get_handler)
{
std::lock_guard<std::mutex> guard(lock);
@@ -29,7 +29,7 @@ JsonHandlerRepo::State::bind(const vespalib::stringref &path_prefix,
}
size_t
-JsonHandlerRepo::State::add_root_resource(const vespalib::stringref &path)
+JsonHandlerRepo::State::add_root_resource(vespalib::stringref path)
{
std::lock_guard<std::mutex> guard(lock);
size_t my_seq = ++seq;
@@ -47,14 +47,14 @@ JsonHandlerRepo::State::unbind(size_t my_seq) {
//-----------------------------------------------------------------------------
JsonHandlerRepo::Token::UP
-JsonHandlerRepo::bind(const vespalib::stringref &path_prefix,
+JsonHandlerRepo::bind(vespalib::stringref path_prefix,
const JsonGetHandler &get_handler)
{
return Token::UP(new Unbinder(_state, _state->bind(path_prefix, get_handler)));
}
JsonHandlerRepo::Token::UP
-JsonHandlerRepo::add_root_resource(const vespalib::stringref &path)
+JsonHandlerRepo::add_root_resource(vespalib::stringref path)
{
return Token::UP(new Unbinder(_state, _state->add_root_resource(path)));
}
diff --git a/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h b/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h
index b9c8cfdc169..8cca0165cd7 100644
--- a/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h
+++ b/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h
@@ -59,9 +59,9 @@ private:
std::vector<Hook> hooks;
std::vector<Resource> root_resources;
State() : lock(), seq(0), hooks(), root_resources() {}
- size_t bind(const vespalib::stringref &path_prefix,
+ size_t bind(vespalib::stringref path_prefix,
const JsonGetHandler &get_handler);
- size_t add_root_resource(const vespalib::stringref &path);
+ size_t add_root_resource(vespalib::stringref path);
void unbind(size_t my_seq);
};
@@ -79,9 +79,9 @@ private:
public:
JsonHandlerRepo() : _state(std::make_shared<State>()) {}
- Token::UP bind(const vespalib::stringref &path_prefix,
+ Token::UP bind(vespalib::stringref path_prefix,
const JsonGetHandler &get_handler);
- Token::UP add_root_resource(const vespalib::stringref &path);
+ Token::UP add_root_resource(vespalib::stringref path);
std::vector<vespalib::string> get_root_resources() const;
vespalib::string get(const vespalib::string &host,
const vespalib::string &path,
diff --git a/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp b/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp
index 22064864b22..5276e5c7eb9 100644
--- a/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp
@@ -69,7 +69,7 @@ GrowableByteBuffer::putDouble(double v)
}
void
-GrowableByteBuffer::putString(const vespalib::stringref& v)
+GrowableByteBuffer::putString(vespalib::stringref v)
{
putInt(v.size());
putBytes(v.data(), v.size());
diff --git a/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h b/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h
index 787ea0e028e..d65cabd8cb7 100644
--- a/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h
+++ b/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h
@@ -70,7 +70,7 @@ public:
/**
Adds a string to the buffer.
*/
- void putString(const vespalib::stringref & v);
+ void putString(vespalib::stringref v);
/**
Adds a single byte to the buffer.
diff --git a/staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp b/staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp
index 0ad52f9aac2..010b9f57a33 100644
--- a/staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp
@@ -173,7 +173,7 @@ JSONWriter::appendNull()
}
JSONWriter &
-JSONWriter::appendKey(const vespalib::stringref & str)
+JSONWriter::appendKey(stringref str)
{
considerComma();
indent();
@@ -243,7 +243,7 @@ JSONWriter::appendUInt64(uint64_t v)
}
JSONWriter &
-JSONWriter::appendString(const vespalib::stringref & str)
+JSONWriter::appendString(stringref str)
{
considerComma();
quote(str.data(), str.size());
@@ -252,7 +252,7 @@ JSONWriter::appendString(const vespalib::stringref & str)
}
JSONWriter &
-JSONWriter::appendJSON(const vespalib::stringref & json)
+JSONWriter::appendJSON(stringref json)
{
considerComma();
(*_os) << json;
diff --git a/staging_vespalib/src/vespa/vespalib/util/jsonwriter.h b/staging_vespalib/src/vespa/vespalib/util/jsonwriter.h
index 77a805b3c0d..0e9e3e10bc3 100644
--- a/staging_vespalib/src/vespa/vespalib/util/jsonwriter.h
+++ b/staging_vespalib/src/vespa/vespalib/util/jsonwriter.h
@@ -49,14 +49,14 @@ public:
JSONWriter & beginArray();
JSONWriter & endArray();
JSONWriter & appendNull();
- JSONWriter & appendKey(const stringref & str);
+ JSONWriter & appendKey(stringref str);
JSONWriter & appendBool(bool v);
JSONWriter & appendDouble(double v);
JSONWriter & appendFloat(float v);
JSONWriter & appendInt64(int64_t v);
JSONWriter & appendUInt64(uint64_t v);
- JSONWriter & appendString(const stringref & str);
- JSONWriter & appendJSON(const stringref & json);
+ JSONWriter & appendString(stringref str);
+ JSONWriter & appendJSON(stringref json);
void setPretty() { _pretty = true; };
};
diff --git a/staging_vespalib/src/vespa/vespalib/util/librarypool.cpp b/staging_vespalib/src/vespa/vespalib/util/librarypool.cpp
index 45ba2979dc2..2a3ca21c369 100644
--- a/staging_vespalib/src/vespa/vespalib/util/librarypool.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/librarypool.cpp
@@ -19,7 +19,7 @@ LibraryPool::~LibraryPool()
}
void
-LibraryPool::loadLibrary(const stringref & libName)
+LibraryPool::loadLibrary(stringref libName)
{
LockGuard guard(_lock);
if (_libraries.find(libName) == _libraries.end()) {
@@ -36,7 +36,7 @@ LibraryPool::loadLibrary(const stringref & libName)
}
FastOS_DynamicLibrary *
-LibraryPool::get(const stringref & name)
+LibraryPool::get(stringref name)
{
LockGuard guard(_lock);
LibraryMap::const_iterator found(_libraries.find(name));
@@ -46,7 +46,7 @@ LibraryPool::get(const stringref & name)
}
const FastOS_DynamicLibrary *
-LibraryPool::get(const stringref & name) const
+LibraryPool::get(stringref name) const
{
LockGuard guard(_lock);
LibraryMap::const_iterator found(_libraries.find(name));
diff --git a/staging_vespalib/src/vespa/vespalib/util/librarypool.h b/staging_vespalib/src/vespa/vespalib/util/librarypool.h
index 1d8ea1eabec..f6afeb23e69 100644
--- a/staging_vespalib/src/vespa/vespalib/util/librarypool.h
+++ b/staging_vespalib/src/vespa/vespalib/util/librarypool.h
@@ -20,14 +20,14 @@ public:
* @param name The name of the library to load. That is without the 'lib' prefix and the '.so' extension.
* @throws IllegalArgumentException if there are any errors.
*/
- void loadLibrary(const vespalib::stringref & name);
+ void loadLibrary(stringref name);
/**
* Will return the library requested. NULL if not found.
* @param name The name of the library as given in the @ref loadLibrary call.
* @return The library that has already been loaded. NULL if not found.
*/
- FastOS_DynamicLibrary *get(const vespalib::stringref & name);
- const FastOS_DynamicLibrary *get(const vespalib::stringref & name) const;
+ FastOS_DynamicLibrary *get(stringref name);
+ const FastOS_DynamicLibrary *get(stringref name) const;
private:
typedef std::shared_ptr<FastOS_DynamicLibrary> DynamicLibrarySP;
typedef std::map<vespalib::string, DynamicLibrarySP> LibraryMap;
diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
index f42dfe5af98..333f7257595 100644
--- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
@@ -205,26 +205,26 @@ void SearchVisitor::init(const Parameters & params)
_attrMan.add(_documentIdAttributeBacking);
_attrMan.add(_rankAttributeBacking);
Parameters::ValueRef valueRef;
- if ( params.get("summaryclass", valueRef) ) {
+ if ( params.lookup("summaryclass", valueRef) ) {
_summaryClass = vespalib::string(valueRef.data(), valueRef.size());
LOG(debug, "Received summary class: %s", _summaryClass.c_str());
}
size_t wantedSummaryCount(10);
- if (params.get("summarycount", valueRef) ) {
+ if (params.lookup("summarycount", valueRef) ) {
vespalib::string tmp(valueRef.data(), valueRef.size());
wantedSummaryCount = strtoul(tmp.c_str(), nullptr, 0);
LOG(debug, "Received summary count: %ld", wantedSummaryCount);
}
_queryResult->getSearchResult().setWantedHitCount(wantedSummaryCount);
- if (params.get("rankprofile", valueRef) ) {
+ if (params.lookup("rankprofile", valueRef) ) {
vespalib::string tmp(valueRef.data(), valueRef.size());
_rankController.setRankProfile(tmp);
LOG(debug, "Received rank profile: %s", _rankController.getRankProfile().c_str());
}
- if (params.get("queryflags", valueRef) ) {
+ if (params.lookup("queryflags", valueRef) ) {
vespalib::string tmp(valueRef.data(), valueRef.size());
LOG(debug, "Received query flags: 0x%lx", strtoul(tmp.c_str(), nullptr, 0));
uint32_t queryFlags = strtoul(tmp.c_str(), nullptr, 0);
@@ -232,7 +232,7 @@ void SearchVisitor::init(const Parameters & params)
LOG(debug, "QFLAG_DUMP_FEATURES: %s", _rankController.getDumpFeatures() ? "true" : "false");
}
- if (params.get("rankproperties", valueRef) && valueRef.size() > 0) {
+ if (params.lookup("rankproperties", valueRef) && valueRef.size() > 0) {
LOG(spam, "Received rank properties of %zd bytes", valueRef.size());
uint32_t len = static_cast<uint32_t>(valueRef.size());
char * data = const_cast<char *>(valueRef.data());
@@ -259,7 +259,7 @@ void SearchVisitor::init(const Parameters & params)
LOG(debug, "No rank properties received");
}
- if (params.get("rankprofile", valueRef)) {
+ if (params.lookup("rankprofile", valueRef)) {
vespalib::string tmp(valueRef.data(), valueRef.size());
_summaryGenerator.getDocsumState()._args.SetRankProfile(tmp);
}
@@ -270,26 +270,26 @@ void SearchVisitor::init(const Parameters & params)
}
vespalib::string location;
- if (params.get("location", valueRef)) {
+ if (params.lookup("location", valueRef)) {
location = vespalib::string(valueRef.data(), valueRef.size());
LOG(debug, "Location = '%s'", location.c_str());
_summaryGenerator.getDocsumState()._args.SetLocation(valueRef.size(), (const char*)valueRef.data());
}
Parameters::ValueRef searchClusterBlob;
- if (params.get("searchcluster", searchClusterBlob)) {
+ if (params.lookup("searchcluster", searchClusterBlob)) {
LOG(spam, "Received searchcluster blob of %zd bytes", searchClusterBlob.size());
vespalib::string searchCluster(searchClusterBlob.data(), searchClusterBlob.size());
_vsmAdapter = _env.getVSMAdapter(searchCluster);
- if ( params.get("sort", valueRef) ) {
+ if ( params.lookup("sort", valueRef) ) {
search::uca::UcaConverterFactory ucaFactory;
_sortSpec = search::common::SortSpec(vespalib::string(valueRef.data(), valueRef.size()), ucaFactory);
LOG(debug, "Received sort specification: '%s'", _sortSpec.getSpec().c_str());
}
Parameters::ValueRef queryBlob;
- if ( params.get("query", queryBlob) ) {
+ if ( params.lookup("query", queryBlob) ) {
LOG(spam, "Received query blob of %zu bytes", queryBlob.size());
VISITOR_TRACE(9, vespalib::make_string("Setting up for query blob of %zu bytes", queryBlob.size()));
QueryTermDataFactory addOnFactory;
@@ -329,7 +329,7 @@ void SearchVisitor::init(const Parameters & params)
LOG(warning, "No query received");
}
- if (params.get("aggregation", valueRef) ) {
+ if (params.lookup("aggregation", valueRef) ) {
std::vector<char> newAggrBlob;
newAggrBlob.resize(valueRef.size());
memcpy(&newAggrBlob[0], valueRef.data(), newAggrBlob.size());
@@ -341,7 +341,7 @@ void SearchVisitor::init(const Parameters & params)
LOG(warning, "No searchcluster specified");
}
- if ( params.get("unique", valueRef) ) {
+ if ( params.lookup("unique", valueRef) ) {
LOG(spam, "Received unique specification of %zd bytes", valueRef.size());
} else {
LOG(debug, "No unique specification received");
diff --git a/vdslib/src/vespa/vdslib/container/parameters.cpp b/vdslib/src/vespa/vdslib/container/parameters.cpp
index 6294c35ca08..6747bee2bec 100644
--- a/vdslib/src/vespa/vdslib/container/parameters.cpp
+++ b/vdslib/src/vespa/vdslib/container/parameters.cpp
@@ -111,14 +111,14 @@ Parameters* Parameters::clone() const
return new Parameters(*this);
}
-vespalib::stringref Parameters::get(const vespalib::stringref& id, const vespalib::stringref& def) const
+vespalib::stringref Parameters::get(vespalib::stringref id, vespalib::stringref def) const
{
ParametersMap::const_iterator it = _parameters.find(id);
if (it == _parameters.end()) return def;
return it->second;
}
-bool Parameters::get(const KeyT & id, ValueRef & v ) const
+bool Parameters::lookup(KeyT id, ValueRef & v ) const
{
ParametersMap::const_iterator it = _parameters.find(id);
if (it == _parameters.end()) return false;
@@ -160,17 +160,17 @@ std::string Parameters::toString() const
return ret;
}
-template void vdslib::Parameters::set(const vespalib::stringref &, int32_t);
-template void vdslib::Parameters::set(const vespalib::stringref &, int64_t);
-template void vdslib::Parameters::set(const vespalib::stringref &, uint64_t);
-template void vdslib::Parameters::set(const vespalib::stringref &, double);
-template void vdslib::Parameters::set(const vespalib::stringref &, const char *);
-template void vdslib::Parameters::set(const vespalib::stringref &, vespalib::string);
-template void vdslib::Parameters::set(const vespalib::stringref &, std::string);
-template int32_t vdslib::Parameters::get(const vespalib::stringref &, int32_t) const;
-template int64_t vdslib::Parameters::get(const vespalib::stringref &, int64_t) const;
-template uint64_t vdslib::Parameters::get(const vespalib::stringref &, uint64_t) const;
-template double vdslib::Parameters::get(const vespalib::stringref &, double) const;
-template std::string vdslib::Parameters::get(const vespalib::stringref &, std::string) const;
+template void vdslib::Parameters::set(vespalib::stringref , int32_t);
+template void vdslib::Parameters::set(vespalib::stringref , int64_t);
+template void vdslib::Parameters::set(vespalib::stringref , uint64_t);
+template void vdslib::Parameters::set(vespalib::stringref , double);
+template void vdslib::Parameters::set(vespalib::stringref , const char *);
+template void vdslib::Parameters::set(vespalib::stringref , vespalib::string);
+template void vdslib::Parameters::set(vespalib::stringref , std::string);
+template int32_t vdslib::Parameters::get(vespalib::stringref , int32_t) const;
+template int64_t vdslib::Parameters::get(vespalib::stringref , int64_t) const;
+template uint64_t vdslib::Parameters::get(vespalib::stringref , uint64_t) const;
+template double vdslib::Parameters::get(vespalib::stringref , double) const;
+template std::string vdslib::Parameters::get(vespalib::stringref , std::string) const;
VESPALIB_HASH_MAP_INSTANTIATE(vespalib::string, vdslib::Parameters::Value);
diff --git a/vdslib/src/vespa/vdslib/container/parameters.h b/vdslib/src/vespa/vdslib/container/parameters.h
index ab65932496a..02d54643e18 100644
--- a/vdslib/src/vespa/vdslib/container/parameters.h
+++ b/vdslib/src/vespa/vdslib/container/parameters.h
@@ -32,7 +32,7 @@ public:
{
public:
Value() { }
- Value(const vespalib::stringref & s) : vespalib::string(s) { }
+ Value(vespalib::stringref s) : vespalib::string(s) { }
Value(const vespalib::string & s) : vespalib::string(s) { }
Value(const void *v, size_t sz) : vespalib::string(v, sz) { }
size_t length() const { return size() - 1; }
@@ -57,10 +57,10 @@ public:
size_t getSerializedSize() const override;
- bool hasValue(const KeyT & id) const { return (_parameters.find(id) != _parameters.end()); }
+ bool hasValue(KeyT id) const { return (_parameters.find(id) != _parameters.end()); }
unsigned int size() const { return _parameters.size(); }
- bool get(const KeyT & id, ValueRef & v ) const;
- void set(const KeyT & id, const void * v, size_t sz) { _parameters[id] = Value(v, sz); }
+ bool lookup(KeyT id, ValueRef & v) const;
+ void set(KeyT id, const void * v, size_t sz) { _parameters[id] = Value(v, sz); }
void print(std::ostream& out, bool verbose, const std::string& indent) const;
@@ -68,8 +68,8 @@ public:
ParametersMap::const_iterator begin() const { return _parameters.begin(); }
ParametersMap::const_iterator end() const { return _parameters.end(); }
/// Convenience from earlier use.
- void set(const KeyT & id, const vespalib::stringref & value) { _parameters[id] = Value(value.data(), value.size()); }
- vespalib::stringref get(const KeyT & id, const vespalib::stringref & def = "") const;
+ void set(KeyT id, vespalib::stringref value) { _parameters[id] = Value(value.data(), value.size()); }
+ vespalib::stringref get(KeyT id, vespalib::stringref def = "") const;
/**
* Set the value identified by the id given. This requires the type to be
* convertible by stringstreams.
@@ -78,7 +78,7 @@ public:
* @param t The value to save. Will be converted to a string.
*/
template<typename T>
- void set(const KeyT & id, T t);
+ void set(KeyT id, T t);
/**
* Get the value identified by the id given, as the same type as the default
@@ -90,7 +90,7 @@ public:
* the default itself if value did not exist.
*/
template<typename T>
- T get(const KeyT & id, T def) const;
+ T get(KeyT id, T def) const;
std::string toString() const;
};
diff --git a/vdslib/src/vespa/vdslib/container/parameters.hpp b/vdslib/src/vespa/vdslib/container/parameters.hpp
index 3647164961d..d7ad1d266cb 100644
--- a/vdslib/src/vespa/vdslib/container/parameters.hpp
+++ b/vdslib/src/vespa/vdslib/container/parameters.hpp
@@ -8,7 +8,7 @@ namespace vdslib {
template<typename T>
void
-Parameters::set(const KeyT & id, T t) {
+Parameters::set(KeyT id, T t) {
vespalib::asciistream ost;
ost << t;
_parameters[id] = ost.str();
@@ -16,9 +16,9 @@ Parameters::set(const KeyT & id, T t) {
template<typename T>
T
-Parameters::get(const KeyT & id, T def) const {
+Parameters::get(KeyT id, T def) const {
vespalib::stringref ref;
- if (!get(id, ref)) return def;
+ if (!lookup(id, ref)) return def;
vespalib::asciistream ist(ref);
T t;
ist >> t;
diff --git a/vdslib/src/vespa/vdslib/state/clusterstate.h b/vdslib/src/vespa/vdslib/state/clusterstate.h
index 26c6f1b95ef..35259ba672b 100644
--- a/vdslib/src/vespa/vdslib/state/clusterstate.h
+++ b/vdslib/src/vespa/vdslib/state/clusterstate.h
@@ -62,7 +62,7 @@ public:
void setVersion(uint32_t version) { _version = version; }
void setClusterState(const State& state);
void setNodeState(const Node& node, const NodeState& state);
- void setDescription(const vespalib::stringref & s) { _description = s; }
+ void setDescription(vespalib::stringref s) { _description = s; }
void setDistributionBitCount(uint16_t count) { _distributionBits = count; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
diff --git a/vdslib/src/vespa/vdslib/state/diskstate.cpp b/vdslib/src/vespa/vdslib/state/diskstate.cpp
index c963dacff82..56e9f36b442 100644
--- a/vdslib/src/vespa/vdslib/state/diskstate.cpp
+++ b/vdslib/src/vespa/vdslib/state/diskstate.cpp
@@ -30,7 +30,7 @@ DiskState::DiskState(const State& state, const vespalib::stringref & description
setCapacity(capacity);
}
-DiskState::DiskState(const vespalib::stringref & serialized)
+DiskState::DiskState(vespalib::stringref serialized)
: _state(&State::UP),
_description(""),
_capacity(1.0)
diff --git a/vdslib/src/vespa/vdslib/state/diskstate.h b/vdslib/src/vespa/vdslib/state/diskstate.h
index 0dcde1e7879..fb71f5c9733 100644
--- a/vdslib/src/vespa/vdslib/state/diskstate.h
+++ b/vdslib/src/vespa/vdslib/state/diskstate.h
@@ -23,7 +23,7 @@ public:
DiskState();
DiskState(const State&, const vespalib::stringref & description = "", double capacity = 1.0);
- explicit DiskState(const vespalib::stringref & serialized);
+ explicit DiskState(vespalib::stringref serialized);
void serialize(vespalib::asciistream & out, const vespalib::stringref & prefix = "",
bool includeReason = true, bool useOldFormat = false) const;
@@ -34,7 +34,7 @@ public:
void setState(const State& state);
void setCapacity(double capacity);
- void setDescription(const vespalib::stringref & desc) { _description = desc; }
+ void setDescription(vespalib::stringref desc) { _description = desc; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
bool operator==(const DiskState& other) const;
diff --git a/vdslib/src/vespa/vdslib/state/nodestate.cpp b/vdslib/src/vespa/vdslib/state/nodestate.cpp
index d59686dcb1c..c6da5757de3 100644
--- a/vdslib/src/vespa/vdslib/state/nodestate.cpp
+++ b/vdslib/src/vespa/vdslib/state/nodestate.cpp
@@ -78,7 +78,7 @@ namespace {
};
}
-NodeState::NodeState(const vespalib::stringref & serialized, const NodeType* type)
+NodeState::NodeState(vespalib::stringref serialized, const NodeType* type)
: _type(type),
_state(&State::UP),
_description(),
diff --git a/vdslib/src/vespa/vdslib/state/nodestate.h b/vdslib/src/vespa/vdslib/state/nodestate.h
index edf2a308fa0..fef251bdaf1 100644
--- a/vdslib/src/vespa/vdslib/state/nodestate.h
+++ b/vdslib/src/vespa/vdslib/state/nodestate.h
@@ -46,7 +46,7 @@ public:
const vespalib::stringref & description = "",
double capacity = 1.0, uint16_t reliability = 1);
/** Set type if you want to verify that content fit with the given type. */
- NodeState(const vespalib::stringref & serialized, const NodeType* nodeType = 0);
+ NodeState(vespalib::stringref serialized, const NodeType* nodeType = 0);
~NodeState();
/**
@@ -77,7 +77,7 @@ public:
void setReliability(uint16_t reliability);
void setInitProgress(vespalib::Double initProgress);
void setStartTimestamp(uint64_t startTimestamp);
- void setDescription(const vespalib::stringref & desc) { _description = desc; }
+ void setDescription(vespalib::stringref desc) { _description = desc; }
void setDiskCount(uint16_t count);
void setDiskState(uint16_t index, const DiskState&);
diff --git a/vdslib/src/vespa/vdslib/state/nodetype.cpp b/vdslib/src/vespa/vdslib/state/nodetype.cpp
index c7676221e14..b5664bf691b 100644
--- a/vdslib/src/vespa/vdslib/state/nodetype.cpp
+++ b/vdslib/src/vespa/vdslib/state/nodetype.cpp
@@ -14,7 +14,7 @@ const NodeType NodeType::STORAGE("storage", 0);
const NodeType NodeType::DISTRIBUTOR("distributor", 1);
const NodeType&
-NodeType::get(const vespalib::stringref & serialized)
+NodeType::get(vespalib::stringref serialized)
{
if (serialized == STORAGE._name) {
return STORAGE;
@@ -26,7 +26,7 @@ NodeType::get(const vespalib::stringref & serialized)
"Unknown node type " + serialized + " given.", VESPA_STRLOC);
}
-NodeType::NodeType(const vespalib::stringref & name, uint16_t enumValue)
+NodeType::NodeType(vespalib::stringref name, uint16_t enumValue)
: _enumValue(enumValue), _name(name)
{
}
diff --git a/vdslib/src/vespa/vdslib/state/nodetype.h b/vdslib/src/vespa/vdslib/state/nodetype.h
index 318cf59218e..4adf3e0d761 100644
--- a/vdslib/src/vespa/vdslib/state/nodetype.h
+++ b/vdslib/src/vespa/vdslib/state/nodetype.h
@@ -24,14 +24,14 @@ class NodeType {
uint16_t _enumValue;
vespalib::string _name;
- NodeType(const vespalib::stringref & name, uint16_t enumValue);
+ NodeType(vespalib::stringref name, uint16_t enumValue);
public:
static const NodeType DISTRIBUTOR;
static const NodeType STORAGE;
/** Throws vespalib::IllegalArgumentException if invalid state given. */
- static const NodeType& get(const vespalib::stringref & serialized);
+ static const NodeType& get(vespalib::stringref serialized);
const vespalib::string& serialize() const { return _name; }
operator uint16_t() const { return _enumValue; }
diff --git a/vdslib/src/vespa/vdslib/state/state.cpp b/vdslib/src/vespa/vdslib/state/state.cpp
index 2c756aed7f5..b3109492c90 100644
--- a/vdslib/src/vespa/vdslib/state/state.cpp
+++ b/vdslib/src/vespa/vdslib/state/state.cpp
@@ -23,7 +23,7 @@ const State State::UP("Up", "u", 6,
true, true, true, true, true, true);
const State&
-State::get(const vespalib::stringref & serialized)
+State::get(vespalib::stringref serialized)
{
if (serialized.size() == 1) switch(serialized[0]) {
case '-': return UNKNOWN;
@@ -39,7 +39,7 @@ State::get(const vespalib::stringref & serialized)
"Unknown state " + serialized + " given.", VESPA_STRLOC);
}
-State::State(const vespalib::stringref & name, const vespalib::stringref & serialized,
+State::State(vespalib::stringref name, const vespalib::stringref & serialized,
uint8_t rank, bool validDisk,
bool validDistributorReported, bool validStorageReported,
bool validDistributorWanted, bool validStorageWanted,
diff --git a/vdslib/src/vespa/vdslib/state/state.h b/vdslib/src/vespa/vdslib/state/state.h
index e0857fe8ccd..75f5e1cbb8e 100644
--- a/vdslib/src/vespa/vdslib/state/state.h
+++ b/vdslib/src/vespa/vdslib/state/state.h
@@ -26,7 +26,7 @@ class State : public vespalib::Printable {
bool _validClusterState;
State(const State&);
- State(const vespalib::stringref & name, const vespalib::stringref & serialized,
+ State(vespalib::stringref name, const vespalib::stringref & serialized,
uint8_t rank, bool validDisk,
bool validDistributorReported, bool validStorageReported,
bool validDistributorWanted, bool validStorageWanted,
@@ -45,7 +45,7 @@ public:
static const State UP;
/** Throws vespalib::IllegalArgumentException if invalid state given. */
- static const State& get(const vespalib::stringref & serialized);
+ static const State& get(vespalib::stringref serialized);
const vespalib::string& serialize() const { return _serialized; }
bool validDiskState() const { return _validDiskState; }
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