From c521d3de5fb8dc0dc8fdb7ee526ef892aaec1c5d Mon Sep 17 00:00:00 2001 From: Jakob Andersen Date: Thu, 22 Feb 2018 13:26:02 +0100 Subject: [PATCH] Sync changes from internal repo. (#100) * Small performance tweak for DDC. --- CHANGELOG.md | 4 +++ lib/message_generator.dart | 9 ++--- lib/src/dart_options.pb.dart | 2 +- lib/src/descriptor.pb.dart | 66 ++++++++++++++++++------------------ lib/src/plugin.pb.dart | 6 ++-- pubspec.yaml | 4 +-- 6 files changed, 48 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdd7f22..9bb9fde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.7.10 - 2018-02-22 + +* Small performance tweak for DDC. + ## 0.7.9 - 2018-01-12 * Add fast getters for common types. diff --git a/lib/message_generator.dart b/lib/message_generator.dart index 5f6bea5..022d03b 100644 --- a/lib/message_generator.dart +++ b/lib/message_generator.dart @@ -321,8 +321,8 @@ class MessageGenerator extends ProtobufContainer { var names = field.memberNames; _emitOverrideIf(field.overridesGetter, out); - var getterExpr = - _getterExpression(fieldTypeString, field.index, defaultExpr); + var getterExpr = _getterExpression( + fieldTypeString, field.index, defaultExpr, field.isRepeated); out.println('${fieldTypeString} get ${names.fieldName} => ${getterExpr};'); if (field.isRepeated) { @@ -361,7 +361,8 @@ class MessageGenerator extends ProtobufContainer { } } - String _getterExpression(String fieldType, int index, String defaultExpr) { + String _getterExpression( + String fieldType, int index, String defaultExpr, bool isRepeated) { if (fieldType == 'String') { return '\$_getS($index, $defaultExpr)'; } @@ -369,7 +370,7 @@ class MessageGenerator extends ProtobufContainer { return '\$_getI64($index)'; } if (defaultExpr == 'null') { - return '\$_getN($index)'; + return isRepeated ? '\$_getList($index)' : '\$_getN($index)'; } return '\$_get($index, $defaultExpr)'; } diff --git a/lib/src/dart_options.pb.dart b/lib/src/dart_options.pb.dart index 68a1822..e730e4a 100644 --- a/lib/src/dart_options.pb.dart +++ b/lib/src/dart_options.pb.dart @@ -89,7 +89,7 @@ class Imports extends GeneratedMessage { if (v is! Imports) checkItemFailed(v, 'Imports'); } - List get mixins => $_getN(0); + List get mixins => $_getList(0); } class _ReadonlyImports extends Imports with ReadonlyMessageMixin {} diff --git a/lib/src/descriptor.pb.dart b/lib/src/descriptor.pb.dart index 2fd1f63..b21aa95 100644 --- a/lib/src/descriptor.pb.dart +++ b/lib/src/descriptor.pb.dart @@ -42,7 +42,7 @@ class FileDescriptorSet extends GeneratedMessage { if (v is! FileDescriptorSet) checkItemFailed(v, 'FileDescriptorSet'); } - List get file => $_getN(0); + List get file => $_getList(0); } class _ReadonlyFileDescriptorSet extends FileDescriptorSet @@ -109,15 +109,15 @@ class FileDescriptorProto extends GeneratedMessage { bool hasPackage() => $_has(1); void clearPackage() => clearField(2); - List get dependency => $_getN(2); + List get dependency => $_getList(2); - List get messageType => $_getN(3); + List get messageType => $_getList(3); - List get enumType => $_getN(4); + List get enumType => $_getList(4); - List get service => $_getN(5); + List get service => $_getList(5); - List get extension => $_getN(6); + List get extension => $_getList(6); FileOptions get options => $_getN(7); set options(FileOptions v) { @@ -135,9 +135,9 @@ class FileDescriptorProto extends GeneratedMessage { bool hasSourceCodeInfo() => $_has(8); void clearSourceCodeInfo() => clearField(9); - List get publicDependency => $_getN(9); + List get publicDependency => $_getList(9); - List get weakDependency => $_getN(10); + List get weakDependency => $_getList(10); String get syntax => $_getS(11, ''); set syntax(String v) { @@ -316,15 +316,15 @@ class DescriptorProto extends GeneratedMessage { bool hasName() => $_has(0); void clearName() => clearField(1); - List get field => $_getN(1); + List get field => $_getList(1); - List get nestedType => $_getN(2); + List get nestedType => $_getList(2); - List get enumType => $_getN(3); + List get enumType => $_getList(3); - List get extensionRange => $_getN(4); + List get extensionRange => $_getList(4); - List get extension => $_getN(5); + List get extension => $_getList(5); MessageOptions get options => $_getN(6); set options(MessageOptions v) { @@ -334,11 +334,11 @@ class DescriptorProto extends GeneratedMessage { bool hasOptions() => $_has(6); void clearOptions() => clearField(7); - List get oneofDecl => $_getN(7); + List get oneofDecl => $_getList(7); - List get reservedRange => $_getN(8); + List get reservedRange => $_getList(8); - List get reservedName => $_getN(9); + List get reservedName => $_getList(9); } class _ReadonlyDescriptorProto extends DescriptorProto @@ -568,7 +568,7 @@ class EnumDescriptorProto extends GeneratedMessage { bool hasName() => $_has(0); void clearName() => clearField(1); - List get value => $_getN(1); + List get value => $_getList(1); EnumOptions get options => $_getN(2); set options(EnumOptions v) { @@ -683,7 +683,7 @@ class ServiceDescriptorProto extends GeneratedMessage { bool hasName() => $_has(0); void clearName() => clearField(1); - List get method => $_getN(1); + List get method => $_getList(1); ServiceOptions get options => $_getN(2); set options(ServiceOptions v) { @@ -970,7 +970,7 @@ class FileOptions extends GeneratedMessage { bool hasPhpNamespace() => $_has(16); void clearPhpNamespace() => clearField(41); - List get uninterpretedOption => $_getN(17); + List get uninterpretedOption => $_getList(17); } class _ReadonlyFileOptions extends FileOptions with ReadonlyMessageMixin {} @@ -1040,7 +1040,7 @@ class MessageOptions extends GeneratedMessage { bool hasMapEntry() => $_has(3); void clearMapEntry() => clearField(7); - List get uninterpretedOption => $_getN(4); + List get uninterpretedOption => $_getList(4); } class _ReadonlyMessageOptions extends MessageOptions with ReadonlyMessageMixin { @@ -1140,7 +1140,7 @@ class FieldOptions extends GeneratedMessage { bool hasWeak() => $_has(5); void clearWeak() => clearField(10); - List get uninterpretedOption => $_getN(6); + List get uninterpretedOption => $_getList(6); } class _ReadonlyFieldOptions extends FieldOptions with ReadonlyMessageMixin {} @@ -1173,7 +1173,7 @@ class OneofOptions extends GeneratedMessage { if (v is! OneofOptions) checkItemFailed(v, 'OneofOptions'); } - List get uninterpretedOption => $_getN(0); + List get uninterpretedOption => $_getList(0); } class _ReadonlyOneofOptions extends OneofOptions with ReadonlyMessageMixin {} @@ -1223,7 +1223,7 @@ class EnumOptions extends GeneratedMessage { bool hasDeprecated() => $_has(1); void clearDeprecated() => clearField(3); - List get uninterpretedOption => $_getN(2); + List get uninterpretedOption => $_getList(2); } class _ReadonlyEnumOptions extends EnumOptions with ReadonlyMessageMixin {} @@ -1266,7 +1266,7 @@ class EnumValueOptions extends GeneratedMessage { bool hasDeprecated() => $_has(0); void clearDeprecated() => clearField(1); - List get uninterpretedOption => $_getN(1); + List get uninterpretedOption => $_getList(1); } class _ReadonlyEnumValueOptions extends EnumValueOptions @@ -1310,7 +1310,7 @@ class ServiceOptions extends GeneratedMessage { bool hasDeprecated() => $_has(0); void clearDeprecated() => clearField(33); - List get uninterpretedOption => $_getN(1); + List get uninterpretedOption => $_getList(1); } class _ReadonlyServiceOptions extends ServiceOptions with ReadonlyMessageMixin { @@ -1368,7 +1368,7 @@ class MethodOptions extends GeneratedMessage { bool hasIdempotencyLevel() => $_has(1); void clearIdempotencyLevel() => clearField(34); - List get uninterpretedOption => $_getN(2); + List get uninterpretedOption => $_getList(2); } class _ReadonlyMethodOptions extends MethodOptions with ReadonlyMessageMixin {} @@ -1463,7 +1463,7 @@ class UninterpretedOption extends GeneratedMessage { if (v is! UninterpretedOption) checkItemFailed(v, 'UninterpretedOption'); } - List get name => $_getN(0); + List get name => $_getList(0); String get identifierValue => $_getS(1, ''); set identifierValue(String v) { @@ -1551,9 +1551,9 @@ class SourceCodeInfo_Location extends GeneratedMessage { checkItemFailed(v, 'SourceCodeInfo_Location'); } - List get path => $_getN(0); + List get path => $_getList(0); - List get span => $_getN(1); + List get span => $_getList(1); String get leadingComments => $_getS(2, ''); set leadingComments(String v) { @@ -1571,7 +1571,7 @@ class SourceCodeInfo_Location extends GeneratedMessage { bool hasTrailingComments() => $_has(3); void clearTrailingComments() => clearField(4); - List get leadingDetachedComments => $_getN(4); + List get leadingDetachedComments => $_getList(4); } class _ReadonlySourceCodeInfo_Location extends SourceCodeInfo_Location @@ -1606,7 +1606,7 @@ class SourceCodeInfo extends GeneratedMessage { if (v is! SourceCodeInfo) checkItemFailed(v, 'SourceCodeInfo'); } - List get location => $_getN(0); + List get location => $_getList(0); } class _ReadonlySourceCodeInfo extends SourceCodeInfo with ReadonlyMessageMixin { @@ -1646,7 +1646,7 @@ class GeneratedCodeInfo_Annotation extends GeneratedMessage { checkItemFailed(v, 'GeneratedCodeInfo_Annotation'); } - List get path => $_getN(0); + List get path => $_getList(0); String get sourceFile => $_getS(1, ''); set sourceFile(String v) { @@ -1709,7 +1709,7 @@ class GeneratedCodeInfo extends GeneratedMessage { if (v is! GeneratedCodeInfo) checkItemFailed(v, 'GeneratedCodeInfo'); } - List get annotation => $_getN(0); + List get annotation => $_getList(0); } class _ReadonlyGeneratedCodeInfo extends GeneratedCodeInfo diff --git a/lib/src/plugin.pb.dart b/lib/src/plugin.pb.dart index d09719a..2122589 100644 --- a/lib/src/plugin.pb.dart +++ b/lib/src/plugin.pb.dart @@ -111,7 +111,7 @@ class CodeGeneratorRequest extends GeneratedMessage { if (v is! CodeGeneratorRequest) checkItemFailed(v, 'CodeGeneratorRequest'); } - List get fileToGenerate => $_getN(0); + List get fileToGenerate => $_getList(0); String get parameter => $_getS(1, ''); set parameter(String v) { @@ -129,7 +129,7 @@ class CodeGeneratorRequest extends GeneratedMessage { bool hasCompilerVersion() => $_has(2); void clearCompilerVersion() => clearField(3); - List<$google$protobuf.FileDescriptorProto> get protoFile => $_getN(3); + List<$google$protobuf.FileDescriptorProto> get protoFile => $_getList(3); } class _ReadonlyCodeGeneratorRequest extends CodeGeneratorRequest @@ -240,7 +240,7 @@ class CodeGeneratorResponse extends GeneratedMessage { bool hasError() => $_has(0); void clearError() => clearField(1); - List get file => $_getN(1); + List get file => $_getList(1); } class _ReadonlyCodeGeneratorResponse extends CodeGeneratorResponse diff --git a/pubspec.yaml b/pubspec.yaml index 85a3752..127215d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: protoc_plugin -version: 0.7.9 +version: 0.7.10 author: Dart Team description: Protoc compiler plugin to generate Dart code homepage: https://github.com/dart-lang/dart-protoc-plugin @@ -8,7 +8,7 @@ environment: dependencies: fixnum: ^0.10.5 path: ^1.0.0 - protobuf: ^0.7.0 + protobuf: ^0.7.1 dart_style: ^1.0.6 dev_dependencies: browser: any