Sync changes from internal repo. (#100)
* Small performance tweak for DDC.
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 @@
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 @@
}
}
- 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 @@
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 @@
if (v is! Imports) checkItemFailed(v, 'Imports');
}
- List<DartMixin> get mixins => $_getN(0);
+ List<DartMixin> 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 @@
if (v is! FileDescriptorSet) checkItemFailed(v, 'FileDescriptorSet');
}
- List<FileDescriptorProto> get file => $_getN(0);
+ List<FileDescriptorProto> get file => $_getList(0);
}
class _ReadonlyFileDescriptorSet extends FileDescriptorSet
@@ -109,15 +109,15 @@
bool hasPackage() => $_has(1);
void clearPackage() => clearField(2);
- List<String> get dependency => $_getN(2);
+ List<String> get dependency => $_getList(2);
- List<DescriptorProto> get messageType => $_getN(3);
+ List<DescriptorProto> get messageType => $_getList(3);
- List<EnumDescriptorProto> get enumType => $_getN(4);
+ List<EnumDescriptorProto> get enumType => $_getList(4);
- List<ServiceDescriptorProto> get service => $_getN(5);
+ List<ServiceDescriptorProto> get service => $_getList(5);
- List<FieldDescriptorProto> get extension => $_getN(6);
+ List<FieldDescriptorProto> get extension => $_getList(6);
FileOptions get options => $_getN(7);
set options(FileOptions v) {
@@ -135,9 +135,9 @@
bool hasSourceCodeInfo() => $_has(8);
void clearSourceCodeInfo() => clearField(9);
- List<int> get publicDependency => $_getN(9);
+ List<int> get publicDependency => $_getList(9);
- List<int> get weakDependency => $_getN(10);
+ List<int> get weakDependency => $_getList(10);
String get syntax => $_getS(11, '');
set syntax(String v) {
@@ -316,15 +316,15 @@
bool hasName() => $_has(0);
void clearName() => clearField(1);
- List<FieldDescriptorProto> get field => $_getN(1);
+ List<FieldDescriptorProto> get field => $_getList(1);
- List<DescriptorProto> get nestedType => $_getN(2);
+ List<DescriptorProto> get nestedType => $_getList(2);
- List<EnumDescriptorProto> get enumType => $_getN(3);
+ List<EnumDescriptorProto> get enumType => $_getList(3);
- List<DescriptorProto_ExtensionRange> get extensionRange => $_getN(4);
+ List<DescriptorProto_ExtensionRange> get extensionRange => $_getList(4);
- List<FieldDescriptorProto> get extension => $_getN(5);
+ List<FieldDescriptorProto> get extension => $_getList(5);
MessageOptions get options => $_getN(6);
set options(MessageOptions v) {
@@ -334,11 +334,11 @@
bool hasOptions() => $_has(6);
void clearOptions() => clearField(7);
- List<OneofDescriptorProto> get oneofDecl => $_getN(7);
+ List<OneofDescriptorProto> get oneofDecl => $_getList(7);
- List<DescriptorProto_ReservedRange> get reservedRange => $_getN(8);
+ List<DescriptorProto_ReservedRange> get reservedRange => $_getList(8);
- List<String> get reservedName => $_getN(9);
+ List<String> get reservedName => $_getList(9);
}
class _ReadonlyDescriptorProto extends DescriptorProto
@@ -568,7 +568,7 @@
bool hasName() => $_has(0);
void clearName() => clearField(1);
- List<EnumValueDescriptorProto> get value => $_getN(1);
+ List<EnumValueDescriptorProto> get value => $_getList(1);
EnumOptions get options => $_getN(2);
set options(EnumOptions v) {
@@ -683,7 +683,7 @@
bool hasName() => $_has(0);
void clearName() => clearField(1);
- List<MethodDescriptorProto> get method => $_getN(1);
+ List<MethodDescriptorProto> get method => $_getList(1);
ServiceOptions get options => $_getN(2);
set options(ServiceOptions v) {
@@ -970,7 +970,7 @@
bool hasPhpNamespace() => $_has(16);
void clearPhpNamespace() => clearField(41);
- List<UninterpretedOption> get uninterpretedOption => $_getN(17);
+ List<UninterpretedOption> get uninterpretedOption => $_getList(17);
}
class _ReadonlyFileOptions extends FileOptions with ReadonlyMessageMixin {}
@@ -1040,7 +1040,7 @@
bool hasMapEntry() => $_has(3);
void clearMapEntry() => clearField(7);
- List<UninterpretedOption> get uninterpretedOption => $_getN(4);
+ List<UninterpretedOption> get uninterpretedOption => $_getList(4);
}
class _ReadonlyMessageOptions extends MessageOptions with ReadonlyMessageMixin {
@@ -1140,7 +1140,7 @@
bool hasWeak() => $_has(5);
void clearWeak() => clearField(10);
- List<UninterpretedOption> get uninterpretedOption => $_getN(6);
+ List<UninterpretedOption> get uninterpretedOption => $_getList(6);
}
class _ReadonlyFieldOptions extends FieldOptions with ReadonlyMessageMixin {}
@@ -1173,7 +1173,7 @@
if (v is! OneofOptions) checkItemFailed(v, 'OneofOptions');
}
- List<UninterpretedOption> get uninterpretedOption => $_getN(0);
+ List<UninterpretedOption> get uninterpretedOption => $_getList(0);
}
class _ReadonlyOneofOptions extends OneofOptions with ReadonlyMessageMixin {}
@@ -1223,7 +1223,7 @@
bool hasDeprecated() => $_has(1);
void clearDeprecated() => clearField(3);
- List<UninterpretedOption> get uninterpretedOption => $_getN(2);
+ List<UninterpretedOption> get uninterpretedOption => $_getList(2);
}
class _ReadonlyEnumOptions extends EnumOptions with ReadonlyMessageMixin {}
@@ -1266,7 +1266,7 @@
bool hasDeprecated() => $_has(0);
void clearDeprecated() => clearField(1);
- List<UninterpretedOption> get uninterpretedOption => $_getN(1);
+ List<UninterpretedOption> get uninterpretedOption => $_getList(1);
}
class _ReadonlyEnumValueOptions extends EnumValueOptions
@@ -1310,7 +1310,7 @@
bool hasDeprecated() => $_has(0);
void clearDeprecated() => clearField(33);
- List<UninterpretedOption> get uninterpretedOption => $_getN(1);
+ List<UninterpretedOption> get uninterpretedOption => $_getList(1);
}
class _ReadonlyServiceOptions extends ServiceOptions with ReadonlyMessageMixin {
@@ -1368,7 +1368,7 @@
bool hasIdempotencyLevel() => $_has(1);
void clearIdempotencyLevel() => clearField(34);
- List<UninterpretedOption> get uninterpretedOption => $_getN(2);
+ List<UninterpretedOption> get uninterpretedOption => $_getList(2);
}
class _ReadonlyMethodOptions extends MethodOptions with ReadonlyMessageMixin {}
@@ -1463,7 +1463,7 @@
if (v is! UninterpretedOption) checkItemFailed(v, 'UninterpretedOption');
}
- List<UninterpretedOption_NamePart> get name => $_getN(0);
+ List<UninterpretedOption_NamePart> get name => $_getList(0);
String get identifierValue => $_getS(1, '');
set identifierValue(String v) {
@@ -1551,9 +1551,9 @@
checkItemFailed(v, 'SourceCodeInfo_Location');
}
- List<int> get path => $_getN(0);
+ List<int> get path => $_getList(0);
- List<int> get span => $_getN(1);
+ List<int> get span => $_getList(1);
String get leadingComments => $_getS(2, '');
set leadingComments(String v) {
@@ -1571,7 +1571,7 @@
bool hasTrailingComments() => $_has(3);
void clearTrailingComments() => clearField(4);
- List<String> get leadingDetachedComments => $_getN(4);
+ List<String> get leadingDetachedComments => $_getList(4);
}
class _ReadonlySourceCodeInfo_Location extends SourceCodeInfo_Location
@@ -1606,7 +1606,7 @@
if (v is! SourceCodeInfo) checkItemFailed(v, 'SourceCodeInfo');
}
- List<SourceCodeInfo_Location> get location => $_getN(0);
+ List<SourceCodeInfo_Location> get location => $_getList(0);
}
class _ReadonlySourceCodeInfo extends SourceCodeInfo with ReadonlyMessageMixin {
@@ -1646,7 +1646,7 @@
checkItemFailed(v, 'GeneratedCodeInfo_Annotation');
}
- List<int> get path => $_getN(0);
+ List<int> get path => $_getList(0);
String get sourceFile => $_getS(1, '');
set sourceFile(String v) {
@@ -1709,7 +1709,7 @@
if (v is! GeneratedCodeInfo) checkItemFailed(v, 'GeneratedCodeInfo');
}
- List<GeneratedCodeInfo_Annotation> get annotation => $_getN(0);
+ List<GeneratedCodeInfo_Annotation> 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 @@
if (v is! CodeGeneratorRequest) checkItemFailed(v, 'CodeGeneratorRequest');
}
- List<String> get fileToGenerate => $_getN(0);
+ List<String> get fileToGenerate => $_getList(0);
String get parameter => $_getS(1, '');
set parameter(String v) {
@@ -129,7 +129,7 @@
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 @@
bool hasError() => $_has(0);
void clearError() => clearField(1);
- List<CodeGeneratorResponse_File> get file => $_getN(1);
+ List<CodeGeneratorResponse_File> 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 <misc@dartlang.org>
description: Protoc compiler plugin to generate Dart code
homepage: https://github.com/dart-lang/dart-protoc-plugin
@@ -8,7 +8,7 @@
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