Merge "Explicitly intern the empty string as 0."
diff --git a/src/profiling/memory/bookkeeping.h b/src/profiling/memory/bookkeeping.h
index 1559459..3ce98df 100644
--- a/src/profiling/memory/bookkeeping.h
+++ b/src/profiling/memory/bookkeeping.h
@@ -208,6 +208,13 @@
current_trace_packet = trace_writer->NewTracePacket();
current_profile_packet = current_trace_packet->set_profile_packet();
current_profile_packet->set_index((*next_index)++);
+
+ // Explicitly reserve intern ID 0 for the empty string, so unset string
+ // fields get mapped to this.
+ auto interned_string = current_profile_packet->add_strings();
+ constexpr const uint8_t kEmptyString[] = "";
+ interned_string->set_id(0);
+ interned_string->set_str(kEmptyString, 0);
}
void WriteMap(const Interned<Mapping> map);