Skip to content

Improve packed field decoding #959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove redundant checkNotNull calls from pre-null-safe days
  • Loading branch information
osa1 committed Feb 10, 2025
commit edfe97a3e22258fb530571ef6ef16ae9ab6f1571
1 change: 0 additions & 1 deletion protobuf/lib/src/protobuf/coded_buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ void _writeToCodedBufferWriter(_FieldSet fs, CodedBufferWriter out) {

void _mergeFromCodedBufferReader(BuilderInfo meta, _FieldSet fs,
CodedBufferReader input, ExtensionRegistry registry) {
ArgumentError.checkNotNull(registry);
fs._ensureWritable();
while (true) {
final tag = input.readTag();
Expand Down
4 changes: 0 additions & 4 deletions protobuf/lib/src/protobuf/field_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ class FieldInfo<T> {
{this.valueOf, this.enumValues, this.defaultEnumValue, String? protoName})
: makeDefault = (() => PbList<T>(check: check!)),
_protoName = protoName {
ArgumentError.checkNotNull(name, 'name');
ArgumentError.checkNotNull(tagNumber, 'tagNumber');
assert(_isRepeated(type));
assert(check != null);
assert(!_isEnum(type) || valueOf != null);
Expand Down Expand Up @@ -280,8 +278,6 @@ class MapFieldInfo<K, V> extends FieldInfo<PbMap<K, V>?> {
defaultOrMaker: () => PbMap<K, V>(keyFieldType, valueFieldType),
defaultEnumValue: defaultEnumValue,
protoName: protoName) {
ArgumentError.checkNotNull(name, 'name');
ArgumentError.checkNotNull(tagNumber, 'tagNumber');
assert(_isMapField(type));
assert(!_isEnum(type) || valueOf != null);
}
Expand Down
3 changes: 0 additions & 3 deletions protobuf/lib/src/protobuf/field_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ class _FieldSet {
/// Works for both extended and non-extended fields.
/// Suitable for public API.
void _setField(int tagNumber, Object value) {
ArgumentError.checkNotNull(value, 'value');

final meta = _meta;
final fi = _nonExtensionInfo(meta, tagNumber);
if (fi == null) {
Expand All @@ -284,7 +282,6 @@ class _FieldSet {
/// Works for both extended and non-extended fields.
/// Suitable for decoders that do their own validation.
void _setFieldUnchecked(BuilderInfo meta, FieldInfo fi, value) {
ArgumentError.checkNotNull(fi, 'fi');
assert(!fi.isRepeated);
if (fi.index == null) {
_ensureExtensions()
Expand Down
4 changes: 0 additions & 4 deletions protobuf/lib/src/protobuf/generated_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ abstract class GeneratedMessage {

/// Sets the value of a non-repeated extension field to [value].
void setExtension(Extension extension, Object value) {
ArgumentError.checkNotNull(value, 'value');
if (_isRepeated(extension.type)) {
throw ArgumentError(_fieldSet._setFieldFailedMessage(
extension, value, 'repeating field (use get + .add())'));
Expand Down Expand Up @@ -489,7 +488,6 @@ abstract class GeneratedMessage {
/// For generated code only.
/// @nodoc
void $_setFloat(int index, double value) {
ArgumentError.checkNotNull(value, 'value');
if (!_isFloat32(value)) {
_fieldSet._$check(index, value);
}
Expand All @@ -503,7 +501,6 @@ abstract class GeneratedMessage {
/// For generated code only.
/// @nodoc
void $_setSignedInt32(int index, int value) {
ArgumentError.checkNotNull(value, 'value');
if (!_isSigned32(value)) {
_fieldSet._$check(index, value);
}
Expand All @@ -513,7 +510,6 @@ abstract class GeneratedMessage {
/// For generated code only.
/// @nodoc
void $_setUnsignedInt32(int index, int value) {
ArgumentError.checkNotNull(value, 'value');
if (!_isUnsigned32(value)) {
_fieldSet._$check(index, value);
}
Expand Down
Loading