Add StringView class and switch trace processor to use it
In the TraceProcessor most of the strings derived from
protos are not terminated. Instead of passing a pointer and
a length, just pass a StringView.
Test: perfetto_unittests --gtest_filter=StringViewTest.*
Change-Id: Ibd44f54b921fb0960e6cd06b89d625a0402757e3
diff --git a/src/trace_processor/trace_storage.h b/src/trace_processor/trace_storage.h
index b45defe..98e796f 100644
--- a/src/trace_processor/trace_storage.h
+++ b/src/trace_processor/trace_storage.h
@@ -25,6 +25,7 @@
#include <vector>
#include "perfetto/base/logging.h"
+#include "perfetto/base/string_view.h"
#include "perfetto/base/utils.h"
namespace perfetto {
@@ -165,7 +166,7 @@
// Return an unqiue identifier for the contents of each string.
// The string is copied internally and can be destroyed after this called.
- StringId InternString(const char* data, size_t length);
+ StringId InternString(base::StringView);
Process* GetMutableProcess(UniquePid upid) {
PERFETTO_DCHECK(upid > 0 && upid < unique_processes_.size());
@@ -215,7 +216,7 @@
private:
TraceStorage& operator=(const TraceStorage&) = default;
- using StringHash = uint32_t;
+ using StringHash = uint64_t;
// Metadata counters for events being added.
Stats stats_;