Use string_view for pref interface to reduce copy
If you pass in a static string literal like "Hello World!", then with
parameter type of const string& you need to construct a new string
object, requiring a copy. It will also require a copy if your data is in
another container, for example std::vector<char> . In update_engine, we
store manifest bytes in std::vector, and sometimes we want to save that
manifest to disk. This CL can help us reduce copy of the manifest(up to
2MB).
Test: treehugger
Change-Id: I70feb4c0673c174fd47f02c4bd41994f74cda743
diff --git a/common/mock_prefs.h b/common/mock_prefs.h
index c91664e..49431fb 100644
--- a/common/mock_prefs.h
+++ b/common/mock_prefs.h
@@ -31,8 +31,7 @@
public:
MOCK_CONST_METHOD2(GetString,
bool(const std::string& key, std::string* value));
- MOCK_METHOD2(SetString,
- bool(const std::string& key, const std::string& value));
+ MOCK_METHOD2(SetString, bool(const std::string& key, std::string_view value));
MOCK_CONST_METHOD2(GetInt64, bool(const std::string& key, int64_t* value));
MOCK_METHOD2(SetInt64, bool(const std::string& key, const int64_t value));