summaryrefslogtreecommitdiff
path: root/upbc
diff options
context:
space:
mode:
Diffstat (limited to 'upbc')
-rw-r--r--upbc/generator.cc2
-rw-r--r--upbc/message_layout.cc4
2 files changed, 4 insertions, 2 deletions
diff --git a/upbc/generator.cc b/upbc/generator.cc
index bb29041..68996a9 100644
--- a/upbc/generator.cc
+++ b/upbc/generator.cc
@@ -521,7 +521,7 @@ void WriteSource(const protobuf::FileDescriptor* file, Output& output) {
}
if (MessageLayout::HasHasbit(field)) {
- presence = absl::StrCat(layout.GetHasbitIndex(field) + 1);
+ presence = absl::StrCat(layout.GetHasbitIndex(field));
} else if (field->containing_oneof()) {
MessageLayout::Size case_offset =
layout.GetOneofCaseOffset(field->containing_oneof());
diff --git a/upbc/message_layout.cc b/upbc/message_layout.cc
index 5956424..f0a6872 100644
--- a/upbc/message_layout.cc
+++ b/upbc/message_layout.cc
@@ -130,7 +130,9 @@ void MessageLayout::PlaceNonOneofFields(
int hasbit_count = 0;
for (auto field : field_order) {
if (HasHasbit(field)) {
- hasbit_indexes_[field] = hasbit_count++;
+ // We don't use hasbit 0, so that 0 can indicate "no presence" in the
+ // table. This wastes one hasbit, but we don't worry about it for now.
+ hasbit_indexes_[field] = ++hasbit_count;
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback